Skip to content

Instantly share code, notes, and snippets.

@Splint3r7
Created March 29, 2021 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Splint3r7/09d82684dfe701a4aa319c5beffb64cd to your computer and use it in GitHub Desktop.
Save Splint3r7/09d82684dfe701a4aa319c5beffb64cd to your computer and use it in GitHub Desktop.
WKHTMLTOPDF SSRF PHP CODE
<?php
# Before starting this lab make sure wkhtmltopdf is installed.
header("Content-Type: text/html");
$bad = "script";
$param = $_GET["xss"];
echo "Printing your payload on pdf file sur ;_;</br>";
// Test if string contains the word
if(strpos($param, $bad) !== false){
echo "</br>you blacklisted-bitch no scripts";
exit;
} else{
# Used str_ireplace to check case-sensitive script combinations
$param = str_ireplace($bad, "", $param);
$fp = fopen('test.html', 'w');
fwrite($fp, $param);
fclose($fp);
}
$html_file_url = 'test.html';
$pdf_file_url = 'test.pdf';
$cmd = "/usr/bin/wkhtmltopdf $html_file_url $pdf_file_url";
shell_exec($cmd);
echo "</br><br>Your PDF is ready <a href='read.php'>Your PDF :)</a>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment