-
Notifications
You must be signed in to change notification settings - Fork 4
/
NetworkScanner.py
156 lines (133 loc) · 9 KB
/
NetworkScanner.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import os
from scapy.all import *
import colorama
from colorama import Fore
import subprocess
addresses = []
def scan(ip_range):
arp = ARP(pdst=ip_range)
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
packet = ether/arp
result = srp(packet, timeout=3, verbose=0)[0]
clients = []
for sent, received in result:
clients.append({'ip': received.psrc, 'mac': received.hwsrc})
return clients
def Fullscan(subnet, time, interface, frequency):
counter = 0
mac = 0
new_mac = ("00:11:22:33:44:55")
new_ip = ("192.168.0.0")
os.system("ifconfig " + interface + " down")
os.system("ifconfig " + interface + " hw ether " + new_mac)
os.system("ifconfig " + interface + " " + new_ip)
os.system("ifconfig " + interface + " up")
for i in range(1, 256):
ip_range = (subnet + "." + str(i) + ".1/24")
print(Fore.WHITE + 'Scanning Hosts on '+ Fore.RED + ip_range + Fore.MAGENTA)
counter = counter + 1
mac = mac + 1
if mac >= 100:
mac = 1
if counter >= 256:
counter = 0
if ((counter % frequency) == 0):
new_mac = ("00:11:22:33:44:" + str(mac))
new_ip = ("192.168.0." + str(counter))
os.system("ifconfig " + interface + " down")
os.system("ifconfig " + interface + " hw ether " + new_mac)
os.system("ifconfig " + interface + " " + new_ip)
os.system("ifconfig " + interface + " up")
print('\n Info Changed \n')
send(ARP(op=2, pdst=new_ip, psrc=new_ip, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=new_mac))
os.system("ifconfig " + interface + " promisc")
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_range), iface=interface, timeout=time)
results = []
for sent, received in ans:
results.append({"ip": received.psrc, "mac": received.hwsrc})
addresses.append({"ip": received.psrc, "mac": received.hwsrc})
# Print the results
for host in results:
print(host)
def SpecificScan():
os.system('clear')
baseip = input('Type in the first 7 numbers of the ip. EX 192.168.1 >>> ')
print('Scanning...')
print('')
clients = scan(baseip + '.1/24')
for client in clients:
print(Fore.YELLOW +"IP: " + Fore.MAGENTA + client["ip"] + Fore.WHITE)
print(Fore.YELLOW +"MAC: " + Fore.BLUE + client["mac"] + Fore.WHITE)
print("")
choice = input('Would you like to save these to a file? y/n >>> ')
if(choice == 'y'):
print('Saving to file')
with open("IP_SAVED_DATA.txt", "a") as file:
for client in clients:
file.write("IP: " + client["ip"])
file.write(" MAC: " + client["mac"] + '\n')
file.write("")
print('')
print('Done!')
print('')
input(Fore.RED+"Press Enter to continue...")
os.system('sudo python RAVAGE.py')
if(choice == 'n'):
input(Fore.RED+"Press Enter to continue...")
os.system('sudo python RAVAGE.py')
def FullScan():
os.system('clear')
address = input('Type in the first 6 numbers of the ip. EX 192.168 >>> ')
print('')
timeout = float(input('Type the amount of connection wait time for each host >>> '))
print('')
device = input('Type in the interface that you are using. EX wlan0 >>> ')
print('')
Frequency = int(input('Type in how many packets should be sent till changing your IP and MAC >>> '))
print('')
print('Scanning...')
print('')
Fullscan(subnet = address, time = timeout, interface = device, frequency = Frequency)
choice = input(Fore.WHITE + 'Would you like to save these to a file? y/n >>> ')
if(choice == 'y'):
print('Saving to file')
with open("IP_SAVED_DATA.txt", "a") as file:
for client in addresses:
file.write("IP: " + client["ip"])
file.write(" MAC: " + client["mac"] + '\n')
file.write("")
print('')
print('Done!')
print('')
input(Fore.RED+"Press Enter to continue...")
os.system('sudo python RAVAGE.py')
if(choice == 'n'):
input(Fore.RED+"Press Enter to continue...")
os.system('sudo python RAVAGE.py')
def Start():
os.system('clear')
print(Fore.MAGENTA + '██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████')
print('█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█░░░░░░██████████░░░░░░█░░░░░░██████████░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░███')
print('█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░░░░░░░░░██░░▄▀░░█░░▄▀░░░░░░░░░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀▄▀░░███')
print('█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░██░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░▄▀░░███')
print('█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░████░░▄▀░░███')
print('█░░▄▀░░░░░░░░░░█░░▄▀░░█████████░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░▄▀░░███')
print('█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀▄▀░░███')
print('█░░░░░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░▄▀░░░░███')
print('█████████░░▄▀░░█░░▄▀░░█████████░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░██░░▄▀░░█████')
print('█░░░░░░░░░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░██░░▄▀░░█░░▄▀░░██░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░██░░▄▀░░░░░░█')
print('█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀░░██░░░░░░░░░░▄▀░░█░░▄▀░░██░░░░░░░░░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀▄▀▄▀░░█')
print('█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█░░░░░░██░░░░░░█░░░░░░██████████░░░░░░█░░░░░░██████████░░░░░░█░░░░░░░░░░░░░░█░░░░░░██░░░░░░░░░░█')
print('██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████')
print(Fore.WHITE+'')
#
print(Fore.CYAN + '1) Full Scan 2) Specific Scan')
print('')
selection = int(input(Fore.WHITE + 'What program is being run? >>> '))
#
if selection == 1:
FullScan()
if selection == 2:
SpecificScan()
elif (selection != 1) or (selection != 2):
Start()