diff options
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | crypter/.gitignore | 1 | ||||
-rw-r--r-- | crypter/Makefile | 29 | ||||
-rw-r--r-- | shellcode/Makefile | 16 |
4 files changed, 29 insertions, 28 deletions
@@ -1,3 +1,5 @@ +CD := cd +MAKE := make RM := rm CC := gcc STRIP := strip @@ -14,10 +16,10 @@ all: $(SOURCES) $(TARGETS) shellcode crypter post-build main: $(SOURCES) $(TARGETS) shellcode: - make -f shellcode/Makefile SUBDIR=shellcode + $(MAKE) -C shellcode all crypter: - make -f crypter/Makefile SUBDIR=crypter SCDIR=. + $(MAKE) -C crypter all post-build: @read -p "disable protection stuff? (y/N) " answ; \ @@ -43,9 +45,10 @@ endif ln -s $< $@ clean: + $(RM) -f *.o $(RM) -f $(patsubst %.o,%,$(TARGETS)) $(patsubst %.c,%_x64,$(wildcard *.c)) $(RM) -f $(TARGETS) - make -f shellcode/Makefile SUBDIR=shellcode clean - make -f crypter/Makefile SUBDIR=crypter clean + $(MAKE) -C crypter clean + $(MAKE) -C shellcode clean .PHONY: shellcode crypter clean diff --git a/crypter/.gitignore b/crypter/.gitignore index 33b4c3f..e084250 100644 --- a/crypter/.gitignore +++ b/crypter/.gitignore @@ -1,2 +1,3 @@ *.h *_encoder +*_encoder_x64 diff --git a/crypter/Makefile b/crypter/Makefile index 5b1b5d6..db41478 100644 --- a/crypter/Makefile +++ b/crypter/Makefile @@ -4,12 +4,17 @@ CC := gcc LD := ld XXD := xxd ASMFLAGS = -g -CFLAGS = -Wall -fpic -Os -LDFLAGS = +CFLAGS ?= -Wall -fpic -Os +X86_FLAGS := -m32 +X64_FLAGS := -m64 +LDFLAGS ?= SUBDIR ?= . -TARGETS = $(patsubst %.asm,%.o,$(wildcard $(SUBDIR)/*.asm)) $(patsubst %.c,%.o,$(wildcard $(SUBDIR)/*.c)) +TARGETS := $(patsubst %.asm,%.o,$(wildcard $(SUBDIR)/*.asm)) $(patsubst %.c,%,$(wildcard $(SUBDIR)/*.c)) +SOURCES_ASM := $(wildcard $(SUBDIR)/*.asm) +SOURCES_C := $(wildcard $(SUBDIR)/*.c) SCDIR ?= .. SCC := $(shell if [ -x $(SCDIR)/sc-test ]; then echo "yes"; else echo "no"; fi) +LBITS := $(shell getconf LONG_BIT) all: $(TARGETS) @@ -17,17 +22,21 @@ all: $(TARGETS) %.o : %.asm $(ASM) $(ASMFLAGS) -o $@ $< -%.o : %.c +% : %.c ifneq ($(SCC),yes) - $(error Please run 'make' in the main directory) + $(error Please run 'make' first in the main directory) +endif + @echo "generating header $(patsubst %.c,%.h,$<) for target $<" + -$(shell $(SCDIR)/sc-test -p $(SUBDIR)/`cat "$<" | sed -n 's/.*#DECODER=//p'` | sed 's/shellcode/decoder/' > $(patsubst %.c,%.h,$<)) + -$(shell $(SCDIR)/sc-test -p $(SUBDIR)/`cat "$<" | sed -n 's/.*#SHELLCODE=//p'` >> $(patsubst %.c,%.h,$<)) + $(CC) $(CFLAGS) $(X86_FLAGS) -D_USE_CFG -o $(patsubst %.c,%,$<) $< +ifeq ($(LBITS),64) + $(CC) $(CFLAGS) $(X64_FLAGS) -D_USE_CFG -o $(patsubst %.c,%_x64,$<) $< endif - @echo "generating header $(patsubst %.o,%.h,$@) for target $<" - -$(shell $(SCDIR)/sc-test -p $(SUBDIR)/`cat "$<" | sed -n 's/.*#DECODER=//p'` | sed 's/shellcode/decoder/' > $(patsubst %.o,%.h,$@)) - -$(shell $(SCDIR)/sc-test -p $(SUBDIR)/`cat "$<" | sed -n 's/.*#SHELLCODE=//p'` >> $(patsubst %.o,%.h,$@)) - $(CC) $(CFLAGS) -D_USE_CFG -o $(patsubst %.c,%,$<) $< clean: - $(RM) -f $(patsubst %.o,%,$(TARGETS)) $(TARGETS) $(patsubst %.o,%.h,$(TARGETS)) $(RM) -f *.o + $(RM) -f $(patsubst %.c,%,$(SOURCES_C)) $(patsubst %.c,%_x64,$(SOURCES_C)) + $(RM) -f $(patsubst %.asm,%.o,$(SOURCES_ASM)) .PHONY: all clean diff --git a/shellcode/Makefile b/shellcode/Makefile index e7833cd..2325641 100644 --- a/shellcode/Makefile +++ b/shellcode/Makefile @@ -1,26 +1,14 @@ RM := rm ASM := nasm -CC := gcc -LD := ld -OBJCOPY := objcopy -XXD := xxd -CFLAGS = -c -Wall -fpic -Os -LDFLAGS = SUBDIR ?= . -TARGETS = $(patsubst %.c,%.o,$(wildcard $(SUBDIR)/*.c)) $(patsubst %.asm,%.o,$(wildcard $(SUBDIR)/*.asm)) +TARGETS = $(patsubst %.asm,%.o,$(wildcard $(SUBDIR)/*.asm)) all: $(TARGETS) -%.o : %.c - $(CC) $(CFLAGS) -o $@ $< - $(LD) $(LDFLAGS) -N -Ttext 0x0 -e _start -Map $(patsubst %.o,%.map,$@) $@ -o $(patsubst %.o,%,$@) - $(OBJCOPY) -R .note -R .comment -S -O binary $(patsubst %.o,%,$@) $(patsubst %.o,%.bin,$@) - $(XXD) -i $(patsubst %.o,%.bin,$@) - %.o : %.asm $(ASM) -o $@ $< clean: - $(RM) -f $(patsubst %.o,%.map,$(TARGETS)) $(patsubst %.o,%.bin,$(TARGETS)) $(patsubst %.o,%,$(TARGETS)) $(TARGETS) + $(RM) -f $(TARGETS) .PHONY: all clean |