Refactor proxy_type assignment to use case/when expression

Replaces two sequential if assignments with a single case/when for
clarity and adds a defensive else branch that logs and skips unexpected
proxy_type values.
This commit is contained in:
sethumadh
2026-05-30 10:17:14 +10:00
parent f2b5af38c3
commit dc78f29693
@@ -19,8 +19,13 @@ class Get_proxy_servers_wpad < BeEF::Core::Command
proxy_type = Regexp.last_match(1).to_s
ip = Regexp.last_match(2).to_s.split(':')[0]
port = Regexp.last_match(2).to_s.split(':')[1]
proto = 'HTTP' if proxy_type =~ /PROXY/
proto = 'SOCKS' if proxy_type =~ /SOCKS/
proto = case proxy_type
when /PROXY/ then 'HTTP'
when /SOCKS/ then 'SOCKS'
else
print_debug("Unexpected proxy_type from WPAD response: #{proxy_type.inspect}")
next
end
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found #{proto} proxy [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto.downcase, ip: ip, port: port, ntype: "#{proto} Proxy")