Skip to content

Commit

Permalink
Merge pull request #1 from AnwarMohamed/test
Browse files Browse the repository at this point in the history
Mac OS X Payload
  • Loading branch information
AnwarMohamed committed Jun 30, 2014
2 parents 76ce9db + 33d139c commit de57061
Show file tree
Hide file tree
Showing 234 changed files with 100,722 additions and 40 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all: osx-lib ios-lib

osx-lib:
make -C osx

ios-lib:
make -C ios

clean:
$(MAKE) clean -C osx
$(MAKE) clean -C ios

install:
$(MAKE) install -C osx
$(MAKE) install -C ios
2 changes: 2 additions & 0 deletions ios/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
clean:
64 changes: 24 additions & 40 deletions osx/Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,40 @@
framework_dir = ../metasploit-framework/
framework_dir =../../metasploit-framework

OUTPUT=.
CFLAGS=-g -Wall -fasm-blocks
CC=i686-apple-darwin10-gcc

CFLAGS+= -I metsrv/ -I common/ -I libdl/
CFLAGS+= -I ../include

all: run-bundle-all inject-bundle-all i386

i386:
$(MAKE) -C libdl && [ -f libdl/libdl-32.dylib ]
cp libdl/libdl-32.dylib $(OUTPUT)/libdl-32.dylib

CFLAGS=-g -Wall -fasm-blocks
CFLAGS+= -I metsrv/ -I common/
CFLAGS+= -fno-stack-protector
CFLAGS+= -fno-builtin -D_SIZE_T_DECLARED
CFLAGS+= -D_BYTE_ORDER=_LITTLE_ENDIAN
CFLAGS+= -march=i386 -m32

all: osx bin
osx:
$(MAKE) -C common && [ -f common/libsupport.dylib ]
cp common/libsupport.dylib $(OUTPUT)/libsupport.dylib

$(MAKE) -C metsrv && [ -f metsrv/libmetsrv.dylib ]
cp metsrv/libmetsrv.dylib $(OUTPUT)/libmetsrv.dylib

x86-64:
$(MAKE) -C extensions/stdapi && [ -f extensions/stdapi/ext_server_stdapi.dylib ]
cp extensions/stdapi/ext_server_stdapi.dylib $(OUTPUT)/ext_server_stdapi.dylib

inject-bundle-all: inject-bundle-32

inject-bundle-32:
$(CC) -I ./include -m32 -march=i386 inject-bundle.c -o inject-bundle

inject-bundle-64:
$(CC) -I ./include -m64 -march=x86-64 inject-bundle.c -o inject-bundle

run-bundle-all: run-bundle-32

run-bundle-32:
$(CC) -I ./include -m32 -march=i386 run-bundle.c -o run-bundle-32

run-bundle-64:
$(CC) -I ./include -m64 -march=x86-64 run-bundle.c -o run-bundle-64
bin:
$(CC) -m32 -march=i386 -ldl payloads/reverse_tcp_x86.c -o payloads/reverse_tcp_x86.bin

clean:
$(MAKE) clean -C libdl
$(MAKE) clean -C common
$(MAKE) clean -C metsrv
rm -rf inject-bundle-* run-bundle-*

test:
rm -rf reverse_tcp
$(CC) -m32 -march=i386 -L. -I./metsrv -lmetsrv reverse_tcp.c -o reverse_tcp
$(MAKE) clean -C extensions/stdapi
rm -rf *.dylib payloads/reverse_tcp_x86.bin

install:
rm -rf /usr/lib/libmetsrv.dylib
rm -rf /usr/lib/libsupport.dylib
rm -rf /usr/lib/libdl-32.dylib
cp libmetsrv.dylib /usr/lib/libmetsrv.dylib
cp libsupport.dylib /usr/lib/libsupport.dylib
cp libdl-32.dylib /usr/lib/libdl-32.dylib
rm -rf $(framework_dir)/data/meterpreter/ext_server_stdapi.dylib
rm -rf $(framework_dir)/data/osx/libmetsrv.dylib
rm -rf $(framework_dir)/data/osx/libsupport.dylib

cp $(OUTPUT)/ext_server_stdapi.dylib $(framework_dir)/data/meterpreter/ext_server_stdapi.dylib
cp $(OUTPUT)/libmetsrv.dylib $(framework_dir)/data/osx/libmetsrv.dylib
cp $(OUTPUT)/libsupport.dylib $(framework_dir)/data/osx/libsupport.dylib
cp payloads/reverse_tcp_x86.bin $(framework_dir)/data/osx/reverse_tcp_x86.bin
35 changes: 35 additions & 0 deletions osx/common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.SUFFIXES: .S .c

SOURCEPATH=.
SSL_PATH=../openssl/include
XOR_PATH=./crypto
ZLIB_PATH=./zlib

CFLAGS= -D_BYTE_ORDER=_LITTLE_ENDIAN -D_SIZE_T_DECLARED
CFLAGS+= -fno-builtin
CFLAGS+= -I$(SOURCEPATH) -I$(XOR_PATH) -I$(ZLIB_PATH) -I$(SSL_PATH)
CFLAGS+= -I.
CFLAGS+= -march=i386 -m32 -g -fPIC -Os -DPIC

objects = args.o base.o base_dispatch.o base_dispatch_common.o buffer.o \
channel.o common.o core.o list.o remote.o thread.o xor.o zlib.o

CFLAGS+= -fno-stack-protector

BASEVPATH=.:./crypto:./arch/posix:./zlib:
OSVPATH=./arch/posix
ARCHVPATH=./arch/posix
VPATH=$(BASEVPATH):$(OSVPATH):$(ARCHVPATH)

CFLAGS+= -I$(ARCHVPATH)

all: libsupport.dylib

libsupport.dylib: $(objects)
$(CC) $(CFLAGS) -dynamiclib $(objects) -L../../lib -lc -lssl -lcrypto -o $@

clean:
$(RM) -f *.o *.a *.dylib zlib/zlib.o

.PHONY: clean

8 changes: 8 additions & 0 deletions osx/common/arch/posix/base_dispatch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "common.h"

DWORD
remote_request_core_migrate(Remote *remote, Packet *packet)
{
return (EOPNOTSUPP);
}

64 changes: 64 additions & 0 deletions osx/common/arch/posix/buffer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <fcntl.h>
#include "common.h"

//#define errno 0

DWORD
buffer_from_file(LPCSTR filePath, PUCHAR *buffer, PULONG length)
{
int fd, res = 0;
off_t size;
char *buf = NULL;

if ((fd = open(filePath, O_RDONLY)) < 0) {
res = errno;
return (res);
}
/*
* find the end
*/
if ((size = lseek(fd, 0, SEEK_END)) < 0) {
res = errno;
goto done;
}
if ((res = lseek(fd, 0, SEEK_SET)) < 0) {
res = errno;
goto done;
}
if ((buf = malloc(size)) == NULL) {
res = ENOMEM;
goto done;
}
if (read(fd, buf, size) < size) {
res = errno;
free(buf);
}
done:
close(fd);
if (res == 0) {
if (buffer)
*buffer = buf;
else
free(buf);
if (length)
*length = size;
}
return (res);
}

DWORD
buffer_to_file(LPCSTR filePath, PUCHAR buffer, ULONG length)
{
int fd, res = 0;
off_t size;

if ((fd = open(filePath, O_CREAT|O_TRUNC|O_WRONLY, 0777)) < 0) {
res = errno;
return (res);
}
if (write(fd, buffer, length) < length)
res = errno;

close(fd);
return (res);
}
Loading

0 comments on commit de57061

Please sign in to comment.