From abf031f2246050cc7d313a52a79ae279bd22ed06 Mon Sep 17 00:00:00 2001 From: James Lee Date: Fri, 27 Jan 2012 15:14:47 -0700 Subject: [PATCH] Add -m32 to all the Makefiles This is in an attempt to get it compilation working on 64-bit hosts. --- external/source/meterpreter/Makefile | 24 +++++++++++++++---- .../meterpreter/source/bionic/libdl/Makefile | 2 +- .../source/bionic/libm/msfMakefile | 1 + .../meterpreter/source/server/rtld/Makefile | 2 +- .../source/meterpreter/workspace/Makefile | 2 +- .../meterpreter/workspace/common/Makefile | 2 +- .../workspace/ext_posix_sample/Makefile | 2 +- .../workspace/ext_server_networkpug/Makefile | 2 +- .../workspace/ext_server_sniffer/Makefile | 2 +- .../workspace/ext_server_stdapi/Makefile | 2 +- .../meterpreter/workspace/metsrv/Makefile | 2 +- 11 files changed, 29 insertions(+), 14 deletions(-) diff --git a/external/source/meterpreter/Makefile b/external/source/meterpreter/Makefile index fc7021ea85..331417740a 100644 --- a/external/source/meterpreter/Makefile +++ b/external/source/meterpreter/Makefile @@ -40,11 +40,25 @@ external/source/meterpreter/source/bionic/compiled/libcrypto.so: tmp/openssl-0.9 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 +LIBC=$(PWD)/external/source/meterpreter/source/bionic/libc +LIBM=$(PWD)/external/source/meterpreter/source/bionic/libm +COMPILED=$(PWD)/external/source/meterpreter/source/bionic/compiled +MSF_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 + tmp/openssl-0.9.8o/libssl.so: [ -d tmp ] || mkdir tmp - [ -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 && tar -C tmp/ -xzf tmp/openssl-0.9.8o.tar.gz - (cd tmp/openssl-0.9.8o && ./Configure threads no-zlib no-krb5 386 --prefix=/tmp/out linux-elf shared) - (cd tmp/openssl-0.9.8o && make CC="gcc -Os -Wl,--hash-style=sysv -I${PWD}/external/source/meterpreter/source/bionic/libc/include -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/linux/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/ -I${PWD}/external/source/meterpreter/source/bionic/libc/arch-x86/include/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/arch-x86/ -I${PWD}/external/source/meterpreter/source/bionic/libc/private -fPIC -DPIC -nostdinc -nostdlib -Dwchar_t='char' -fno-builtin -D_SIZE_T_DECLARED -DElf_Size='u_int32_t' -I${PWD}/external/source/meterpreter/source/bionic/libm/include -L${PWD}/external/source/meterpreter/source/bionic/compiled -D_BYTE_ORDER=_LITTLE_ENDIAN -lc" depend all ; [ -f libssl.so.0.9.8 -a -f libcrypto.so.0.9.8 ] ) + [ -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=( \ + "linux-msf", "gcc:$(MSF_CFLAGS) -DL_ENDIAN -DTERMIO -Wall::$(MSF_CFLAGS) -D_REENTRANT::$(MSF_CFLAGS) -ldl:BN_LLONG $${x86_gcc_des} $${x86_gcc_opts}:$${x86_elf_asm}:dlfcn:linux-shared:$(MSF_CFLAGS) -fPIC::.so.\\$$\\$$(SHLIB_MAJOR).\\$$\\$$(SHLIB_MINOR)",\ + #;' > 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 \ + ) + (cd tmp/openssl-0.9.8o && make CC="gcc -march=i386 -m32 -Os -Wl,--hash-style=sysv -I${PWD}/external/source/meterpreter/source/bionic/libc/include -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/linux/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/ -I${PWD}/external/source/meterpreter/source/bionic/libc/arch-x86/include/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/arch-x86/ -I${PWD}/external/source/meterpreter/source/bionic/libc/private -fPIC -DPIC -nostdinc -nostdlib -Dwchar_t='char' -fno-builtin -D_SIZE_T_DECLARED -DElf_Size='u_int32_t' -I${PWD}/external/source/meterpreter/source/bionic/libm/include -L${PWD}/external/source/meterpreter/source/bionic/compiled -D_BYTE_ORDER=_LITTLE_ENDIAN -lc" depend all ; [ -f libssl.so.0.9.8 -a -f libcrypto.so.0.9.8 ] ) cp tmp/openssl-0.9.8o/libssl.so* tmp/openssl-0.9.8o/libcrypto.so* external/source/meterpreter/source/openssl/lib/linux/i386/ external/source/meterpreter/source/bionic/compiled/libpcap.so: tmp/libpcap-1.1.1/libpcap.so.1.1.1 @@ -53,7 +67,7 @@ external/source/meterpreter/source/bionic/compiled/libpcap.so: tmp/libpcap-1.1.1 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 - tar -C tmp -xzf tmp/libpcap-1.1.1.tar.gz + [ -f tmp/libpcap-1.1.1/configure ] || tar -C tmp -xzf tmp/libpcap-1.1.1.tar.gz (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 @@ -63,7 +77,7 @@ tmp/libpcap-1.1.1/libpcap.so.1.1.1: 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 - sed -i -e s^"CC = gcc"^"CC = gcc -Wl,--hash-style=sysv -fno-stack-protector -nostdinc -nostdlib -fPIC -DPIC -g -Wall -D_UNIX -D__linux__ -I${PWD}/external/source/meterpreter/source/bionic/libc/include -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/linux/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/ -I${PWD}/external/source/meterpreter/source/bionic/libc/arch-x86/include/ -I${PWD}/external/source/meterpreter/source/bionic/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${PWD}/external/source/meterpreter/source/bionic/compiled -gstabs+ -fPIC -Os -lc"^g tmp/libpcap-1.1.1/Makefile + sed -i -e s^"CC = gcc"^"CC = gcc -march=i386 -m32 -Wl,--hash-style=sysv -fno-stack-protector -nostdinc -nostdlib -fPIC -DPIC -g -Wall -D_UNIX -D__linux__ -I${PWD}/external/source/meterpreter/source/bionic/libc/include -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/linux/ -I${PWD}/external/source/meterpreter/source/bionic/libc/kernel/common/ -I${PWD}/external/source/meterpreter/source/bionic/libc/arch-x86/include/ -I${PWD}/external/source/meterpreter/source/bionic/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${PWD}/external/source/meterpreter/source/bionic/compiled -gstabs+ -fPIC -Os -lc"^g tmp/libpcap-1.1.1/Makefile (cd tmp/libpcap-1.1.1 && make) diff --git a/external/source/meterpreter/source/bionic/libdl/Makefile b/external/source/meterpreter/source/bionic/libdl/Makefile index 8a84177986..626bf933e4 100644 --- a/external/source/meterpreter/source/bionic/libdl/Makefile +++ b/external/source/meterpreter/source/bionic/libdl/Makefile @@ -3,7 +3,7 @@ CFLAGS+= -I../libc/include -I../libc/private -I../libc/bionic -I../libc/kernel/a CFLAGS+= -I../libc/kernel/common/linux/ -I../libc/arch-x86/include/ -I../libc/kernel/common/ CFLAGS+= -Os -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 all: gcc -Wl,--hash-style=sysv -shared -o libdl.so $(CFLAGS) libdl.c diff --git a/external/source/meterpreter/source/bionic/libm/msfMakefile b/external/source/meterpreter/source/bionic/libm/msfMakefile index b61de61857..bbb1eec304 100644 --- a/external/source/meterpreter/source/bionic/libm/msfMakefile +++ b/external/source/meterpreter/source/bionic/libm/msfMakefile @@ -10,6 +10,7 @@ CFLAGS+=-I../libc/kernel/common/ -I../libc/arch-${TARGET_ARCH}/include/ -I../lib CFLAGS+=-D_BYTE_ORDER=_LITTLE_ENDIAN -Ihack/ -I${TARGET_FPU} -I../libc/arch-${TARGET_ARCH}/include CFLAGS+=-fPIC -DPIC CFLAGS+=-Wl,--hash-style=sysv +CFLAGS+=-march=i386 -m32 libm_common_src_files= \ isinf.c \ diff --git a/external/source/meterpreter/source/server/rtld/Makefile b/external/source/meterpreter/source/server/rtld/Makefile index 65d09027e0..62c8e281ef 100644 --- a/external/source/meterpreter/source/server/rtld/Makefile +++ b/external/source/meterpreter/source/server/rtld/Makefile @@ -6,7 +6,7 @@ CFLAGS+= -nostdinc -nostdlib -Dwchar_t="char" -fno-builtin -D_SIZE_T_DECLARED -D #CFLAGS+= -ggdb CFLAGS+= -DMETSRV_RTLD -D_BYTE_ORDER=_LITTLE_ENDIAN -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 OBJ=msflinker.o basic_libc.o syscall.o linker_format.o dlfcn.o zlib.o metsrv_rtld.o diff --git a/external/source/meterpreter/workspace/Makefile b/external/source/meterpreter/workspace/Makefile index a90403005f..4c4b540c47 100644 --- a/external/source/meterpreter/workspace/Makefile +++ b/external/source/meterpreter/workspace/Makefile @@ -1,6 +1,6 @@ SUBDIRS = common metsrv ext_server_stdapi ext_server_sniffer ext_server_networkpug -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 subdirs: for dir in $(SUBDIRS); do \ diff --git a/external/source/meterpreter/workspace/common/Makefile b/external/source/meterpreter/workspace/common/Makefile index dc378f3eee..77243345fa 100644 --- a/external/source/meterpreter/workspace/common/Makefile +++ b/external/source/meterpreter/workspace/common/Makefile @@ -18,7 +18,7 @@ CFLAGS+= -lgcc -L../../source/bionic/compiled CFLAGS+= -D_UNIX -I$(SOURCEPATH) -I$(MALLOC_PATH) -I$(XOR_PATH) -DMALLOC_PRODUCTION -DPIC -I$(SSLPATH) -I$(STDLIBPATH) -I$(ZLIB_PATH) CFLAGS+= -g -fPIC -Os -D_POSIX_C_SOURCE=200809 -D__BSD_VISIBLE=1 -D__XSI_VISIBLE=1 -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 CC=gcc diff --git a/external/source/meterpreter/workspace/ext_posix_sample/Makefile b/external/source/meterpreter/workspace/ext_posix_sample/Makefile index d35d93d1ac..baeb58fdf1 100644 --- a/external/source/meterpreter/workspace/ext_posix_sample/Makefile +++ b/external/source/meterpreter/workspace/ext_posix_sample/Makefile @@ -15,7 +15,7 @@ CFLAGS+= -lgcc -L../../source/bionic/compiled -gstabs+ CFLAGS+= -fPIC -Os CFLAGS+= -I../../source/extensions/stdapi/server -lc -lsupport -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 objects = test.o diff --git a/external/source/meterpreter/workspace/ext_server_networkpug/Makefile b/external/source/meterpreter/workspace/ext_server_networkpug/Makefile index 98be99affe..25ad5c42e0 100644 --- a/external/source/meterpreter/workspace/ext_server_networkpug/Makefile +++ b/external/source/meterpreter/workspace/ext_server_networkpug/Makefile @@ -16,7 +16,7 @@ CFLAGS+= -lgcc -L../../source/bionic/compiled -gstabs+ CFLAGS+= -fPIC -Os CFLAGS+= -I../../source/extensions/networkpug -lc -lpcap -lsupport -lmetsrv_main -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 #LDFLAGS= -fPIC -Bshareable -lc diff --git a/external/source/meterpreter/workspace/ext_server_sniffer/Makefile b/external/source/meterpreter/workspace/ext_server_sniffer/Makefile index 36d21676af..20f495862d 100644 --- a/external/source/meterpreter/workspace/ext_server_sniffer/Makefile +++ b/external/source/meterpreter/workspace/ext_server_sniffer/Makefile @@ -17,7 +17,7 @@ CFLAGS+= -fPIC -Os CFLAGS+= -I../../source/extensions/networkpug -lc -lpcap -lsupport -lmetsrv_main CFLAGS+= -I. -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 objects = sniffer.o diff --git a/external/source/meterpreter/workspace/ext_server_stdapi/Makefile b/external/source/meterpreter/workspace/ext_server_stdapi/Makefile index b8311ca2c8..3a2d495c83 100644 --- a/external/source/meterpreter/workspace/ext_server_stdapi/Makefile +++ b/external/source/meterpreter/workspace/ext_server_stdapi/Makefile @@ -15,7 +15,7 @@ CFLAGS+= -lgcc -L../../source/bionic/compiled -gstabs+ CFLAGS+= -fPIC -Os CFLAGS+= -I../../source/extensions/stdapi/server -lc -lsupport -lmetsrv_main -lpcap -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 #LDFLAGS= -fPIC -Bshareable -lc diff --git a/external/source/meterpreter/workspace/metsrv/Makefile b/external/source/meterpreter/workspace/metsrv/Makefile index 44196eb200..07435ee8d0 100644 --- a/external/source/meterpreter/workspace/metsrv/Makefile +++ b/external/source/meterpreter/workspace/metsrv/Makefile @@ -13,7 +13,7 @@ CFLAGS+= -Dwchar_t="char" -fno-builtin -D_SIZE_T_DECLARED -DElf_Size="u_int32_t" CFLAGS+= -D_BYTE_ORDER=_LITTLE_ENDIAN CFLAGS+= -lgcc -L../../source/bionic/compiled -gstabs+ -CFLAGS+= -march=i386 +CFLAGS+= -march=i386 -m32 OS=posix OSVPATH=../../source/common/arch/$(OS):../../source/server/linux/