ARP扫描:命名为:kcan.py
#!/usr/local/bin/python3.7
import os
import re
from scapy.all import *
import threading
iface = 'ens32'
#得到自己的IP
def get_ip_address():
try:
data=os.popen('ifconfig ' + iface).read()
except:
print('Not install net-tools')
words=data.split()
clearOut=[('255', '255', '255', '0')]
for x in words:
result=re.findall('(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})',x)
if result and result != clearOut:
return result[0]
#得到网络号内的IP,24位网络号可实现
def constrcut_net_ip():
my_ip=get_ip_address()
Net_Ip_List=[]
for i in range(1,255):
net_ip = my_ip[0]+'.'+my_ip[1]+'.'+my_ip[2]+'.'+str(i)
Net_Ip_List.append(net_ip)
return Net_Ip_List
#得到自己的MAC
def get_mac_address(iface):
try:
data=os.popen('ifconfig ' + iface).read()
except: