Ban an IP manually? #1
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
Hello Herman! While we don't have that feature at the moment, that's a pretty easy thing to add to Phx2Ban. I'll add it to our roadmap and let you know when it is released :). |
Beta Was this translation helpful? Give feedback.
-
Hi, I added it to my site this morning, but it crashed immediately the first time someone tried to abuse my contact form. |
Beta Was this translation helpful? Give feedback.
-
And it works now, and apparently solves another issue I had noticed just now on another project. [error] GenServer Phx2Ban.Rules.KnownMaliciousIp terminating
** (FunctionClauseError) no function clause matching in Phx2Ban.Rules.KnownMaliciousIp.check_request/2
(phx_2_ban 0.2.0) lib/phx_2_ban/rules/known_malicious_ip.ex:67: Phx2Ban.Rules.KnownMaliciousIp.check_request({0, 0, 0, 0, 0, 65535, 32512, 1}, {:cuckoo_filter, #Reference<0.632981430.155582470.134068>, {:spinlock, #Reference<0.632981430.155582470.134068>, 1000000}, 32768, 2147483647, 4, 16, 100, #Function<0.131942963/1 in Phx2Ban.Rules.KnownMaliciousIp.hash>})
(phx_2_ban 0.2.0) lib/phx_2_ban/rules/known_malicious_ip.ex:54: Phx2Ban.Rules.KnownMaliciousIp.handle_call/3
(stdlib 6.1) gen_server.erl:2381: :gen_server.try_handle_call/4
(stdlib 6.1) gen_server.erl:2410: :gen_server.handle_msg/6
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.350.0>): {:valid_request?, {0, 0, 0, 0, 0, 65535, 32512, 1}}
State: {:cuckoo_filter, #Reference<0.632981430.155582470.134068>, {:spinlock, #Reference<0.632981430.155582470.134068>, 1000000}, 32768, 2147483647, 4, 16, 100, #Function<0.131942963/1 in Phx2Ban.Rules.KnownMaliciousIp.hash>}
Client #PID<0.350.0> is alive
(stdlib 6.1) gen.erl:260: :gen.do_call/4
(elixir 1.17.3) lib/gen_server.ex:1125: GenServer.call/3
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:134: anonymous fn/2 in Phx2Ban.Analyzer.maybe_blocklist_ip/2
(elixir 1.17.3) lib/enum.ex:4343: Enum.find_value_list/3
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:91: Phx2Ban.Analyzer.handle_conn_data/2
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:61: Phx2Ban.Analyzer.handle_cast/2
(stdlib 6.1) gen_server.erl:2371: :gen_server.try_handle_cast/3
(stdlib 6.1) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
[error] GenServer #PID<0.350.0> terminating
** (stop) exited in: GenServer.call(Phx2Ban.Rules.KnownMaliciousIp, {:valid_request?, {0, 0, 0, 0, 0, 65535, 32512, 1}}, 5000)
** (EXIT) an exception was raised:
** (FunctionClauseError) no function clause matching in Phx2Ban.Rules.KnownMaliciousIp.check_request/2
(phx_2_ban 0.2.0) lib/phx_2_ban/rules/known_malicious_ip.ex:67: Phx2Ban.Rules.KnownMaliciousIp.check_request({0, 0, 0, 0, 0, 65535, 32512, 1}, {:cuckoo_filter, #Reference<0.632981430.155582470.134068>, {:spinlock, #Reference<0.632981430.155582470.134068>, 1000000}, 32768, 2147483647, 4, 16, 100, #Function<0.131942963/1 in Phx2Ban.Rules.KnownMaliciousIp.hash>})
(phx_2_ban 0.2.0) lib/phx_2_ban/rules/known_malicious_ip.ex:54: Phx2Ban.Rules.KnownMaliciousIp.handle_call/3
(stdlib 6.1) gen_server.erl:2381: :gen_server.try_handle_call/4
(stdlib 6.1) gen_server.erl:2410: :gen_server.handle_msg/6
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
(elixir 1.17.3) lib/gen_server.ex:1128: GenServer.call/3
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:134: anonymous fn/2 in Phx2Ban.Analyzer.maybe_blocklist_ip/2
(elixir 1.17.3) lib/enum.ex:4343: Enum.find_value_list/3
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:91: Phx2Ban.Analyzer.handle_conn_data/2
(phx_2_ban 0.2.0) lib/phx_2_ban/analyzer.ex:61: Phx2Ban.Analyzer.handle_cast/2
(stdlib 6.1) gen_server.erl:2371: :gen_server.try_handle_cast/3
(stdlib 6.1) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", {:analyze_request, %Phx2Ban.ConnData{remote_ip: {0, 0, 0, 0, 0, 65535, 32512, 1}, method: "GET", request_path: "/phoenix/live_reload/frame", req_headers: [{"x-forwarded-proto", "https"}, {"x-forwarded-host", "faulty-tower.test"}, {"x-forwarded-for", "::1"}, {"upgrade-insecure-requests", "1"}, {"te", "trailers"}, {"sec-gpc", "1"}, {"sec-fetch-s
ite", "same-origin"}, {"sec-fetch-mode", "navigate"}, {"sec-fetch-dest", "iframe"}, {"referer", "https://faulty-tower.test/"}, {"priority", "u=4"}, {"dnt", "1"}, {"cookie", "_faulty_tower_key=SFMyNTY.g3QAAAADbQAAAAtfY3NyZl90b2tlbm0AAAAYWWUwelVSMVpzQXJfTW9rQ1pMc3ZScUZabQAAAA5saXZlX3NvY2tldF9pZG0AAAA7dXNlcnNfc2Vzc2lvbnM6TkI2cHJFdVdnWGluWnFOX0dHdTR3UkxPaU5UYVA5Q1NDMzllTmRobk
pjND1tAAAACnVzZXJfdG9rZW5tAAAAIDQeqaxLloF4p2ajfxhruMESzojU2j_Qkgt_XjXYZyXO.w4edQ-vrIxHW9ZzTBt6enM-tAyxrWssfSXadi-TurAA"}, {"accept-language", "nl-BE,nl;q=0.8,en-US;q=0.6,en;q=0.4,fr-BE;q=0.2"}, {"accept-encoding", "gzip, deflate, br, zstd"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}, {"user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS
X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"}, {"host", "faulty-tower.test"}], status: nil, host: "faulty-tower.test", req_route_exists?: false}}}
State: %{allow_list: MapSet.new(["127.0.0.1"]), ignore_routes: [], all_rules: [Phx2Ban.Rules.Linux, Phx2Ban.Rules.PHP, Phx2Ban.Rules.Drupal, Phx2Ban.Rules.Wordpress, Phx2Ban.Rules.Python, Phx2Ban.Rules.Windows, Phx2Ban.Rules.KnownMaliciousIp], inspect_percentage: 100, routers: [FaultyTowerWeb.Router]} |
Beta Was this translation helpful? Give feedback.
@Hermanverschooten I just released
v0.2.1
which should fix this. could you please bump the version and try again? Thank you for your patience!