Skip to content

Commit 4447c86

Browse files
committed
add deps.sh
1 parent dfc0699 commit 4447c86

File tree

2 files changed

+68
-10
lines changed

2 files changed

+68
-10
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
patchkit
22
----
3-
43
Patches an ELF binary using one or more simple Python scripts.
54

65
Usage:
@@ -10,13 +9,11 @@ Usage:
109

1110
patchdir
1211
----
13-
1412
Contains one or more Python patch files, which will be executed in alphabetical order against a binary.
1513

1614

1715
Patch Example
1816
----
19-
2017
def patch(pt):
2118
# nop out a jump at the entry point
2219
pt.patch(pt.entry, hex='90' * 5)
@@ -30,7 +27,6 @@ Patch Example
3027

3128
API
3229
----
33-
3430
addr = search(data)
3531
hook(addr, new_addr)
3632
patch(addr, *compile arg*)
@@ -46,7 +42,6 @@ API
4642

4743
IDA scripts
4844
----
49-
5045
Some scripts live in the ida/ path. Run them like this:
5146

5247
/Applications/IDA\ Pro\ 6.8/idaq.app/Contents/MacOS/idaq64 -A -B -Sida/allfuncs.py a.out
@@ -56,14 +51,16 @@ When invoked like this, allfuncs.py will generate `a.out.funcs` which is used by
5651

5752
Tools
5853
----
54+
These are somewhat CGC and x86-specific right now, but will be ported for general use in the future.
55+
5956
- explore: uses a Python CFG and recursive backtracking emulator to find basic blocks in an executable
6057
- bindiff: uses the block boundaries from an explore run, as well as additional analysis to find and output basic block diffs between two binaries
6158

6259

6360
Dependencies
6461
----
65-
* Capstone Engine - https://github.com/aquynh/capstone.git
66-
* Keystone Engine - https://github.com/keystone-engine/keystone.git
67-
* Unicorn Engine - https://github.com/unicorn-engine/unicorn.git
68-
* Python bindings for the above: `cd bindings/python; sudo make install`
69-
* Python coding library: `pip install coding`
62+
- Python coding library: `pip install coding`
63+
- Run `./deps.sh` to automatically install these.
64+
- Capstone Engine - https://github.com/aquynh/capstone.git
65+
- Keystone Engine - https://github.com/keystone-engine/keystone.git
66+
- Unicorn Engine - https://github.com/unicorn-engine/unicorn.git

deps.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash -u
2+
3+
echo
4+
echo "Take a look here if Unicorn fails to build:"
5+
echo " https://github.com/unicorn-engine/unicorn/blob/master/docs/COMPILE-NIX.md"
6+
echo
7+
echo "If you're on Ubuntu, you want to do this first:"
8+
echo " sudo apt-get update"
9+
echo " sudo apt-get install python-pip build-essential git cmake python-dev libglib2.0-dev"
10+
echo
11+
echo "If you're on a Mac, do this first:"
12+
echo " brew install pkg-config glib cmake"
13+
echo
14+
echo "Using ./build as a tmp dir. ^C if that's a bad idea."
15+
echo
16+
echo -n "[press enter to continue]"
17+
read
18+
echo
19+
20+
cwd=$(pwd)
21+
build="$cwd/build"
22+
23+
mkdir build &>/dev/null
24+
set -e
25+
26+
echo "[*] Building Keystone"
27+
cd "$build"
28+
git clone https://github.com/keystone-engine/keystone.git
29+
cd keystone && mkdir build && cd build
30+
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="all" -G "Unix Makefiles" .. && make -j2
31+
echo
32+
33+
echo "[*] Building Capstone"
34+
cd "$build"
35+
git clone https://github.com/aquynh/capstone.git
36+
cd capstone && make -j2
37+
echo
38+
39+
echo "[*] Building Unicorn"
40+
cd "$build"
41+
git clone https://github.com/unicorn-engine/unicorn.git
42+
cd unicorn && ./make.sh
43+
44+
echo
45+
echo "[*] Installing projects and Python bindings (using sudo)"
46+
cd "$build/keystone/build" && sudo make install
47+
cd "$build/keystone/bindings/python" && sudo make install
48+
49+
cd "$build/capstone" && sudo make install
50+
cd "$build/capstone/bindings/python" && sudo make install
51+
52+
cd "$build/unicorn" && sudo ./make.sh install
53+
cd "$build/unicorn/bindings/python" && sudo make install
54+
55+
which ldconfig &>/dev/null && sudo ldconfig
56+
57+
echo
58+
echo "All done! Don't forget to `sudo pip install coding`, or use a virtualenv if you're hip with that."
59+
echo
60+
echo -n "Testing Python import: "
61+
python -c "import capstone, keystone, unicorn; print 'works.'"

0 commit comments

Comments
 (0)