forked from Cisco-Talos/pyrebox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c7fb20
commit ac78eb3
Showing
15 changed files
with
833 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# ------------------------------------------------------------------------------- | ||
# | ||
# Copyright (C) 2017 Cisco Talos Security Intelligence and Research Group | ||
# | ||
# PyREBox: Python scriptable Reverse Engineering Sandbox | ||
# Author: Jonas Zaddach | ||
# Author: Xabier Ugarte-Pedrero | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
# MA 02110-1301, USA. | ||
# | ||
# ------------------------------------------------------------------------------- | ||
|
||
# CONFIGURATION PAMATERS | ||
# ...................... | ||
|
||
# BUFFER_SIZE: Guest agent buffer size used to copy data back and forth | ||
# AGENT_NAME: Base of the file name of the generated guest agent binaries | ||
# (and their corresponding configuration files. | ||
|
||
BUFFER_SIZE := 4096 | ||
|
||
AGENT_NAME := linux_agent | ||
|
||
#-------------------------------------------------------------------------------- | ||
|
||
CC := gcc | ||
CC32 := gcc | ||
CC64 := gcc | ||
|
||
CFLAGS_32 := -Iinclude/ -I../include -g -O0 -m32 | ||
CFLAGS_64 := -Iinclude/ -I../include -g -O0 | ||
|
||
DEFINES := -DMAX_BUFFER_SIZE=$(BUFFER_SIZE) | ||
|
||
all: $(AGENT_NAME)_32 $(AGENT_NAME)_64 | ||
|
||
32bit_test: test.c | ||
$(CC32) $(CFLAGS_32) $(DEFINES) -c -o test_32.o $< | ||
$(CC32) -m32 test_32.o -o test_32 | ||
|
||
64bit_test: test.c | ||
$(CC64) $(CFLAGS_64) $(DEFINES) -c -o test_64.o $< | ||
$(CC64) test_64.o -o test_64 | ||
|
||
%_32: guest_agent_32.o | ||
$(CC32) -m32 $^ -o $@ | ||
AGENT_NAME=$@ BUFFER_SIZE=$(BUFFER_SIZE) bash ./configure_offsets.sh | ||
%_64: guest_agent_64.o | ||
$(CC64) $^ -o $@ | ||
AGENT_NAME=$@ BUFFER_SIZE=$(BUFFER_SIZE) bash ./configure_offsets.sh | ||
|
||
%_32.o: %.c | ||
$(CC32) $(CFLAGS_32) $(DEFINES) -c -o $@ $< | ||
%_64.o: %.c | ||
$(CC64) $(CFLAGS_64) $(DEFINES) -DPYREBOX_GUEST_64 -c -o $@ $< | ||
|
||
.PHONY: clean dist-clean | ||
clean: | ||
rm -f $(AGENT_NAME)_32 | ||
rm -f $(AGENT_NAME)_64 | ||
rm -f *.o | ||
rm -f test_32 | ||
rm -f test_64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Compiling guest agent | ||
===================== | ||
|
||
Just compile with ``make``. | ||
|
||
You may need to install the following packages. For example, on Ubuntu, or Debian: | ||
:: | ||
apt-get install libc6-dev-i386 | ||
|
||
Compiling test files | ||
==================== | ||
|
||
In order to compile the test files, just use the provided Makefile as follows: | ||
:: | ||
make test_32 | ||
make test_64 | ||
|
||
Configuring guest agent | ||
======================= | ||
|
||
- Add `plugins.guest_agent: True` to your pyrebox.conf | ||
- (Optionally) modify your guest agent file name. | ||
- Add the agent configuration to your pyrebox.conf | ||
- Adjust the configuration appropriately (if you changed the agent file name). | ||
- Make sure the agent conf file exists and is up to date. This file is automatically | ||
generated by the compilation process. | ||
- Copy the corresponding guest agent (32 or 64 bit version) to the guest VM, and make | ||
sure it follows the same name as declared in the configuration name. | ||
- Start the agent (you can configure the VM to start the agent on every system start-up). | ||
- Once the agent is started, you can take a snapshot. | ||
|
||
Example configuration of guest agent in pyrebox.conf: | ||
:: | ||
[AGENT] | ||
name: linux_agent_64 | ||
conf: linux_agent_64.conf | ||
|
||
|
||
Using guest_agent | ||
================= | ||
|
||
In scripts: | ||
|
||
- Add ``plugins.guest_agent: True`` to your pyrebox.conf, or: | ||
- Add a member to your module named "requirements" containing a | ||
list of required plugins/scripts. E.g.: ``requirements = ["plugins.guest_agent"]`` | ||
- Import the plugin with ``from plugins.guest_agent import guest_agent`` in your script. | ||
- Interact with the guest agent using the public interface of this class (agent is | ||
a singleton instance of GuestAgentPlugin). | ||
|
||
In the IPython shell: | ||
|
||
- If no script is loading the guest_agent plugin, you will need to make sure it | ||
gets loaded by adding ``plugins.guest_agent: True`` to your pyrebox.conf. | ||
- Interact with the guest agent using the global member ``agent`` that is a singleton | ||
instance of GuestAgentPlugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# ------------------------------------------------------------------------------- | ||
# | ||
# Copyright (C) 2017 Cisco Talos Security Intelligence and Research Group | ||
# | ||
# PyREBox: Python scriptable Reverse Engineering Sandbox | ||
# Author: Jonas Zaddach | ||
# Author: Xabier Ugarte-Pedrero | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
# MA 02110-1301, USA. | ||
# | ||
# ------------------------------------------------------------------------------- | ||
|
||
#This script extracts the relative position of the global buffer named agent_buffer | ||
#that is used to copy data back and forth between the host and the guest, as well | ||
#as its size (that is configured in the Makefile). | ||
|
||
#This approach allows the pyrebox guest_agent plugin to check the boundaries of the buffer | ||
#before each write operation in order to prevent overflows and arbitrary memory writes. | ||
|
||
echo "[BUFFER]" > ../../${AGENT_NAME}.conf | ||
echo "BufferOffset: " $((16#`nm ${AGENT_NAME} | grep "agent_buffer" | awk '{ print $1 }'`)) >> ../../${AGENT_NAME}.conf | ||
echo "BufferSize: " ${BUFFER_SIZE} >> ../../${AGENT_NAME}.conf |
Oops, something went wrong.