Created
January 20, 2011 10:22
-
-
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 :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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