Skip to content

Commit

Permalink
(WIP #39) ARPspoof test file, forgot it haha.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4n3dw0lf committed Nov 27, 2018
1 parent 5ada971 commit 55429aa
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pythem/tests/test_arpspoof_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
logging.getLogger("scapy.loading").setLevel(logging.ERROR)
import unittest
from netaddr import IPAddress
from scapy.all import *
from threading import Thread
from time import sleep

class TestMacTarget(Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, verbose=None):
super(TestMacTarget,self).__init__(group=group,name=name,verbose=verbose)
self.args = args
self.kwargs = kwargs
return
def test_sniffer_callback(self, p):
if p.haslayer(ARP):
if p[ARP].op == 1:
socket = conf.L2socket(iface='lo')
socket.send(Ether(src='aa:bb:cc:dd:ee:ff', dst='ff:ff:ff:ff:ff:ff') / ARP(op="is-at", pdst='127.0.0.1',
psrc='127.0.0.1',hwdst="ff:ff:ff:ff:ff:ff",hwsrc='aa:bb:cc:dd:ee:ff'))
if p[ARP].op == 2 and p[ARP].hwsrc == 'ff:ee:dd:cc:bb:aa':
p.show()
exit(0)
def run(self):
p = sniff(iface='lo', prn=self.test_sniffer_callback)

class TestModulesObjectsCreation(unittest.TestCase):
def test_arpspoof(self):
from pythem.modules.utils import get_myip, get_mymac
myip = get_myip('lo')
mymac = get_mymac('lo')
from pythem.modules.arpoisoner import ARPspoof
arpspoof = ARPspoof()
test_get_range = arpspoof.get_range('127.0.0.0/30')
assert IPAddress('127.0.0.1') in test_get_range
resolve_mac = TestMacTarget()
resolve_mac.start()
arpspoof.gateway = '127.0.0.10'
arpspoof.interface = 'lo'
arpspoof.myip = myip
arpspoof.mymac = mymac
sleep(1)
test_resolve_mac = arpspoof.resolve_mac('127.0.0.1')
assert test_resolve_mac == "aa:bb:cc:dd:ee:ff"
arpspoof.start('10.0.0.1', None, 'lo', '10.0.0.10', 'ff:ee:dd:cc:bb:aa')
resolve_mac.join()

if __name__ == "__main__":
unittest.main()

0 comments on commit 55429aa

Please sign in to comment.