klezVirus / inceptor

Template-Driven AV/EDR Evasion Framework
Other
1.58k stars 260 forks source link

LLVM Compiler Error #48

Closed SnazzyBaton368 closed 8 months ago

SnazzyBaton368 commented 11 months ago

Bug Description LLVM Compiler wont work.

To Reproduce

What it looks like

[+] Native Artifact Generator Started At 2023-10-10 14:20:58.232656 [] Phase 0: Loading... [] Phase 1: Converting binary into shellcode [>] Transformer: Pe2sh [] Phase 2: Encoding [] Phase 3: Generating source files using CLASSIC [>] Phase 3.1: Writing CPP file in .\temp\tmp0vyzc7fu.cpp [] Phase 4: EXE compilation and Signing [>] Phase 4.1: Compiling EXE... [-] Error: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\include\utility(229,9): error: expected member name or ';' after declaration specifiers Traceback (most recent call last): File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\compilers\Compiler.py", line 66, in compile output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 421, in check_output return run(popenargs, stdout=PIPE, timeout=timeout, check=True, File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 526, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" x64 & "C:\x\Projects\Program\MALWARE\inceptor\inceptor\obfuscators\native\llvm-clang\llvm-clang\clang-cl.exe" /permissive- /GS /GL /W3 /Gy /Zi /Gm- /O2 /sdl /Zc:inline /Zc:wchar_t /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /EHsc /nologo /diagnostics:column -o "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\main-36-temp.exe" /D CUDACC /D _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -mllvm -bcf -mllvm -bcf_prob=73 -mllvm -bcf_loop=1 -mllvm -sub -mllvm -sub_loop=5 -mllvm -fla -mllvm -split_num=5 -mllvm -aesSeed=4ed3ee74122b15cb57ea400b35317328 -w "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\tmp0vyzc7fu.cpp" /link ' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 248, in generate self.generate_wrapped() File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 291, in generate_wrapped self.compile_exe(shellcode) File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 200, in compile_exe status = self.compiler.compile([self.exe_writer.outfile] + self.obj_files) File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\compilers\Compiler.py", line 73, in compile raise Exception("Compiler Error") Exception: Compiler Error

Debug Info: [+] Native Artifact Generator Started At 2023-10-10 14:21:44.918387 [] Phase 0: Loading... [] Phase 1: Converting binary into shellcode [>] Transformer: Pe2sh [>] Pe2Sh cmd line: "C:\x\Projects\Program\MALWARE\inceptor\inceptor\libs\public\pe2sh.exe" "C:\x\Projects\Program\MALWARE\inceptor\inceptor\tests\main.exe" "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\main.shc.exe" Reading module from: C:\x\Projects\Program\MALWARE\inceptor\inceptor\tests\main.exe [+] Saved as: C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\main.shc.exe

[] Phase 2: Encoding [] Phase 3: Generating source files using CLASSIC [>] Phase 3.1: Writing CPP file in .\temp\tmp1na_byjv.cpp [] Phase 4: EXE compilation and Signing [>] Phase 4.1: Compiling EXE... "C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" x64 & "C:\x\Projects\Program\MALWARE\inceptor\inceptor\obfuscators\native\llvm-clang\llvm-clang\clang-cl.exe" /permissive- /GS /GL /W3 /Gy /Zi /Gm- /O2 /sdl /Zc:inline /Zc:wchar_t /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /EHsc /nologo /diagnostics:column -o "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\main-36-temp.exe" /D CUDACC /D _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -mllvm -bcf -mllvm -bcf_prob=73 -mllvm -bcf_loop=1 -mllvm -sub -mllvm -sub_loop=5 -mllvm -fla -mllvm -split_num=5 -mllvm -aesSeed=83d75223ea0fa0097840d9ecce185f0f -w "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\tmp1na_byjv.cpp" /link [-] Error: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.38.33030\include\utility(229,9): error: expected member name or ';' after declaration specifiers Traceback (most recent call last): File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\compilers\Compiler.py", line 66, in compile output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 421, in check_output return run(popenargs, stdout=PIPE, timeout=timeout, check=True, File "C:\Users\x\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 526, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" x64 & "C:\x\Projects\Program\MALWARE\inceptor\inceptor\obfuscators\native\llvm-clang\llvm-clang\clang-cl.exe" /permissive- /GS /GL /W3 /Gy /Zi /Gm- /O2 /sdl /Zc:inline /Zc:wchar_t /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /EHsc /nologo /diagnostics:column -o "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\main-36-temp.exe" /D CUDACC /D _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH -mllvm -bcf -mllvm -bcf_prob=73 -mllvm -bcf_loop=1 -mllvm -sub -mllvm -sub_loop=5 -mllvm -fla -mllvm -split_num=5 -mllvm -aesSeed=83d75223ea0fa0097840d9ecce185f0f -w "C:\x\Projects\Program\MALWARE\inceptor\inceptor\temp\tmp1na_byjv.cpp" /link ' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 248, in generate self.generate_wrapped() File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 291, in generate_wrapped self.compile_exe(shellcode) File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\generators\NativeArtifactGenerator.py", line 200, in compile_exe status = self.compiler.compile([self.exe_writer.outfile] + self.obj_files) File "C:\x\Projects\Program\MALWARE\inceptor\inceptor\compilers\Compiler.py", line 73, in compile raise Exception("Compiler Error") Exception: Compiler Error

radman404 commented 11 months ago

For me this was due to the MSVC tools version. It works with 14.33.31629. I made a change in my fork that allows you to pick the version (as long as you have the right version installed you can choose it) that is used when using LLVM. I can pull it here if @klezVirus would like.

adrian-rt commented 10 months ago

@radman404 are you going to submit a pull request?

Did you have to specify any include paths with -I ? It seems I have to and I get some weird errord due to MSVC tools version.

radman404 commented 10 months ago

@radman404 are you going to submit a pull request?

Did you have to specify any include paths with -I ? It seems I have to and I get some weird errord due to MSVC tools version.

@adrian-rt I did check the pull requests.

klezVirus commented 10 months ago

@adrian-rt @radman404 If you're happy with that I'm gonna merge this