Skip to content

Commit 2337810

Browse files
committed
Linux bug fixes
1 parent 2cc102f commit 2337810

File tree

10 files changed

+16
-17
lines changed

10 files changed

+16
-17
lines changed

Keystone/libkeystone_x64.a

4.79 MB
Binary file not shown.

Keystone/libkeystone_x86.a

3.9 MB
Binary file not shown.

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,12 @@ This is an Alpha version. Please report any bugs or suggestions.
5151
1. Initial support for Windows x64
5252
2. Initial support for Linux (x86 and x64) shellcodes
5353

54-
# Keystone compilation
54+
# Keystone
5555

5656
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)
6360

6461
# Author
6562

Release/ShellcodeCompiler_x64.exe

0 Bytes
Binary file not shown.

Release/ShellcodeCompiler_x86.exe

0 Bytes
Binary file not shown.

ShellcodeCompiler/ASMHeader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ string ASMHeader::GetASMHeader_x86()
3838
"inc ecx ; Increment the ordinal \r\n"
3939
"lodsd ; Get name offset \r\n"
4040
"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"
4242
"jnz Get_Function \r\n"
43-
"cmp dword ptr [eax + 0x4], 0x41636f72 ; rocA \r\n"
43+
"cmp dword [eax + 0x4], 0x41636f72 ; rocA \r\n"
4444
"jnz Get_Function \r\n"
45-
"cmp dword ptr [eax + 0x8], 0x65726464 ; ddre \r\n"
45+
"cmp dword [eax + 0x8], 0x65726464 ; ddre \r\n"
4646
"jnz Get_Function \r\n"
4747
"mov esi, [edx + 0x24] ; ESI = Offset ordinals \r\n"
4848
"add esi, ebx ; ESI = Ordinals table \r\n"

ShellcodeCompiler/CommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void CommandLine::PrintHelp(string p_sFile)
6565
cout << "\tkill(1661, 9);" << endl;
6666
cout << "\tgetpid();" << endl;
6767
cout << "\texecve(\"/usr/bin/burpsuite\", 0, 0);" << endl;
68-
cout << "\texit(2" << endl << endl;
68+
cout << "\texit(2);" << endl << endl;
6969

7070
cout << "Invocation example" << endl;
7171
cout << "------------------" << endl << endl;

ShellcodeCompiler/DeclaredFunctions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ string DeclaredFunctions::GenerateLoadLibraryCall_x86(string p_sDLLName)
7777
sContent += Utils::CharToHexString(p_sDLLName[Len - 3]);
7878
sContent += "\r\n";
7979
sContent += "push eax\r\n";
80-
sContent += "sub dword ptr [esp + 3], 0x23\r\n";
80+
sContent += "sub dword [esp + 3], 0x23\r\n";
8181
}
8282
else cout << "Imaginary number?" << endl;
8383

@@ -157,7 +157,7 @@ string DeclaredFunctions::GenerateLoadLibraryCall_x64(string p_sDLLName)
157157
sContent += Utils::CharToHexString(p_sDLLName[Len - 3]);
158158
sContent += "\r\n";
159159
sContent += "push rax\r\n";
160-
sContent += "sub dword ptr [rsp + 7], 0x23\r\n";
160+
sContent += "sub dword [rsp + 7], 0x23\r\n";
161161
}
162162
else if (Len % 8 == 4)
163163
{
@@ -303,7 +303,7 @@ string DeclaredFunctions::GenerateGetProcAddressCall_x86(string p_sDLLName, stri
303303
sContent += Utils::CharToHexString(p_sFunctionName[Len - 3]);
304304
sContent += "\r\n";
305305
sContent += "push eax\r\n";
306-
sContent += "sub dword ptr [esp + 3], 0x23\r\n";
306+
sContent += "sub dword [esp + 3], 0x23\r\n";
307307
}
308308
else cout << "Imaginary number?" << endl;
309309

@@ -323,7 +323,7 @@ string DeclaredFunctions::GenerateGetProcAddressCall_x86(string p_sDLLName, stri
323323
// DLL base address
324324

325325
sContent += "push esp ; String on the stack \r\n";
326-
sContent += "push dword ptr [esp + ";
326+
sContent += "push dword [esp + ";
327327
sContent += to_string((NrFunctionsToStack * 4) + ((NrBasesToStack + 3 - DLLBaseAddress::GetDLLBase(p_sDLLName)) * 4) + ((Times + 2) * 4));
328328
sContent += "] \r\n";
329329

ShellcodeCompiler/FunctionCalls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ string FunctionCalls::GeneratePutStringToStack_x86(string p_sString)
9292
sContent += Utils::CharToHexString(p_sString[Len - 3]);
9393
sContent += "\r\n";
9494
sContent += "push eax\r\n";
95-
sContent += "sub dword ptr [esp + 3], 0x23\r\n";
95+
sContent += "sub dword [esp + 3], 0x23\r\n";
9696
}
9797
else cout << "Imaginary number?" << endl;
9898

@@ -265,7 +265,7 @@ string FunctionCalls::GenerateFunctionCall_x86(FunctionCalls::FunctionCall p_oFu
265265
{
266266
if (p_oFunctionCall.Parameters[i].Type == FunctionCalls::PARAMETER_TYPE_STRING)
267267
{
268-
sContent += "push dword ptr [ESP + ";
268+
sContent += "push dword [ESP + ";
269269
sContent += to_string(((CurrentParamNr - 1) * 4) + ((StringOffsetAddress::CurrentStringOffset - StringOffsetAddress::GetStringOffset(p_oFunctionCall.Parameters[i].StringValue)) * 4));
270270
sContent += "]\r\n";
271271
}

ShellcodeCompiler/KeystoneLib.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ unsigned char* KeystoneLib::Assemble(size_t *p_pSize, string p_sASM)
2424

2525
// Assemble the code
2626

27+
ks_option(ks, KS_OPT_SYNTAX, KS_OPT_SYNTAX_NASM);
28+
2729
if (ks_asm(ks, p_sASM.c_str(), 0, &encode, &size, &count)) {
2830
cout << "ERROR: Failed on ks_asm() with count = " << count << ", error code = " << ks_errno(ks) << endl;
2931
return NULL;

0 commit comments

Comments
 (0)