Add search engines support
parent
74ad8e4970
commit
1a3eeaf4cf
|
@ -1,6 +1,22 @@
|
||||||
module ProjectHoneypot
|
module ProjectHoneypot
|
||||||
class Url
|
class Url
|
||||||
attr_reader :ip_address, :last_activity, :score, :offenses
|
SEARCH_ENGINES = %w(
|
||||||
|
Undocumented
|
||||||
|
AltaVista
|
||||||
|
Ask
|
||||||
|
Baidu
|
||||||
|
Excite
|
||||||
|
Google
|
||||||
|
Looksmart
|
||||||
|
Lycos
|
||||||
|
MSN
|
||||||
|
Yahoo
|
||||||
|
Cuil
|
||||||
|
InfoSeek
|
||||||
|
Miscellaneous
|
||||||
|
)
|
||||||
|
|
||||||
|
attr_reader :ip_address, :last_activity, :score, :offenses, :search_engine
|
||||||
def initialize(ip_address, honeypot_response)
|
def initialize(ip_address, honeypot_response)
|
||||||
@ip_address = ip_address
|
@ip_address = ip_address
|
||||||
@safe = honeypot_response.nil?
|
@safe = honeypot_response.nil?
|
||||||
|
@ -19,6 +35,10 @@ module ProjectHoneypot
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_engine?
|
||||||
|
@offenses.include?(:search_engine)
|
||||||
|
end
|
||||||
|
|
||||||
def comment_spammer?
|
def comment_spammer?
|
||||||
@offenses.include?(:comment_spammer)
|
@offenses.include?(:comment_spammer)
|
||||||
end
|
end
|
||||||
|
@ -40,11 +60,22 @@ module ProjectHoneypot
|
||||||
@offenses = []
|
@offenses = []
|
||||||
else
|
else
|
||||||
hp_array = honeypot_response.split(".")
|
hp_array = honeypot_response.split(".")
|
||||||
|
|
||||||
|
if hp_array[3].to_i == 0
|
||||||
|
# search engine
|
||||||
|
@last_activity = nil
|
||||||
|
@score = 0
|
||||||
|
@offenses = [:search_engine]
|
||||||
|
@search_engine = (hp_array[2].to_i < SEARCH_ENGINES.length ?
|
||||||
|
SEARCH_ENGINES[hp_array[2].to_i] :
|
||||||
|
SEARCH_ENGINES[0])
|
||||||
|
else
|
||||||
@last_activity = hp_array[1].to_i
|
@last_activity = hp_array[1].to_i
|
||||||
@score = hp_array[2].to_i
|
@score = hp_array[2].to_i
|
||||||
@offenses = set_offenses(hp_array[3])
|
@offenses = set_offenses(hp_array[3])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_offenses(offense_code)
|
def set_offenses(offense_code)
|
||||||
offense_code = offense_code.to_i
|
offense_code = offense_code.to_i
|
||||||
|
|
Loading…
Reference in New Issue