Open-Redirect
https://gitlab.com/jobertabma/vulnerable-code/-/tree/master/open-redirect?ref_type=heads
Step 1: Understand the Vulnerability
The
index.phpscript simply takes thenextparameter from the URL query string and appends it to theLocationheader for redirectionThis code does not perform any validation on the
nextparameter, which allows an attacker to control the redirection destination.

Step 2: Create and Run the Bash Script
1.Create the Bash Script: Create a file named open-redirect.sh and add the provided Bash script to it.
- Explanation of the Script:
echo $1 > _tmp/strip: This line writes the first argument passed to the script into a file namedstripin the_tmpdirectory.php -S 127.0.0.1:8080 -topen-redirect&: This line starts a local PHP server on127.0.0.1(localhost) at port8080, serving files from the open-redirect directory, and runs it in the background.open 'http://127.0.0.1:8080/?next=https://hackerone.com' Open the URL in the default web browser
wait: This line waits for the background process (the PHP server) to finish
2.Make the Script Executable: Change the script's permissions to make it executable.
3. Run the script:

Expected Outcomes:
Server Start: The PHP built-in server should start and listen on
127.0.0.1:8080.Redirect Execution: The script should open the default web browser and navigate to the URL
http://127.0.0.1:8080/?next=https://hackerone.com.Redirection Confirmation: Once the browser processes the URL, it should be redirected to
https://hackerone.com. This confirms that theindex.phpscript is vulnerable to open-redirect attacks and that the vulnerability has been successfully exploited.

Last updated