diff --git a/ShellcodeStdio/ScStdio.cpp b/ShellcodeStdio/ScStdio.cpp index 7875f7e..85e8a00 100644 --- a/ShellcodeStdio/ScStdio.cpp +++ b/ShellcodeStdio/ScStdio.cpp @@ -1,28 +1,32 @@ #include "ScStdio.h" +#define ROR_SHIFT 13 + namespace ScStdio { + /* - Suggested VS Compilation Switches: + VS Compilation Switches: C/C++ -> Optimization -> /O1, /Ob2, /Oi, /Os, /Oy-, /GL C/C++ -> Code Generation -> /MT, /GS-, /Gy Linker -> General -> /INCREMENTAL:NO */ +#ifndef _WIN64 __declspec(naked) void MalCodeBegin() { __asm { jmp MalCode } }; +#else + void MalCodeBegin() { MalCode(); } +#endif -#define htons(A) ((((WORD)(A) & 0xff00) >> 8) | (((WORD)(A) & 0x00ff) << 8)) - - __forceinline PEB *get_peb() { - PEB *p; - __asm { - mov eax, fs:[30h] - mov p, eax - } + PPEB getPEB() { + PPEB p; +#ifndef _WIN64 + p = (PPEB)__readfsdword(0x30); +#else + p = (PPEB)__readgsqword(0x60); +#endif return p; } -#define ROR_SHIFT 13 - constexpr DWORD ct_ror(DWORD n) { return (n >> ROR_SHIFT) | (n << (sizeof(DWORD) * CHAR_BIT - ROR_SHIFT)); } @@ -51,7 +55,7 @@ namespace ScStdio { } PVOID getProcAddrByHash(DWORD hash) { - PEB *peb = get_peb(); + PEB *peb = getPEB(); LIST_ENTRY *first = peb->Ldr->InMemoryOrderModuleList.Flink; LIST_ENTRY *ptr = first; do { @@ -106,7 +110,11 @@ namespace ScStdio { MessageBoxA(NULL, strMboxMsg, strMboxTitle, MB_OK); } +#ifndef _WIN64 __declspec(naked) void MalCodeEnd() { }; +#else + void MalCodeEnd() {}; +#endif BOOL WriteShellcodeToDisk() { diff --git a/ShellcodeStdio/ScStdio.h b/ShellcodeStdio/ScStdio.h index bbf92fb..c977964 100644 --- a/ShellcodeStdio/ScStdio.h +++ b/ShellcodeStdio/ScStdio.h @@ -1,8 +1,5 @@ #pragma once -/* Original: ShellcodeStdio -> @ winternl.com (Jack Ullrich)*/ -/* Much credit to the reddit user: good_nickname */ - #include #include #include diff --git a/ShellcodeStdio/ShellcodeStdio.vcxproj b/ShellcodeStdio/ShellcodeStdio.vcxproj index 8f5da3c..cc8b7de 100644 --- a/ShellcodeStdio/ShellcodeStdio.vcxproj +++ b/ShellcodeStdio/ShellcodeStdio.vcxproj @@ -22,7 +22,7 @@ 15.0 {FACF8E26-40F6-416F-B103-3FCB714FA6BB} ShellcodeStdio - 10.0.15063.0 + 8.1 @@ -72,6 +72,9 @@ false + + false + Level3 @@ -106,10 +109,15 @@ Level3 - MaxSpeed + MinSpace true true true + AnySuitable + Size + false + MultiThreaded + false true diff --git a/ShellcodeStdio/main.cpp b/ShellcodeStdio/main.cpp index 59fae28..1ca1291 100644 --- a/ShellcodeStdio/main.cpp +++ b/ShellcodeStdio/main.cpp @@ -1,7 +1,6 @@ #include "ScStdio.h" int main(void) { - - ScStdio::MalCode(); - ScStdio::WriteShellcodeToDisk(); + ScStdio::MalCode(); + ScStdio::WriteShellcodeToDisk(); } \ No newline at end of file diff --git a/ShellcodeStdio/shellcode.bin b/ShellcodeStdio/shellcode.bin new file mode 100644 index 0000000..79e313c Binary files /dev/null and b/ShellcodeStdio/shellcode.bin differ