| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,15 +51,12 @@ This is an Alpha version. Please report any bugs or suggestions. | |||
| 51 | 51 | 1. Initial support for Windows x64 | |
| 52 | 52 | 2. Initial support for Linux (x86 and x64) shellcodes | |
| 53 | 53 | ||
| 54 | - # Keystone compilation | ||
| 54 | + # Keystone | ||
| 55 | 55 | ||
| 56 | 56 | 1. Download Keystone Engine source code | |
| 57 | - 2. Download, install and put in PATH cmake and python | ||
| 58 | - 3. Open Visual Studio 2019 - x86 (for 32 bits) and x64 (for 64 bits) "Native Tools Command Prompts" and go to Keystone source directory | ||
| 59 | - 4. Edit nmake-lib.bat file and replace -DLLVM_TARGETS_TO_BUILD="all" with -DLLVM_TARGETS_TO_BUILD="X86" | ||
| 60 | - 5. Run mkdir build and cd build commands | ||
| 61 | - 6. Run ..\nmake-lib.bat command | ||
| 62 | - 7. Copy the resulted lib file from keystone-src\build\llvm\lib\keystone.lib to ShellcodeCompiler\Keystone\keystone_x86.lib (for 32 bits) and keystone_x64.lib (for 64 bits) | ||
| 57 | + 2. Compile Keystone Engine as static library using nmake-lib.sh (for Linux) and nmake-lib.bat (for Windows) | ||
| 58 | + 3. Windows: Copy the resulted lib file from keystone-src\build\llvm\lib\keystone.lib to ShellcodeCompiler\Keystone\keystone_x86.lib (for 32 bits) and keystone_x64.lib (for 64 bits) | ||
| 59 | + 4. Linux: Copy the resulted lib file from keystone-src\build\llvm\lib\keystone.lib to ShellcodeCompiler\Keystone\libkeystone_x86.a (for 32 bits) and libkeystone_x64.a (for 64 bits) | ||
| 63 | 60 | ||
| 64 | 61 | # Author | |
| 65 | 62 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,11 +38,11 @@ string ASMHeader::GetASMHeader_x86() | |||
| 38 | 38 | "inc ecx ; Increment the ordinal \r\n" | |
| 39 | 39 | "lodsd ; Get name offset \r\n" | |
| 40 | 40 | "add eax, ebx ; Get function name \r\n" | |
| 41 | - "cmp dword ptr [eax], 0x50746547 ; GetP \r\n" | ||
| 41 | + "cmp dword [eax], 0x50746547 ; GetP \r\n" | ||
| 42 | 42 | "jnz Get_Function \r\n" | |
| 43 | - "cmp dword ptr [eax + 0x4], 0x41636f72 ; rocA \r\n" | ||
| 43 | + "cmp dword [eax + 0x4], 0x41636f72 ; rocA \r\n" | ||
| 44 | 44 | "jnz Get_Function \r\n" | |
| 45 | - "cmp dword ptr [eax + 0x8], 0x65726464 ; ddre \r\n" | ||
| 45 | + "cmp dword [eax + 0x8], 0x65726464 ; ddre \r\n" | ||
| 46 | 46 | "jnz Get_Function \r\n" | |
| 47 | 47 | "mov esi, [edx + 0x24] ; ESI = Offset ordinals \r\n" | |
| 48 | 48 | "add esi, ebx ; ESI = Ordinals table \r\n" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ void CommandLine::PrintHelp(string p_sFile) | |||
| 65 | 65 | cout << "\tkill(1661, 9);" << endl; | |
| 66 | 66 | cout << "\tgetpid();" << endl; | |
| 67 | 67 | cout << "\texecve(\"/usr/bin/burpsuite\", 0, 0);" << endl; | |
| 68 | - cout << "\texit(2" << endl << endl; | ||
| 68 | + cout << "\texit(2);" << endl << endl; | ||
| 69 | 69 | ||
| 70 | 70 | cout << "Invocation example" << endl; | |
| 71 | 71 | cout << "------------------" << endl << endl; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,7 +77,7 @@ string DeclaredFunctions::GenerateLoadLibraryCall_x86(string p_sDLLName) | |||
| 77 | 77 | sContent += Utils::CharToHexString(p_sDLLName[Len - 3]); | |
| 78 | 78 | sContent += "\r\n"; | |
| 79 | 79 | sContent += "push eax\r\n"; | |
| 80 | - sContent += "sub dword ptr [esp + 3], 0x23\r\n"; | ||
| 80 | + sContent += "sub dword [esp + 3], 0x23\r\n"; | ||
| 81 | 81 | } | |
| 82 | 82 | else cout << "Imaginary number?" << endl; | |
| 83 | 83 | ||
@@ -157,7 +157,7 @@ string DeclaredFunctions::GenerateLoadLibraryCall_x64(string p_sDLLName) | |||
| 157 | 157 | sContent += Utils::CharToHexString(p_sDLLName[Len - 3]); | |
| 158 | 158 | sContent += "\r\n"; | |
| 159 | 159 | sContent += "push rax\r\n"; | |
| 160 | - sContent += "sub dword ptr [rsp + 7], 0x23\r\n"; | ||
| 160 | + sContent += "sub dword [rsp + 7], 0x23\r\n"; | ||
| 161 | 161 | } | |
| 162 | 162 | else if (Len % 8 == 4) | |
| 163 | 163 | { | |
@@ -303,7 +303,7 @@ string DeclaredFunctions::GenerateGetProcAddressCall_x86(string p_sDLLName, stri | |||
| 303 | 303 | sContent += Utils::CharToHexString(p_sFunctionName[Len - 3]); | |
| 304 | 304 | sContent += "\r\n"; | |
| 305 | 305 | sContent += "push eax\r\n"; | |
| 306 | - sContent += "sub dword ptr [esp + 3], 0x23\r\n"; | ||
| 306 | + sContent += "sub dword [esp + 3], 0x23\r\n"; | ||
| 307 | 307 | } | |
| 308 | 308 | else cout << "Imaginary number?" << endl; | |
| 309 | 309 | ||
@@ -323,7 +323,7 @@ string DeclaredFunctions::GenerateGetProcAddressCall_x86(string p_sDLLName, stri | |||
| 323 | 323 | // DLL base address | |
| 324 | 324 | ||
| 325 | 325 | sContent += "push esp ; String on the stack \r\n"; | |
| 326 | - sContent += "push dword ptr [esp + "; | ||
| 326 | + sContent += "push dword [esp + "; | ||
| 327 | 327 | sContent += to_string((NrFunctionsToStack * 4) + ((NrBasesToStack + 3 - DLLBaseAddress::GetDLLBase(p_sDLLName)) * 4) + ((Times + 2) * 4)); | |
| 328 | 328 | sContent += "] \r\n"; | |
| 329 | 329 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,7 @@ string FunctionCalls::GeneratePutStringToStack_x86(string p_sString) | |||
| 92 | 92 | sContent += Utils::CharToHexString(p_sString[Len - 3]); | |
| 93 | 93 | sContent += "\r\n"; | |
| 94 | 94 | sContent += "push eax\r\n"; | |
| 95 | - sContent += "sub dword ptr [esp + 3], 0x23\r\n"; | ||
| 95 | + sContent += "sub dword [esp + 3], 0x23\r\n"; | ||
| 96 | 96 | } | |
| 97 | 97 | else cout << "Imaginary number?" << endl; | |
| 98 | 98 | ||
@@ -265,7 +265,7 @@ string FunctionCalls::GenerateFunctionCall_x86(FunctionCalls::FunctionCall p_oFu | |||
| 265 | 265 | { | |
| 266 | 266 | if (p_oFunctionCall.Parameters[i].Type == FunctionCalls::PARAMETER_TYPE_STRING) | |
| 267 | 267 | { | |
| 268 | - sContent += "push dword ptr [ESP + "; | ||
| 268 | + sContent += "push dword [ESP + "; | ||
| 269 | 269 | sContent += to_string(((CurrentParamNr - 1) * 4) + ((StringOffsetAddress::CurrentStringOffset - StringOffsetAddress::GetStringOffset(p_oFunctionCall.Parameters[i].StringValue)) * 4)); | |
| 270 | 270 | sContent += "]\r\n"; | |
| 271 | 271 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,8 @@ unsigned char* KeystoneLib::Assemble(size_t *p_pSize, string p_sASM) | |||
| 24 | 24 | ||
| 25 | 25 | // Assemble the code | |
| 26 | 26 | ||
| 27 | + ks_option(ks, KS_OPT_SYNTAX, KS_OPT_SYNTAX_NASM); | ||
| 28 | + | ||
| 27 | 29 | if (ks_asm(ks, p_sASM.c_str(), 0, &encode, &size, &count)) { | |
| 28 | 30 | cout << "ERROR: Failed on ks_asm() with count = " << count << ", error code = " << ks_errno(ks) << endl; | |
| 29 | 31 | return NULL; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments