Skip to content

Commit 7afd470

Browse files
committed
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.
1 parent 783ffb1 commit 7afd470

File tree

1 file changed

+32
-6
lines changed
  • external/source/shellcode/linux/ia32

1 file changed

+32
-6
lines changed
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
1-
ASM=nasm
21
STAGERS=stager_sock_bind stager_sock_bind_udp stager_sock_bind_icmp \
32
stager_egghunt stager_sock_find stager_sock_reverse \
43
stager_sock_reverse_icmp stager_sock_reverse_udp \
5-
stager_sock_reverse_udp_dns
4+
stager_sock_reverse_udp_dns
65
STAGES=stage_tcp_shell stage_udp_shell
76
SINGLE=single_adduser single_bind_tcp_shell single_find_tcp_shell \
87
single_reverse_tcp_shell single_reverse_udp_shell single_exec
8+
99
OBJS=${STAGERS} ${STAGES} ${SINGLE}
1010

11-
include ../../Makefile.incl
11+
.SUFFIXES:
12+
.SUFFIXES: .asm .hex .disasm .o
13+
14+
# Tell Make not to delete these intermediate files
15+
.PRECIOUS: %.hex %.disasm
16+
17+
all: $(SINGLE) $(STAGES) $(STAGERS)
18+
19+
%.o: %.asm %.bin %.hex %.disasm
20+
@nasm -o $@ -f elf $<
21+
22+
%.bin: %.asm
23+
@nasm -o $@ -f bin $<
24+
25+
# Replace 00 with \x00. Put quotes at beginning and end of line. Put plus at
26+
# end of all lines but the last. This ends up outputting an escaped string
27+
# suitable for use in a Ruby script.
28+
%.hex: %.bin
29+
@xxd -c 16 -ps $< | \
30+
sed -e 's/\([0123456789abcdef][0123456789abcdef]\)/\\x\1/g' \
31+
-e 's/^/"/;s/$$/"/;$$ b;s/$$/+/;' > $@
32+
33+
%.disasm: %.bin
34+
@ndisasm -b 32 $< > $@
35+
36+
$(SINGLE) $(STAGES) $(STAGERS): %: %.o
37+
@echo "Building $@... (`wc -c $(<:.o=.bin)|awk '{print $$1}'` bytes)"
38+
@ld -i -m elf_i386 $< -o $@
39+
@chmod +x $@
1240

13-
all:
14-
@for i in ${OBJS}; ${BUILDASM}; done
1541

1642
clean:
17-
rm -f *.o *.hex ${OBJS} *.disasm
43+
rm -f *.bin *.tmp *.o *.hex ${OBJS} *.disasm

0 commit comments

Comments
 (0)