From 8547acd281ee381186a9cba2b15ea62189d7e791 Mon Sep 17 00:00:00 2001 From: slimwang Date: Fri, 12 Jun 2026 14:30:22 +0800 Subject: [PATCH] fix(nanodump): make host-tool build work on macOS On macOS, gcc is Apple clang which does not support static linking (no crt0.o/static libc) or the obsolete -s linker flag, so building the host helper tools (bin2c, restore_signature) failed with "library 'crt0.o' not found". Stripping restore_signature with the mingw strip also failed since it is a native Mach-O binary, not PE. Detect the host OS and drop -static -s on Darwin, and use the host strip instead of the mingw strip for the native helper tool. Linux behavior is unchanged. --- Creds-BOF/nanodump/Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Creds-BOF/nanodump/Makefile b/Creds-BOF/nanodump/Makefile index 6e5face..fdc73fa 100644 --- a/Creds-BOF/nanodump/Makefile +++ b/Creds-BOF/nanodump/Makefile @@ -8,6 +8,16 @@ OPTIONS := -masm=intel -Wimplicit-function-declaration -Wall -I include -Wl,--dy PPL_MEDIC_OPTIONS := -Wno-trigraphs -DPASS_PARAMS_VIA_NAMED_PIPES=1 SSP_OPTIONS := -DPASS_PARAMS_VIA_NAMED_PIPES=1 +# macOS' gcc is clang and does not support static linking (no crt0.o) or -s. +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Darwin) + HOST_FLAGS := + HOST_STRIP := strip +else + HOST_FLAGS := -static -s + HOST_STRIP := $(STRIP_x64) +endif + nanodump: @(mkdir dist 2>/dev/null) && echo 'creating dist' || echo 'dist exists' @@ -23,7 +33,7 @@ nanodump: @$(CC_x86) -c source/entry.c -o dist/$(BOFNAME).x86.o $(OPTIONS) -DNANO -DBOF @$(STRIP_x86) --strip-unneeded dist/$(BOFNAME).x86.o && echo '[+] nanodump x86' || echo '[!] nanodump x86' - @$(GCC) source/bin2c.c -o dist/bin2c -static -s -Os + @$(GCC) source/bin2c.c -o dist/bin2c $(HOST_FLAGS) -Os @$(CC_x64) source/utils.c source/handle.c source/modules.c source/syscalls.c source/token_priv.c source/nanodump.c source/dinvoke.c source/pipe.c source/entry.c -o dist/$(BOFNAME)_ssp.x64.dll $(OPTIONS) $(SSP_OPTIONS) -DNANO -DSSP -DDDL -shared @$(STRIP_x64) --strip-all dist/$(BOFNAME)_ssp.x64.dll && echo '[+] nanodump_ssp Dll x64' || echo '[!] nanodump_ssp Dll x64' @@ -75,8 +85,8 @@ nanodump: @$(CC_x64) -c source/ppl/ppl.c -o dist/$(BOFNAME)_ppl_medic.x64.o $(OPTIONS) $(PPL_MEDIC_OPTIONS) -DBOF -DPPL_MEDIC @$(STRIP_x64) --strip-unneeded dist/$(BOFNAME)_ppl_medic.x64.o && echo '[+] nanodump_ppl_medic x64' || echo '[!] nanodump_ppl_medic x64' - @$(GCC) source/restore_signature.c -o scripts/restore_signature -static -s -Os - @$(STRIP_x64) --strip-all scripts/restore_signature + @$(GCC) source/restore_signature.c -o scripts/restore_signature $(HOST_FLAGS) -Os + @$(HOST_STRIP) scripts/restore_signature clean: @rm -f dist/*