import os,re import requests filenames = os.listdir('/var/www/html/src') pattern = re.compile(r"\$_[GEPOST]{3,4}\[.*?\]") for name in filenames: print(name) withopen('/var/www/html/src/'+name,'r') as f: data = f.read() result = list(set(pattern.findall(data))) for ret in result: try: command = 'uname' flag = 'Linux' # command = 'phpinfo();' # flag = 'phpinfo' if'GET'in ret: passwd = re.findall(r"'(.*)'",ret)[0] r = requests.get(url='http://127.0.0.1:8888/' + name + '?' + passwd + '='+ command) if flag in r.text: print('backdoor file is: ' + name) print('GET: ' + passwd) elif'POST'in ret: passwd = re.findall(r"'(.*)'",ret)[0] r = requests.post(url='http://127.0.0.1:8888/' + name,data={passwd:command}) if flag in r.text: print('backdoor file is: ' + name) print('POST: ' + passwd) except : pass