-
Notifications
You must be signed in to change notification settings - Fork 21
/
py3_nmap_autoscan.py
executable file
·83 lines (69 loc) · 2.59 KB
/
py3_nmap_autoscan.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
#!/usr/bin/python3
# EmreOvunc
from os import system
from socket import inet_aton
from datetime import datetime as dt
ipList = open('ipList.txt', 'r')
try:
system('rm script_logs.txt 2>/dev/null')
except:
pass
system('touch script_logs.txt')
logger = open('script_logs.txt', 'w')
IPs = ipList.readlines()
flag = 1
forbiddenIP = ['1.1.1.1', '10.0.0.0/24']
for IP in IPs:
scanIP = IP.strip()
try:
network = scanIP.split('/')[0]
subnet = scanIP.split('/')[1]
except:
pass
try:
inet_aton(network)
except:
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
err1 ='[-]' + str(time) + '|' + str(scanIP) + ' taranamıyor !'
logger.write(str(err1) + '\n')
flag = 0
if flag != 0:
for ip in forbiddenIP:
if len(ip.split('/')) > 1:
nw = ip.split('.')[0] + "." + ip.split('.')[1] + "." + ip.split('.')[2] + "."
for lastpart in range(0, 256):
checkip = nw + str(lastpart)
if len(scanIP.split('/')) > 1:
if ip == scanIP:
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
err2 = '[!]' + str(time) + '|' + str(scanIP) + ' yasaklı ! [' + ip + ']'
logger.write(str(err2) + '\n')
flag = 0
break
else:
if checkip == scanIP:
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
err3 = '[!]' + str(time) + '|' + str(scanIP) + ' yasaklı ! [' + ip + ']'
logger.write(str(err3) + '\n')
flag = 0
break
else:
if ip == scanIP:
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
err4 = '[!]' + str(time) + '|' + str(scanIP) + ' yasaklı ! [' + ip + ']'
logger.write(str(err4) + '\n')
flag = 0
break
if flag == 0:
pass
else:
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
status1 = '[?]' + str(time) + ' | ' + str(scanIP) + ' tarama başlatıldı !'
logger.write(str(status1) + '\n')
system('nmap -sV ' + str(scanIP) + ' --open')
time = dt.now().strftime('%Y-%m-%d %H:%M:%S')
status2 = '[+]' + str(time) + '|' + str(scanIP) + ' tarama bitti !'
logger.write(str(status2) + '\n')
flag = 1
ipList.close()
logger.close()