mirror of
https://github.com/jackullrich/ShellcodeStdio
synced 2026-06-08 14:56:00 +00:00
Added support for x64 and some code cleanup.
This commit is contained in:
+20
-12
@@ -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()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
/* Original: ShellcodeStdio -> @ winternl.com (Jack Ullrich)*/
|
||||
/* Much credit to the reddit user: good_nickname */
|
||||
|
||||
#include <Windows.h>
|
||||
#include <winnt.h>
|
||||
#include <winternl.h>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{FACF8E26-40F6-416F-B103-3FCB714FA6BB}</ProjectGuid>
|
||||
<RootNamespace>ShellcodeStdio</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -72,6 +72,9 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -106,10 +109,15 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ScStdio.h"
|
||||
|
||||
int main(void) {
|
||||
|
||||
ScStdio::MalCode();
|
||||
ScStdio::WriteShellcodeToDisk();
|
||||
ScStdio::MalCode();
|
||||
ScStdio::WriteShellcodeToDisk();
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user