aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--crypter/.gitignore1
-rw-r--r--crypter/Makefile21
-rw-r--r--shellcode/Makefile16
4 files changed, 22 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 5937b64..32fc076 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+CD := cd
+MAKE := make
RM := rm
CC := gcc
STRIP := strip
@@ -13,10 +15,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; \
@@ -42,7 +44,7 @@ disable-prot:
clean:
$(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 0508caa..11a89ac 100644
--- a/crypter/Makefile
+++ b/crypter/Makefile
@@ -3,10 +3,14 @@ ASM := nasm
CC := gcc
LD := ld
XXD := xxd
-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)
@@ -16,16 +20,17 @@ all: $(TARGETS)
%.o : %.asm
$(ASM) -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
-$(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,%,$<) $<
+ $(CC) $(CFLAGS) $(X86_FLAGS) -D_USE_CFG -o $(patsubst %.c,%,$<) $<
+ $(CC) $(CFLAGS) $(X64_FLAGS) -D_USE_CFG -o $(patsubst %.c,%_x64,$<) $<
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