mirror of
https://github.com/beefproject/beef
synced 2026-06-08 13:15:56 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user