Clean up linux shellcode Makefile

Now you can "make single_bind_tcp_shell", or the like, and build one
payload instead of the kludgy embedded shell script that always builds
all of them.

Need to do the same with BSD.
unstable
James Lee 2012-09-03 23:21:49 -05:00
parent 783ffb13c2
commit 7afd470eb0
1 changed files with 32 additions and 6 deletions

View File

@ -1,17 +1,43 @@
ASM=nasm
STAGERS=stager_sock_bind stager_sock_bind_udp stager_sock_bind_icmp \ STAGERS=stager_sock_bind stager_sock_bind_udp stager_sock_bind_icmp \
stager_egghunt stager_sock_find stager_sock_reverse \ stager_egghunt stager_sock_find stager_sock_reverse \
stager_sock_reverse_icmp stager_sock_reverse_udp \ stager_sock_reverse_icmp stager_sock_reverse_udp \
stager_sock_reverse_udp_dns stager_sock_reverse_udp_dns
STAGES=stage_tcp_shell stage_udp_shell STAGES=stage_tcp_shell stage_udp_shell
SINGLE=single_adduser single_bind_tcp_shell single_find_tcp_shell \ SINGLE=single_adduser single_bind_tcp_shell single_find_tcp_shell \
single_reverse_tcp_shell single_reverse_udp_shell single_exec single_reverse_tcp_shell single_reverse_udp_shell single_exec
OBJS=${STAGERS} ${STAGES} ${SINGLE} OBJS=${STAGERS} ${STAGES} ${SINGLE}
include ../../Makefile.incl .SUFFIXES:
.SUFFIXES: .asm .hex .disasm .o
# Tell Make not to delete these intermediate files
.PRECIOUS: %.hex %.disasm
all: $(SINGLE) $(STAGES) $(STAGERS)
%.o: %.asm %.bin %.hex %.disasm
@nasm -o $@ -f elf $<
%.bin: %.asm
@nasm -o $@ -f bin $<
# Replace 00 with \x00. Put quotes at beginning and end of line. Put plus at
# end of all lines but the last. This ends up outputting an escaped string
# suitable for use in a Ruby script.
%.hex: %.bin
@xxd -c 16 -ps $< | \
sed -e 's/\([0123456789abcdef][0123456789abcdef]\)/\\x\1/g' \
-e 's/^/"/;s/$$/"/;$$ b;s/$$/+/;' > $@
%.disasm: %.bin
@ndisasm -b 32 $< > $@
$(SINGLE) $(STAGES) $(STAGERS): %: %.o
@echo "Building $@... (`wc -c $(<:.o=.bin)|awk '{print $$1}'` bytes)"
@ld -i -m elf_i386 $< -o $@
@chmod +x $@
all:
@for i in ${OBJS}; ${BUILDASM}; done
clean: clean:
rm -f *.o *.hex ${OBJS} *.disasm rm -f *.bin *.tmp *.o *.hex ${OBJS} *.disasm