2010-09-09 15:51:30 +00:00
|
|
|
# PKS, I suck at Makefile's. Given that this compiles POSIX meterpreter and
|
|
|
|
# associated stuff (openssl, libpcap, etc) this is going to get very messy,
|
|
|
|
# very quickly.
|
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
objects = external/source/meterpreter/source/bionic/compiled/libc.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libm.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libdl.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libcrypto.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libssl.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libsupport.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libmetsrv_main.so
|
|
|
|
objects += external/source/meterpreter/source/bionic/compiled/libpcap.so
|
|
|
|
objects += data/meterpreter/msflinker_linux_x86.bin
|
|
|
|
objects += data/meterpreter/ext_server_stdapi.lso
|
|
|
|
objects += data/meterpreter/ext_server_sniffer.lso
|
|
|
|
objects += data/meterpreter/ext_server_networkpug.lso
|
|
|
|
|
2012-02-10 20:57:59 +00:00
|
|
|
BIONIC=$(PWD)/external/source/meterpreter/source/bionic
|
|
|
|
LIBC=$(BIONIC)/libc
|
|
|
|
LIBM=$(BIONIC)/libm
|
|
|
|
COMPILED=$(BIONIC)/compiled
|
|
|
|
|
|
|
|
PCAP_CFLAGS = -march=i386 -m32 -Wl,--hash-style=sysv -fno-stack-protector -nostdinc -nostdlib -fPIC -DPIC -g -Wall -D_UNIX -D__linux__ -I$(LIBC)/include -I$(LIBC)/kernel/common/linux/ -I$(LIBC)/kernel/common/ -I$(LIBC)/arch-x86/include/ -I$(LIBC)/kernel/arch-x86/ -Dwchar_t="char" -fno-builtin -D_SIZE_T_DECLARED -DElf_Size="u_int32_t" -D_BYTE_ORDER=_LITTLE_ENDIAN -lgcc -L$(COMPILED) -fPIC -Os -lc
|
|
|
|
|
|
|
|
OSSL_CFLAGS=-Os -Wl,--hash-style=sysv -march=i386 -m32 -nostdinc -nostdlib -fno-builtin -fpic -I $(LIBC)/include -I $(LIBC)/kernel/common/linux/ -I $(LIBC)/kernel/common/ -I $(LIBC)/arch-x86/include/ -I $(LIBC)/kernel/arch-x86/ -I$(LIBC)/private -I$(LIBM)/include -DPIC -Dwchar_t='char' -D_SIZE_T_DECLARED -DElf_Size='u_int32_t' -D_BYTE_ORDER=_LITTLE_ENDIAN -L$(COMPILED) -lc
|
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
workspace = external/source/meterpreter/workspace
|
|
|
|
|
|
|
|
all: $(objects)
|
2010-09-09 15:51:30 +00:00
|
|
|
|
2012-02-10 20:57:59 +00:00
|
|
|
debug: DEBUG=true
|
|
|
|
# I'm 99% sure this is the wrong way to do this
|
|
|
|
debug: MAKE += debug
|
|
|
|
debug: all
|
|
|
|
|
2010-09-09 15:51:30 +00:00
|
|
|
external/source/meterpreter/source/bionic/compiled/libc.so: external/source/meterpreter/source/bionic/compiled
|
|
|
|
(cd external/source/meterpreter/source/bionic/libc && ARCH=x86 TOP=${PWD} jam && cd out/x86/ && sh make.sh && [ -f libbionic.so ] )
|
|
|
|
cp external/source/meterpreter/source/bionic/libc/out/x86/libbionic.so external/source/meterpreter/source/bionic/compiled/libc.so
|
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled:
|
|
|
|
mkdir external/source/meterpreter/source/bionic/compiled/
|
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libm.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(LIBM) -f msfMakefile && [ -f $(LIBM)/libm.so ]
|
|
|
|
cp $(LIBM)/libm.so $(COMPILED)/libm.so
|
2010-09-09 15:51:30 +00:00
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libdl.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(BIONIC)/libdl && [ -f $(BIONIC)/libdl/libdl.so ]
|
|
|
|
cp $(BIONIC)/libdl/libdl.so $(COMPILED)/libdl.so
|
2010-09-09 15:51:30 +00:00
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libcrypto.so: tmp/openssl-0.9.8o/libssl.so
|
2012-02-10 20:57:59 +00:00
|
|
|
cp tmp/openssl-0.9.8o/libcrypto.so external/source/meterpreter/source/bionic/compiled/libcrypto.so
|
2010-09-09 15:51:30 +00:00
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libssl.so: tmp/openssl-0.9.8o/libssl.so
|
|
|
|
cp tmp/openssl-0.9.8o/libssl.so external/source/meterpreter/source/bionic/compiled/libssl.so
|
|
|
|
|
|
|
|
tmp/openssl-0.9.8o/libssl.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
[ -d tmp ] || mkdir tmp
|
2012-01-27 22:14:47 +00:00
|
|
|
[ -d tmp/openssl-0.9.8o ] || wget -O tmp/openssl-0.9.8o.tar.gz http://openssl.org/source/openssl-0.9.8o.tar.gz
|
|
|
|
[ -f tmp/openssl-0.9.8o/Configure ] || tar -C tmp/ -xzf tmp/openssl-0.9.8o.tar.gz
|
|
|
|
(cd tmp/openssl-0.9.8o && \
|
|
|
|
cat Configure | grep -v 'linux-msf' | \
|
|
|
|
sed -e 's#my %table=(#my %table=( \
|
2012-02-10 20:57:59 +00:00
|
|
|
"linux-msf", "gcc:$(OSSL_CFLAGS) -DL_ENDIAN -DTERMIO -Wall::$(OSSL_CFLAGS) -D_REENTRANT::$(OSSL_CFLAGS) -ldl:BN_LLONG $${x86_gcc_des} $${x86_gcc_opts}:$${x86_elf_asm}:dlfcn:linux-shared:$(OSSL_CFLAGS) -fPIC::.so.\\$$\\$$(SHLIB_MAJOR).\\$$\\$$(SHLIB_MINOR)",\
|
2012-01-27 22:14:47 +00:00
|
|
|
#;' > Configure-msf;\
|
|
|
|
cp Configure-msf Configure && chmod +x Configure && \
|
|
|
|
grep linux-msf Configure && \
|
|
|
|
./Configure --prefix=/tmp/out threads shared no-hw no-dlfcn no-zlib no-krb5 no-idea 386 linux-msf \
|
|
|
|
)
|
2012-02-10 20:57:59 +00:00
|
|
|
(cd tmp/openssl-0.9.8o && make depend all ; [ -f libssl.so.0.9.8 -a -f libcrypto.so.0.9.8 ] )
|
2011-07-25 07:59:51 +00:00
|
|
|
cp tmp/openssl-0.9.8o/libssl.so* tmp/openssl-0.9.8o/libcrypto.so* external/source/meterpreter/source/openssl/lib/linux/i386/
|
2010-09-09 15:51:30 +00:00
|
|
|
|
2010-09-13 14:44:00 +00:00
|
|
|
external/source/meterpreter/source/bionic/compiled/libpcap.so: tmp/libpcap-1.1.1/libpcap.so.1.1.1
|
|
|
|
cp tmp/libpcap-1.1.1/libpcap.so.1.1.1 external/source/meterpreter/source/bionic/compiled/libpcap.so
|
|
|
|
|
|
|
|
tmp/libpcap-1.1.1/libpcap.so.1.1.1:
|
|
|
|
[ -d tmp ] || mkdir tmp
|
|
|
|
[ -f tmp/libpcap-1.1.1.tar.gz ] || wget -O tmp/libpcap-1.1.1.tar.gz http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
|
2012-01-27 22:14:47 +00:00
|
|
|
[ -f tmp/libpcap-1.1.1/configure ] || tar -C tmp -xzf tmp/libpcap-1.1.1.tar.gz
|
2010-09-13 14:44:00 +00:00
|
|
|
(cd tmp/libpcap-1.1.1 && ./configure --disable-bluetooth --without-bluetooth --without-usb --disable-usb --without-can --disable-can --without-usb-linux --disable-usb-linux)
|
|
|
|
echo '#undef HAVE_DECL_ETHER_HOSTTON' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
echo '#undef HAVE_SYS_BITYPES_H' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
echo '#undef PCAP_SUPPORT_CAN' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
echo '#undef PCAP_SUPPORT_USB' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
echo '#undef HAVE_ETHER_HOSTTON' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
echo '#define _STDLIB_H this_works_around_malloc_definition_in_grammar_dot_c' >> tmp/libpcap-1.1.1/config.h
|
|
|
|
(cd tmp/libpcap-1.1.1 && patch --dry-run -p0 < ../../external/source/meterpreter/source/libpcap/pcap_nametoaddr_fix.diff && patch -p0 < ../../external/source/meterpreter/source/libpcap/pcap_nametoaddr_fix.diff)
|
|
|
|
sed -i -e s/pcap-usb-linux.c//g -e s/fad-getad.c/fad-gifc.c/g tmp/libpcap-1.1.1/Makefile
|
2012-02-10 20:57:59 +00:00
|
|
|
sed -i -e s^"CC = gcc"^"CC = gcc $(PCAP_CFLAGS)"^g tmp/libpcap-1.1.1/Makefile
|
|
|
|
$(MAKE) -C tmp/libpcap-1.1.1
|
2010-09-13 14:44:00 +00:00
|
|
|
|
|
|
|
|
2010-09-09 15:51:30 +00:00
|
|
|
data/meterpreter/msflinker_linux_x86.bin: external/source/meterpreter/source/server/rtld/msflinker.bin
|
|
|
|
cp external/source/meterpreter/source/server/rtld/msflinker.bin data/meterpreter/msflinker_linux_x86.bin
|
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
external/source/meterpreter/source/server/rtld/msflinker.bin: external/source/meterpreter/source/bionic/compiled/libc.so
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C external/source/meterpreter/source/server/rtld
|
2010-09-09 15:51:30 +00:00
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
$(workspace)/metsrv/libmetsrv_main.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(workspace)/metsrv
|
2011-07-25 07:59:51 +00:00
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libmetsrv_main.so: $(workspace)/metsrv/libmetsrv_main.so
|
2012-02-10 20:57:59 +00:00
|
|
|
cp $(workspace)/metsrv/libmetsrv_main.so external/source/meterpreter/source/bionic/compiled/libmetsrv_main.so
|
2011-07-25 07:59:51 +00:00
|
|
|
|
|
|
|
$(workspace)/common/libsupport.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(workspace)/common
|
2011-07-25 07:59:51 +00:00
|
|
|
|
|
|
|
external/source/meterpreter/source/bionic/compiled/libsupport.so: $(workspace)/common/libsupport.so
|
|
|
|
cp $(workspace)/common/libsupport.so external/source/meterpreter/source/bionic/compiled/libsupport.so
|
|
|
|
|
|
|
|
$(workspace)/ext_server_sniffer/ext_server_sniffer.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_sniffer
|
2010-09-09 15:51:30 +00:00
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
data/meterpreter/ext_server_sniffer.lso: $(workspace)/ext_server_sniffer/ext_server_sniffer.so
|
|
|
|
cp $(workspace)/ext_server_sniffer/ext_server_sniffer.so data/meterpreter/ext_server_sniffer.lso
|
2010-09-09 15:51:30 +00:00
|
|
|
|
2011-07-25 07:59:51 +00:00
|
|
|
$(workspace)/ext_server_stdapi/ext_server_stdapi.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_stdapi
|
2011-07-25 07:59:51 +00:00
|
|
|
|
2012-02-10 20:57:59 +00:00
|
|
|
data/meterpreter/ext_server_stdapi.lso: $(workspace)/ext_server_stdapi/ext_server_stdapi.so
|
2011-07-25 07:59:51 +00:00
|
|
|
cp $(workspace)/ext_server_stdapi/ext_server_stdapi.so data/meterpreter/ext_server_stdapi.lso
|
|
|
|
|
|
|
|
$(workspace)/ext_server_networkpug/ext_server_networkpug.so:
|
2012-02-10 20:57:59 +00:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_networkpug
|
2011-07-25 07:59:51 +00:00
|
|
|
|
|
|
|
data/meterpreter/ext_server_networkpug.lso: $(workspace)/ext_server_networkpug/ext_server_networkpug.so
|
|
|
|
cp $(workspace)/ext_server_networkpug/ext_server_networkpug.so data/meterpreter/ext_server_networkpug.lso
|
2010-09-21 09:35:46 +00:00
|
|
|
|
2011-07-24 19:25:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
clean:
|
2011-07-25 07:59:51 +00:00
|
|
|
rm -f $(objects)
|
2012-02-14 00:59:01 +00:00
|
|
|
(cd external/source/meterpreter/source/server/rtld/ && make clean)
|
|
|
|
(cd $(workspace) && make clean)
|
|
|
|
|
|
|
|
depclean:
|
2011-07-25 07:59:51 +00:00
|
|
|
rm -f external/source/meterpreter/source/bionic/lib*/*.o
|
2012-01-27 23:33:27 +00:00
|
|
|
find external/source/meterpreter/source/bionic/ -name '*.a' -print0 | xargs -0 rm -f 2>/dev/null
|
2011-07-25 07:59:51 +00:00
|
|
|
rm -f external/source/meterpreter/source/bionic/lib*/*.so
|
|
|
|
|
2012-01-27 23:33:27 +00:00
|
|
|
clean-pcap:
|
2012-02-01 17:59:06 +00:00
|
|
|
#(cd tmp/libpcap-1.1.1/ && make clean)
|
|
|
|
# This avoids the pcap target trying to patch the same file more than once.
|
|
|
|
# It's a pretty small tar, so untar'ing goes pretty quickly anyway, in
|
|
|
|
# contrast to openssl.
|
|
|
|
rm -r tmp/libpcap-1.1.1 || true
|
2011-07-24 19:25:19 +00:00
|
|
|
|
2012-01-27 23:33:27 +00:00
|
|
|
clean-ssl:
|
|
|
|
(cd tmp/openssl-0.9.8o/ && make clean)
|
|
|
|
|
2012-02-14 00:59:01 +00:00
|
|
|
really-clean: clean clean-ssl clean-pcap depclean
|
2012-01-27 23:33:27 +00:00
|
|
|
|
|
|
|
|
2012-02-10 20:57:59 +00:00
|
|
|
.PHONY: clean clean-ssl clean-pcap really-clean debug
|
2011-07-24 19:25:19 +00:00
|
|
|
|