Skip to content

Instantly share code, notes, and snippets.

@eristoddle
Created June 28, 2012 15:33
Show Gist options
  • Save eristoddle/3012036 to your computer and use it in GitHub Desktop.
Save eristoddle/3012036 to your computer and use it in GitHub Desktop.
Find .htaccess hacks in your website with Python
import os
#Replace with name of directory to scan, i.e, your WP directory
dir = "/var/www/"
#Replace with string to find, in my case, this domain, which my site was redirecting to
to_find = "vlag-nerto.ru"
for root, dirs, files in os.walk(dir):
for file in files:
fullpath = os.path.join(root, file)
#if os.path.splitext(fullpath)[1] == '.php':
if file == '.htaccess':
f = open(fullpath)
for line in f:
if line.find(to_find) > -1:
print "Bad: " + fullpath
else:
pass
#print "Good: " + fullpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment