def checkfile(filename): fp=open(filename) content = fp.read() for keyword in keywords: if re.search(keyword[0],content,re.I): log="%s:%s" % (filename,keyword[1]) #print log print >>writelog,log fp.close()
def checkdir(dirname): try: ls=os.listdir(dirname) except: print 'access deny' else: for l in ls: temp=os.path.join(dirname,l) if(os.path.isdir(temp)): checkdir(temp) else: ext = temp[temp.rindex('.'):] if ext in findtype: checkfile(temp)
if __name__=="__main__": print "PHP webshell check for Python!" print "By:Neeao" print "http://Neeao.com" if len(sys.argv) < 2: print "%s C://" % sys.argv[0] else: print "Check start!" dirs=sys.argv[1:] #print dirs[0] if os.path.exists(dirs[0]): checkdir(dirs[0]) else: print "Dir:'%s' not exists!" % dirs[0]