2013-02-23 00:49:47 +01:00
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
# Used by 'install' target. Change this to wherever your framework checkout is.
|
|
|
|
# Doesn't have to be development. Should point to the base directory where
|
|
|
|
# msfconsole lives.
|
|
|
|
framework_dir = ../metasploit-framework/
|
|
|
|
|
|
|
|
# Change me if you want to build openssl and libpcap somewhere else
|
|
|
|
build_tmp = posix-meterp-build-tmp
|
2014-12-16 18:51:52 +01:00
|
|
|
cwd=$(shell pwd)
|
2013-03-19 23:10:13 +01:00
|
|
|
|
2014-03-12 08:23:37 +01:00
|
|
|
ROOT=$(basename $(CURDIR:%/=%))
|
|
|
|
BIONIC=$(ROOT)/source/bionic
|
2012-11-19 23:46:07 +01:00
|
|
|
LIBC=$(BIONIC)/libc
|
|
|
|
LIBM=$(BIONIC)/libm
|
|
|
|
COMPILED=$(BIONIC)/compiled
|
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
objects = $(COMPILED)/libc.so
|
|
|
|
objects += $(COMPILED)/libm.so
|
|
|
|
objects += $(COMPILED)/libdl.so
|
|
|
|
objects += $(COMPILED)/libcrypto.so
|
|
|
|
objects += $(COMPILED)/libssl.so
|
|
|
|
objects += $(COMPILED)/libsupport.so
|
|
|
|
objects += $(COMPILED)/libmetsrv_main.so
|
|
|
|
objects += $(COMPILED)/libpcap.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
outputs = data/meterpreter/msflinker_linux_x86.bin
|
|
|
|
outputs += data/meterpreter/ext_server_stdapi.lso
|
|
|
|
outputs += data/meterpreter/ext_server_sniffer.lso
|
|
|
|
outputs += data/meterpreter/ext_server_networkpug.lso
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
STD_CFLAGS = -Os -m32 -march=i386 -fno-stack-protector
|
2015-01-14 00:20:00 +01:00
|
|
|
STD_CFLAGS += -Wl,--hash-style=sysv
|
|
|
|
STD_CFLAGS += -lc -lm -nostdinc -nostdlib -fno-builtin -fPIC -DPIC
|
2015-01-12 20:00:52 +01:00
|
|
|
STD_CFLAGS += -Dwchar_t='char' -D_SIZE_T_DECLARED -DElf_Size='u_int32_t'
|
|
|
|
STD_CFLAGS += -D_BYTE_ORDER=_LITTLE_ENDIAN -D_UNIX -D__linux__ -lgcc
|
|
|
|
STD_CFLAGS += -I$(LIBC)/include
|
|
|
|
STD_CFLAGS += -I$(LIBC)/kernel/common/linux/
|
|
|
|
STD_CFLAGS += -I$(LIBC)/kernel/common/
|
|
|
|
STD_CFLAGS += -I$(LIBC)/arch-x86/include/
|
|
|
|
STD_CFLAGS += -I$(LIBC)/kernel/arch-x86/
|
|
|
|
STD_CFLAGS += -L$(COMPILED)
|
|
|
|
|
2015-01-14 00:24:05 +01:00
|
|
|
GCCGOLD = $(shell (echo "int main(){}" | gcc -fuse-ld=gold -o/dev/null -xc -); echo $$?)
|
2015-01-14 00:20:00 +01:00
|
|
|
ifeq "$(GCCGOLD)" "0"
|
|
|
|
STD_CFLAGS += -fuse-ld=gold
|
|
|
|
endif
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
PCAP_CFLAGS = $(STD_CFLAGS)
|
|
|
|
|
|
|
|
OSSL_CFLAGS = $(STD_CFLAGS) -I$(LIBC)/private -I$(LIBM)/include
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
workspace = workspace
|
|
|
|
|
2013-02-23 00:49:47 +01:00
|
|
|
all: $(objects) $(outputs)
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
include Makefile.ossl
|
|
|
|
include Makefile.pcap
|
|
|
|
|
2012-11-19 23:46:07 +01:00
|
|
|
debug: DEBUG=true
|
|
|
|
# I'm 99% sure this is the wrong way to do this
|
|
|
|
debug: MAKE += debug
|
|
|
|
debug: all
|
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
$(COMPILED):
|
|
|
|
mkdir $(COMPILED)/
|
|
|
|
|
|
|
|
$(COMPILED)/libc.so: $(COMPILED)
|
2015-01-12 20:00:52 +01:00
|
|
|
@echo Building libc
|
|
|
|
@(cd source/bionic/libc && ARCH=x86 TOP=${ROOT} jam > build.log 2>&1 )
|
|
|
|
@(cd source/bionic/libc/out/x86/ && $(MAKE) -f Makefile.msf >> build.log 2>&1 && [ -f libbionic.so ])
|
|
|
|
@cp source/bionic/libc/out/x86/libbionic.so $(COMPILED)/libc.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
$(COMPILED)/libm.so:
|
2015-01-12 20:00:52 +01:00
|
|
|
@echo Building libm
|
|
|
|
@$(MAKE) -C $(LIBM) -f Makefile.msf > build.log 2>&1 && [ -f $(LIBM)/libm.so ]
|
|
|
|
@cp $(LIBM)/libm.so $(COMPILED)/libm.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
$(COMPILED)/libdl.so:
|
2015-01-12 20:00:52 +01:00
|
|
|
@echo Building libdl
|
|
|
|
@$(MAKE) -C $(BIONIC)/libdl > build.log && [ -f $(BIONIC)/libdl/libdl.so ]
|
|
|
|
@cp $(BIONIC)/libdl/libdl.so $(COMPILED)/libdl.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
data/meterpreter/msflinker_linux_x86.bin: source/server/rtld/msflinker.bin
|
|
|
|
cp source/server/rtld/msflinker.bin data/meterpreter/msflinker_linux_x86.bin
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
source/server/rtld/msflinker.bin: $(COMPILED)/libc.so \
|
|
|
|
$(wildcard source/server/*.h) \
|
|
|
|
$(wildcard source/server/*.c)
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C source/server/rtld
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
$(workspace)/metsrv/libmetsrv_main.so: $(COMPILED)/libsupport.so \
|
|
|
|
$(wildcard source/server/*.h) \
|
|
|
|
$(wildcard source/server/*.c)
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C $(workspace)/metsrv
|
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
$(COMPILED)/libmetsrv_main.so: $(workspace)/metsrv/libmetsrv_main.so
|
|
|
|
cp $(workspace)/metsrv/libmetsrv_main.so $(COMPILED)/libmetsrv_main.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
$(workspace)/common/libsupport.so: \
|
|
|
|
$(wildcard source/common/*.h) \
|
|
|
|
$(wildcard source/common/*.c)
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C $(workspace)/common
|
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
$(COMPILED)/libsupport.so: $(workspace)/common/libsupport.so
|
|
|
|
cp $(workspace)/common/libsupport.so $(COMPILED)/libsupport.so
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
$(workspace)/ext_server_sniffer/ext_server_sniffer.so: \
|
|
|
|
$(wildcard source/extensions/sniffer/*.h) \
|
|
|
|
$(wildcard source/extensions/sniffer/*.c) \
|
|
|
|
$(COMPILED)/libpcap.so
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_sniffer
|
|
|
|
|
2015-01-12 20:00:52 +01: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
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
$(workspace)/ext_server_stdapi/ext_server_stdapi.so: \
|
|
|
|
$(wildcard source/extensions/stdapi/*.h) \
|
|
|
|
$(wildcard source/extensions/stdapi/*.c)
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_stdapi
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
data/meterpreter/ext_server_stdapi.lso: \
|
|
|
|
$(workspace)/ext_server_stdapi/ext_server_stdapi.so
|
|
|
|
cp $(workspace)/ext_server_stdapi/ext_server_stdapi.so \
|
|
|
|
data/meterpreter/ext_server_stdapi.lso
|
2012-11-19 23:46:07 +01:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
$(workspace)/ext_server_networkpug/ext_server_networkpug.so: \
|
|
|
|
$(wildcard source/extensions/networkpug/*.h) \
|
|
|
|
$(wildcard source/extensions/networkpug/*.c)
|
2012-11-19 23:46:07 +01:00
|
|
|
$(MAKE) -C $(workspace)/ext_server_networkpug
|
|
|
|
|
2015-01-12 20:00:52 +01: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
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
|
2013-03-19 23:10:13 +01:00
|
|
|
install: $(outputs)
|
|
|
|
cp $(outputs) $(framework_dir)/data/meterpreter/
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(objects)
|
2013-03-19 23:10:13 +01:00
|
|
|
make -C source/server/rtld/ clean
|
|
|
|
make -C $(workspace) clean
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
depclean:
|
|
|
|
rm -f source/bionic/lib*/*.o
|
|
|
|
find source/bionic/ -name '*.a' -print0 | xargs -0 rm -f 2>/dev/null
|
2013-02-23 00:49:47 +01:00
|
|
|
find source/bionic/ -name '*.so' -print0 | xargs -0 rm -f 2>/dev/null
|
2015-01-14 00:20:00 +01:00
|
|
|
find . -name 'build.log' | xargs rm -f
|
2012-11-19 23:46:07 +01:00
|
|
|
rm -f source/bionic/lib*/*.so
|
2013-02-23 00:49:47 +01:00
|
|
|
rm -rf source/openssl/lib/linux/i386/
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
really-clean: clean clean-ssl clean-pcap depclean
|
|
|
|
|
2015-01-14 00:20:00 +01:00
|
|
|
distclean: really-clean
|
2012-11-19 23:46:07 +01:00
|
|
|
|
|
|
|
.PHONY: clean clean-ssl clean-pcap really-clean debug
|
|
|
|
|