Skip to content

Instantly share code, notes, and snippets.

@eladmeidar
Created January 20, 2011 10:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eladmeidar/787703 to your computer and use it in GitHub Desktop.
Save eladmeidar/787703 to your computer and use it in GitHub Desktop.
A rails metal sinatra app that identifies evil .php requests / word press submissions, usually originated in evil attempts to spam your app. oh, the youtube like is replaceable :)
# app/metal/wordpress_attacks.rb
#
# Remember to add sinatra to your Gemfile.
require 'sinatra/base'
class WordPressAttacks < Sinatra::Base
helpers do
def youtube_movie_url
"http://www.youtube.com/watch?v=EDcWCGdr-wE"
end
def filter_wordpress_attacks
redirect youtube_movie_url if request.query_string =~ /wp_/
incoming_paramerters = params.keys
incoming_paramerters.each do |parameter_name|
redirect youtube_movie_url if parameter_name =~ /^wp_/
end
end
end
get "*.php" do
redirect youtube_movie_url
end
post "*.php" do
redirect youtube_movie_url
end
delete "*.php" do
redirect youtube_movie_url
end
put "*.php" do
redirect youtube_movie_url
end
get "*" do
filter_wordpress_attacks
end
post "*" do
filter_wordpress_attacks
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment