diff --git a/external/source/meterpreter/source/openssl/build.sh b/external/source/meterpreter/source/openssl/build.sh index e6c64858a1..8babe2dc87 100755 --- a/external/source/meterpreter/source/openssl/build.sh +++ b/external/source/meterpreter/source/openssl/build.sh @@ -1,15 +1,34 @@ #!/bin/sh -OSSL=openssl-0.9.8o +set -e -pushd $OSSL -./Configure threads no-zlib no-krb5 386 --prefix=/tmp/out linux-msf no-dlfcn shared -popd +#OSSL=openssl-0.9.8o +OSSL=openssl-0.9.8n -export LIBC=../../bionic/libc -export LIBM=../../bionic/libm -export COMPILED=../../bionic/compiled +cd $OSSL + +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 +mv Configure-msf Configure +chmod +x Configure + +./Configure --prefix=/tmp/out threads shared no-hw no-dlfcn no-zlib no-krb5 no-idea 386 linux-msf +cd .. + + +# These have to be relative to PWD because the OpenSSL make system builds in +# multiple different levels of subdirs, so we can't just use ../../ +export LIBC=${PWD}/../bionic/libc +export LIBM=${PWD}/../bionic/libm +export COMPILED=${PWD}/../bionic/compiled + +export MSF_CFLAGS="-Os -Wl,--hash-style=sysv -march=i386 -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" + +# We don't need all the random executable utilities that 'all' builds, just the +# important .so files +#make -C $OSSL depend clean all + +make -C $OSSL depend clean build_libs -export CFLAGS="-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 -fPIC -DPIC -nostdinc -nostdlib -Dwchar_t='char' -fno-builtin -D_SIZE_T_DECLARED -DElf_Size='u_int32_t' -I${LIBM}/include -L${COMPILED} -D_BYTE_ORDER=_LITTLE_ENDIAN -lc" -make -C $OSSL depend clean all diff --git a/external/source/meterpreter/source/server/rtld/Makefile b/external/source/meterpreter/source/server/rtld/Makefile index db60c93f00..65d09027e0 100644 --- a/external/source/meterpreter/source/server/rtld/Makefile +++ b/external/source/meterpreter/source/server/rtld/Makefile @@ -3,7 +3,7 @@ CFLAGS=-I${PWD}/hack CFLAGS+= -I ../../bionic/libc/include -I ../../bionic/libc/kernel/common/linux/ -I ../../bionic/libc/kernel/common/ -I ../../bionic/libc/arch-x86/include/ CFLAGS+= -I ../../bionic/libc/kernel/arch-x86/ -I../../source/server/elf/headers -I../../bionic/libc/private -fPIC -DPIC CFLAGS+= -nostdinc -nostdlib -Dwchar_t="char" -fno-builtin -D_SIZE_T_DECLARED -DElf_Size="u_int32_t" -DANDROID_X86_LINKER -CFLAGS+= -ggdb +#CFLAGS+= -ggdb CFLAGS+= -DMETSRV_RTLD -D_BYTE_ORDER=_LITTLE_ENDIAN CFLAGS+= -march=i386 @@ -14,6 +14,7 @@ all: msflinker msflinker.bin rtldtest msflinker: $(OBJ) gcc -Wl,-script=script -Wl,--hash-style=sysv $(CFLAGS) -o msflinker $(OBJ) -lgcc + strip msflinker msflinker.bin: msflinker elf2bin.c gcc -o elf2bin elf2bin.c @@ -61,5 +62,5 @@ rtldtest: rtldtest.c msflinker clean: rm -f libmetsrv_main.h libssl.h libcrypto.h libm.h libc.h libsupport.h rm -f *.o - rm -f msflinker msflinker.so + rm -f msflinker msflinker.bin msflinker.so rm -f rtldtest elf2bin diff --git a/external/source/meterpreter/source/server/rtld/elf2bin.c b/external/source/meterpreter/source/server/rtld/elf2bin.c index 0a536c85ce..5b2f148698 100644 --- a/external/source/meterpreter/source/server/rtld/elf2bin.c +++ b/external/source/meterpreter/source/server/rtld/elf2bin.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) ehdr = (Elf32_Ehdr *)data; phdr = (Elf32_Phdr *)(data + ehdr->e_phoff); - printf("data @ %08x, mapping @ %08x\n", data, mapping); + printf("data @ %p, mapping @ %p\n", data, mapping); for(i = 0; i < ehdr->e_phnum; i++, phdr++) { if(phdr->p_type == PT_LOAD) { @@ -71,7 +71,7 @@ int main(int argc, char **argv) source = data + (phdr->p_offset & ~4095); dest = mapping + ((phdr->p_vaddr - base) & ~4095); len = phdr->p_filesz + (phdr->p_vaddr & 4095); - printf("memcpy(%08x, %08x, %08x)\n", dest, source, len); + printf("memcpy(%p, %p, %08x)\n", dest, source, len); memcpy(dest, source, len); used += (phdr->p_memsz + (phdr->p_vaddr & 4095) + 4095) & ~4095 ; diff --git a/external/source/meterpreter/source/server/rtld/linker_debug.h b/external/source/meterpreter/source/server/rtld/linker_debug.h index b468d068fa..29b9e6f213 100644 --- a/external/source/meterpreter/source/server/rtld/linker_debug.h +++ b/external/source/meterpreter/source/server/rtld/linker_debug.h @@ -29,7 +29,7 @@ #ifndef _LINKER_DEBUG_H_ #define _LINKER_DEBUG_H_ -#define LINKER_DEBUG 1 +#define LINKER_DEBUG 0 #include @@ -41,9 +41,9 @@ * or 0 to use stdout instead. */ #define LINKER_DEBUG_TO_LOG 0 -#define TRACE_DEBUG 1 -#define DO_TRACE_LOOKUP 1 -#define DO_TRACE_RELO 1 +#define TRACE_DEBUG 0 +#define DO_TRACE_LOOKUP 0 +#define DO_TRACE_RELO 0 /********************************************************************* * You shouldn't need to modify anything below unless you are adding