Skip to content

Commit

Permalink
Installation.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasxm committed Jul 12, 2024
1 parent a31cc70 commit b4c7b67
Show file tree
Hide file tree
Showing 42 changed files with 1,307 additions and 16 deletions.
34 changes: 29 additions & 5 deletions Boaz.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,22 @@ def run_obfuscation(loader_path):

def compile_output(loader_path, output_name, compiler, sleep_flag, anti_emulation, insert_junk_api_calls, api_unhooking=False, mllvm_options=None, god_speed=False, encoding=None, loader_number=1, dream=None, etw=False, compile_as_dll=False, compile_as_cpl = False):


# Find the latest MinGW directory
mingw_dir_command = "ls -d /usr/lib/gcc/x86_64-w64-mingw32/*-win32 | sort -V | tail -n 1"
mingw_dir = subprocess.check_output(mingw_dir_command, shell=True, text=True).strip()

if not mingw_dir:
print("Error: No x86_64-w64-mingw32 directory found.")
sys.exit(1)

print(f"Using MinGW directory: {mingw_dir} \n")


if not mingw_dir:
print("Error: No x86_64-w64-mingw32 directory found.")
sys.exit(1)

if loader_number == 1 or 39 or 40 or 41:
try:
subprocess.run(['nasm', '-f', 'win64', 'assembly.asm', '-o', 'assembly.o'], check=True)
Expand All @@ -644,7 +660,13 @@ def compile_output(loader_path, output_name, compiler, sleep_flag, anti_emulatio
print(f"[-] NASM assembly compilation failed: {e}")
return # Exit the function if NASM compilation fails


if not output_name:
raise ValueError("output_name is empty. Please provide a valid output name.")

# Ensure output_name has a path
if not os.path.dirname(output_name):
output_name = "./" + output_name

output_dir = os.path.dirname(output_name)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
Expand Down Expand Up @@ -677,9 +699,11 @@ def compile_output(loader_path, output_name, compiler, sleep_flag, anti_emulatio
elif compile_as_cpl:
compile_command.append('-shared')
output_name = output_name.replace('.exe', '.cpl')
compile_command.extend(['-o', output_name, '-v', '-L/usr/lib/gcc/x86_64-w64-mingw32/12-win32',
compile_command.extend(['-o', output_name, '-v', f'-L{mingw_dir}',
'-L./clang_test_include', '-I./c++/', '-I./c++/mingw32/'])
elif compiler == "akira":


# Default LLVM options for Akira
# default_akira_options = ['-irobf-indbr', '-irobf-icall', '-irobf-indgv', '-irobf-cse', '-irobf-cff']
# akira_options = mllvm_options if mllvm_options else default_akira_options
Expand All @@ -696,7 +720,7 @@ def compile_output(loader_path, output_name, compiler, sleep_flag, anti_emulatio
elif compile_as_cpl:
compile_command.append('-shared')
output_name = output_name.replace('.exe', '.cpl')
compile_command.extend(['-o', output_name, '-v', '-L/usr/lib/gcc/x86_64-w64-mingw32/12-win32',
compile_command.extend(['-o', output_name, '-v', f'-L{mingw_dir}',
'-L./clang_test_include', '-I./c++/', '-I./c++/mingw32/'])
for option in akira_options:
compile_command.extend(['-mllvm', option])
Expand Down Expand Up @@ -818,14 +842,14 @@ def compile_with_syswhisper(loader_path, output_name, syswhisper_option, sleep_f
compile_command = ["./akira_built/bin/clang++", '-I.', '-I./converter', '-I./evader', "-D", "nullptr=NULL", "-mllvm", "-irobf-indbr", "-mllvm", "-irobf-icall",
"-mllvm", "-irobf-indgv", "-mllvm", "-irobf-cse", "-mllvm", "-irobf-cff", "-target", "x86_64-w64-mingw32",
loader_path, "./classic_stubs/syscalls.c", "./classic_stubs/syscallsstubs.std.x64.s", "-o", output_name, "-v",
"-L/usr/lib/gcc/x86_64-w64-mingw32/12-win32", "-L./clang_test_include", "-I./c++/", "-I./c++/mingw32/"] + additional_sources
f"-L{mingw_dir}", "-L./clang_test_include", "-I./c++/", "-I./c++/mingw32/"] + additional_sources
subprocess.run(compile_command, check=True)
elif compiler == "pluto":
# Pluto-specific compilation command
compile_command = ["./llvm_obfuscator_pluto/bin/clang++", '-I.', '-I./converter', '-I./evader', "-fms-extensions", "-D", "nullptr=NULL", "-O3", "-flto", "-fuse-ld=lld",
"-mllvm", "-passes=mba,sub,idc,bcf,fla,gle", "-Xlinker", "-mllvm", "-Xlinker", "-passes=hlw,idc",
"-target", "x86_64-w64-mingw32", loader_path, "./classic_stubs/syscalls.c", "./classic_stubs/syscallsstubs.std.x64.s", "-o", output_name, "-v",
"-L/usr/lib/gcc/x86_64-w64-mingw32/12-win32", "-L./clang_test_include", "-I./c++/", "-I./c++/mingw32/"] + additional_sources
f"-L{mingw_dir}", "-L./clang_test_include", "-I./c++/", "-I./c++/mingw32/"] + additional_sources
subprocess.run(compile_command, check=True)
elif syswhisper_option == 1:
# Random syscall jumps compilation
Expand Down
6 changes: 6 additions & 0 deletions clang_test_include/algorithm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace std {
template<class T> constexpr const T& min(const T& a, const T& b);
template<class T> constexpr const T& max(const T& a, const T& b);
}
4 changes: 4 additions & 0 deletions clang_test_include/climits
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#define INT_MIN -2147483648
#define INT_MAX 2147483647
236 changes: 236 additions & 0 deletions clang_test_include/cmath
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
#pragma once

// __clang_cuda_(c)math(.h) also provide `abs` which actually belong in
// cstdlib. We could split them out but for now we just include cstdlib from
// cmath.h which is what the systems I've seen do as well.
#include <cstdlib>

#include <math.h>

double acos(double);
float acos(float);
double acosh(double);
float acosh(float);
double asin(double);
float asin(float);
double asinh(double);
float asinh(float);
double atan2(double, double);
float atan2(float, float);
double atan(double);
float atan(float);
double atanh(double);
float atanh(float);
double cbrt(double);
float cbrt(float);
double ceil(double);
float ceil(float);
double copysign(double, double);
float copysign(float, float);
double cos(double);
float cos(float);
double cosh(double);
float cosh(float);
double erfc(double);
float erfc(float);
double erf(double);
float erf(float);
double exp2(double);
float exp2(float);
double exp(double);
float exp(float);
double expm1(double);
float expm1(float);
double fdim(double, double);
float fdim(float, float);
double floor(double);
float floor(float);
double fma(double, double, double);
float fma(float, float, float);
double fmax(double, double);
float fmax(float, float);
float max(float, float);
double max(double, double);
double fmin(double, double);
float fmin(float, float);
float min(float, float);
double min(double, double);
double fmod(double, double);
float fmod(float, float);
int fpclassify(double);
int fpclassify(float);
double frexp(double, int *);
float frexp(float, int *);
double hypot(double, double);
float hypot(float, float);
int ilogb(double);
int ilogb(float);
bool isfinite(long double);
bool isfinite(double);
bool isfinite(float);
bool isgreater(double, double);
bool isgreaterequal(double, double);
bool isgreaterequal(float, float);
bool isgreater(float, float);
bool isinf(long double);
bool isinf(double);
bool isinf(float);
bool isless(double, double);
bool islessequal(double, double);
bool islessequal(float, float);
bool isless(float, float);
bool islessgreater(double, double);
bool islessgreater(float, float);
bool isnan(long double);
#ifdef USE_ISNAN_WITH_INT_RETURN
int isnan(double);
int isnan(float);
#else
bool isnan(double);
bool isnan(float);
#endif
bool isnormal(double);
bool isnormal(float);
bool isunordered(double, double);
bool isunordered(float, float);
double ldexp(double, int);
float ldexp(float, int);
double lgamma(double);
float lgamma(float);
long long llrint(double);
long long llrint(float);
double log10(double);
float log10(float);
double log1p(double);
float log1p(float);
double log2(double);
float log2(float);
double logb(double);
float logb(float);
double log(double);
float log(float);
long lrint(double);
long lrint(float);
long lround(double);
long lround(float);
long long llround(float); // No llround(double).
double modf(double, double *);
float modf(float, float *);
double nan(const char *);
float nanf(const char *);
double nearbyint(double);
float nearbyint(float);
double nextafter(double, double);
float nextafter(float, float);
double pow(double, double);
double pow(double, int);
float pow(float, float);
float pow(float, int);
double remainder(double, double);
float remainder(float, float);
double remquo(double, double, int *);
float remquo(float, float, int *);
double rint(double);
float rint(float);
double round(double);
float round(float);
double scalbln(double, long);
float scalbln(float, long);
double scalbn(double, int);
float scalbn(float, int);
bool signbit(double);
bool signbit(float);
long double sin(long double);
double sin(double);
float sin(float);
double sinh(double);
float sinh(float);
double sqrt(double);
float sqrt(float);
double tan(double);
float tan(float);
double tanh(double);
float tanh(float);
double tgamma(double);
float tgamma(float);
double trunc(double);
float trunc(float);

namespace std {

using ::acos;
using ::acosh;
using ::asin;
using ::asinh;
using ::atan;
using ::atan2;
using ::atanh;
using ::cbrt;
using ::ceil;
using ::copysign;
using ::cos;
using ::cosh;
using ::erf;
using ::erfc;
using ::exp;
using ::exp2;
using ::expm1;
using ::fdim;
using ::floor;
using ::fma;
using ::fmax;
using ::fmin;
using ::fmod;
using ::fpclassify;
using ::frexp;
using ::hypot;
using ::ilogb;
using ::isfinite;
using ::isgreater;
using ::isgreaterequal;
using ::isinf;
using ::isless;
using ::islessequal;
using ::islessgreater;
using ::isnan;
using ::isnormal;
using ::isunordered;
using ::ldexp;
using ::lgamma;
using ::llrint;
using ::log;
using ::log10;
using ::log1p;
using ::log2;
using ::logb;
using ::lrint;
using ::lround;
using ::llround;
using ::modf;
using ::nan;
using ::nanf;
using ::nearbyint;
using ::nextafter;
using ::pow;
using ::remainder;
using ::remquo;
using ::rint;
using ::round;
using ::scalbln;
using ::scalbn;
using ::signbit;
using ::sin;
using ::sinh;
using ::sqrt;
using ::tan;
using ::tanh;
using ::tgamma;
using ::trunc;

} // namespace std

#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
Loading

0 comments on commit b4c7b67

Please sign in to comment.