Class: BetterCap::Proxy::TCP::Proxy
- Inherits:
-
Object
- Object
- BetterCap::Proxy::TCP::Proxy
- Defined in:
- lib/bettercap/proxy/tcp/proxy.rb
Overview
Transparent TCP proxy class.
Instance Method Summary collapse
-
#initialize(address, port, up_address, up_port) ⇒ Proxy
constructor
Initialize the TCP proxy with given arguments.
-
#start ⇒ Object
Start the proxy.
-
#stop ⇒ Object
Stop the proxy.
Constructor Details
#initialize(address, port, up_address, up_port) ⇒ Proxy
Initialize the TCP proxy with given arguments.
38 39 40 41 42 43 44 45 |
# File 'lib/bettercap/proxy/tcp/proxy.rb', line 38 def initialize( address, port, up_address, up_port ) @address = address @port = port @upstream_address = up_address @upstream_port = up_port @ctx = BetterCap::Context.get @worker = nil end |
Instance Method Details
#start ⇒ Object
Start the proxy.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/bettercap/proxy/tcp/proxy.rb', line 48 def start Logger.info "[#{'TCP PROXY'.green}] Starting on #{@address}:#{@port} ( -> #{@upstream_address}:#{@upstream_port} ) ..." @worker = Thread.new &method(:worker) # If the upstream server is in this network, we need to make sure that its MAC # address is discovered and put in the ARP cache before we even start the proxy, # otherwise internal connections won't be spoofed and the proxy will be useless # until some random event will fill the ARP cache for the server. if @ctx.ifconfig[:ip4_obj].include?( @upstream_address ) Logger.debug "[#{'TCP PROXY'.green}] Sending probe to upstream server address ..." BetterCap::Network.get_hw_address( @ctx, @upstream_address ) # wait for the system to acknowledge the ARP cache changes. sleep( 1 ) end end |