From 6d71cf2ba6d9caf0123c6154f3b82245dbb2bcea Mon Sep 17 00:00:00 2001 From: gabrieljablonski Date: Thu, 19 Sep 2024 15:08:24 -0300 Subject: [PATCH] handle BLEXBot (WebMeUp) --- README.md | 1 + lib/legitbot.rb | 1 + lib/legitbot/blexbot.rb | 10 +++++++ test/blexbot_test.rb | 60 +++++++++++++++++++++++++++++++++++++ test/lib/dns_server_mock.rb | 8 +++++ 5 files changed, 80 insertions(+) create mode 100644 lib/legitbot/blexbot.rb create mode 100644 test/blexbot_test.rb diff --git a/README.md b/README.md index 5ce400e..0f02fc7 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ end - [Applebot](https://support.apple.com/en-us/119829) - [Baidu spider](http://help.baidu.com/question?prod_en=master&class=498&id=1000973) - [Bingbot](https://blogs.bing.com/webmaster/2012/08/31/how-to-verify-that-bingbot-is-bingbot/) +- [BLEXBot (WebMeUp)](http://webmeup-crawler.com/) - [DuckDuckGo bot](https://duckduckgo.com/duckduckbot) - [Google crawlers](https://support.google.com/webmasters/answer/1061943) - [IAS](https://integralads.com/ias-privacy-data-management/policies/site-indexing-policy/) diff --git a/lib/legitbot.rb b/lib/legitbot.rb index 957fb02..79756a9 100644 --- a/lib/legitbot.rb +++ b/lib/legitbot.rb @@ -8,6 +8,7 @@ require_relative 'legitbot/apple' require_relative 'legitbot/baidu' require_relative 'legitbot/bing' +require_relative 'legitbot/blexbot' require_relative 'legitbot/duckduckgo' require_relative 'legitbot/facebook' require_relative 'legitbot/google' diff --git a/lib/legitbot/blexbot.rb b/lib/legitbot/blexbot.rb new file mode 100644 index 0000000..158db74 --- /dev/null +++ b/lib/legitbot/blexbot.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Legitbot # :nodoc: + # http://webmeup-crawler.com/ + class BLEXBot < BotMatch + domains 'webmeup.com.' + end + + rule Legitbot::BLEXBot, %w[BLEXBot] +end diff --git a/test/blexbot_test.rb b/test/blexbot_test.rb new file mode 100644 index 0000000..a9a6084 --- /dev/null +++ b/test/blexbot_test.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +require_relative 'test_helper' + +class BLEXBot < Minitest::Test + include Minitest::Hooks + include DnsServerMock + + def test_malicious_ip + ip = '149.210.164.47' + match = Legitbot::BLEXBot.new ip + + refute_predicate match, :valid? + end + + def test_valid_ip + ip = '65.21.113.197' + match = Legitbot::BLEXBot.new ip + + assert_predicate match, :valid? + end + + def test_malicious_ua + bot = Legitbot.bot( + 'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)', + '149.210.164.47' + ) + + assert bot + refute_predicate bot, :valid? + end + + def test_valid_ua + bot = Legitbot.bot( + 'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)', + '65.21.113.197' + ) + + assert bot + assert_predicate bot, :valid? + end + + def test_valid_name + bot = Legitbot.bot( + 'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)', + '65.21.113.197' + ) + + assert_equal :blexbot, bot.detected_as + end + + def test_fake_name + bot = Legitbot.bot( + 'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)', + '81.1.172.108' + ) + + assert_equal :blexbot, bot.detected_as + end +end diff --git a/test/lib/dns_server_mock.rb b/test/lib/dns_server_mock.rb index 99adeca..b847c81 100644 --- a/test/lib/dns_server_mock.rb +++ b/test/lib/dns_server_mock.rb @@ -38,6 +38,14 @@ ptr: %w[17-58-98-60.applebot.apple.com] }, + # BLEXBot (WebMeUp) + 'pot22.webmeup.com' => { + a: %w[65.21.113.197] + }, + '65.21.113.197' => { + ptr: %w[pot22.webmeup.com] + }, + # Google 'crawl-66-249-64-141.googlebot.com' => { a: %w[66.249.64.141]