-
Notifications
You must be signed in to change notification settings - Fork 66
/
SmbtouchScanner.py
60 lines (50 loc) · 1.5 KB
/
SmbtouchScanner.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
#
# Smbtouch Scanner
# By: 3gstudent
# License: BSD 3-Clause
'''
Automatically scan the inner network.
Use Smbtouch.exe to detect whether the target is vulnerable.
Protocol: SMB
Scan port:445
Note:
You can also use protocl NBT and port 139,just change the Smbtouch-1.1.1.xml
You can get Smbtouch.exe from this:
https://github.com/x0rz/EQGRP_Lost_in_Translation/blob/master/windows/touches/Smbtouch-1.1.1.exe
'''
import os
import fileinput
#Start IP,change it
BeginIP = '192.168.1.1'
#End IP,change it
EndIP = '192.168.1.10'
#Log file
fp = open('log.txt', 'w+')
OldIP = ' <value>127.0.0.1</value>'
TempIP = OldIP
IP1 = BeginIP.split('.')[0]
IP2 = BeginIP.split('.')[1]
IP3 = BeginIP.split('.')[2]
IP4 = BeginIP.split('.')[-1]
EndIP_last = EndIP.split('.')[-1]
for i in range(int(IP4)-1,int(EndIP_last)):
ip = str(IP1+'.'+IP2+'.'+IP3+'.'+IP4)
int_IP4 = int(IP4)
int_IP4 += 1
IP4 = str(int_IP4)
NewIP= ' <value>'+ip+'</value>'
for line in fileinput.input('Smbtouch-1.1.1.xml',inplace=1):
print line.rstrip().replace(TempIP,NewIP)
TempIP = NewIP
Output = os.popen(r"Smbtouch-1.1.1.exe").read()
Output = Output[0:Output.find('<config',1)]
fp.writelines(Output)
Flag = Output.find('[-] Touch failed')
if Flag == -1 :
print '[+] Touch success: ' +ip
else:
print '[-] Touch failed: ' +ip
else:
fp.close( )
for line in fileinput.input('Smbtouch-1.1.1.xml',inplace=1):
print line.rstrip().replace(NewIP,OldIP)