/dev/null 2>&1
echo 'The password for %(target)s is user "user", password "%(password)s"'
fi
""" % params
os.system(cmd)
def remove_evil_lines(evils,filename):
''' Exclude evil lines '''
fc = open(filename,'r')
filecontent=[]
fixes=0
for line in fc:
for evil in evils:
if evil.search(line):
line=''
fixes+=1
break # ooh, efficiency
filecontent.append(line)
fc.close()
if fixes == 0:
return []
fc = open(filename,'w');
fc.writelines(filecontent)
fc.close()
return [ filename, ]
def cleanup_htaccess(args):
"Cleanup a htaccess injection"
evils = (
re.compile(r'^(\s+$|\s{10}).*\n'),
)
fixes=[]
for filename in args:
if filename.find('htaccess')>=0:
fixes.extend( remove_evil_lines(evils,filename) )
return fixes
def remove_evils(evils,filename):
''' Removing matching part of evil regex '''
fixes=0
fc = open(filename,'r')
filecontent = fc.read()
fc.close()
for evil in evils:
newcontent=evil.sub('',filecontent)
if newcontent!=filecontent: fixes+=1
filecontent=newcontent
if fixes:
fc = open(filename,'w');
fc.write(filecontent);
fc.close()
return [ filename, ]
return []
def cleanup_eval(args):
"Cleanup an eval injection"
evils = (
re.compile(r'<\?php\s+.*strto.*\[\d\].*\?>'),
re.compile(r'<\?php\s+(eval|preg_replace)\([^;]*\);\s*\?>'), # php segment consisting entirely of eval or equivalent
re.compile(r'(eval|echo)\(base64.*?;'),
re.compile(r'<\?php\s*\?>\s*|/\*\*/ *',re.I),
);
fixes=[]
for filename in args:
fixes.extend(remove_evils(evils,filename))
return fixes
def cleanup_iframe(args):
evils = (
re.compile(r'echo "";\s*',re.I),
re.compile(r'',re.I),
re.compile(r']*style=[^>]*?(display:\s*none|visibility:\s*hidden|left:\s*-\d\d\d\d).*?href="?http://.*?',re.I | re.S),
re.compile(r']*style=[^>]*?(display:\s*none|visibility:\s*hidden|left:\s*-\d\d\d\d|(width|height):\s*0|overflow:\s*hidden).*?href="?http://.*?', re.I | re.S),
re.compile(r']*style=[^>]*?(display:\s*none|visibility:\s*hidden|left:\s*-\d\d\d\d).*?href="?http://.*?
', re.I | re.S),
re.compile(r'', re.I | re.S),
re.compile(r'