Skip to content

Commit e93cdc2

Browse files
committed
Initial release
1 parent 49f5cf1 commit e93cdc2

File tree

81 files changed

+8491
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8491
-22
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
push:
3+
tags:
4+
- '*'
5+
jobs:
6+
create_release:
7+
name: Create GitHub Release
8+
runs-on: ubuntu-latest
9+
outputs:
10+
upload_url: ${{ steps.create_release.outputs.upload_url }}
11+
permissions:
12+
contents: write # To checkout repo and to create release
13+
steps:
14+
- name: Create GitHub Release
15+
id: create_release
16+
uses: actions/create-release@v1
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
with:
20+
tag_name: ${{ github.ref }}
21+
release_name: GAIT release ${{ github.ref }}
22+
draft: false
23+
prerelease: false
24+
build-matrix:
25+
needs: create_release # we need to know the upload URL
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write # To checkout repo and to create release
29+
strategy:
30+
matrix:
31+
ghidra_version: ['11.1.2', '11.1.1', '11.1', '11.0.3', '11.0.2', '11.0.1', '11.0']
32+
steps:
33+
- name: checkout repo
34+
uses: actions/checkout@v3
35+
- name: Extract tag name
36+
id: tag
37+
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
38+
- name: build
39+
env:
40+
GHIDRA_VERSION: ${{ matrix.ghidra_version }}
41+
run: docker compose up --exit-code-from build.service
42+
- name: Extract filename
43+
id: filename
44+
run: echo ::set-output name=ASSET_NAME::$(ls -AU plugin/AngrIntegration/dist | head -1)
45+
- name: Upload Release Asset
46+
id: upload-release-asset
47+
uses: actions/upload-release-asset@v1
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
upload_url: ${{ needs.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
52+
asset_path: plugin/AngrIntegration/dist/${{ steps.filename.outputs.ASSET_NAME }}
53+
asset_name: ghidra-angr-integration-tool-${{ steps.tag.outputs.TAG_NAME }}-ghidra_${{ matrix.ghidra_version }}.zip
54+
asset_content_type: application/zip

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv/
2+
__pycache__/
3+
angr/

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Current File",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": false
14+
}
15+
]
16+
}

.vscode/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"python.analysis.autoImportCompletions": false,
3+
"python.analysis.typeCheckingMode": "off", // disable pylance type hinting, when mypy does a better job
4+
"python.analysis.extraPaths": [
5+
"./plugin/AngrIntegration/data/architectures"
6+
],
7+
"[python]": {
8+
"editor.defaultFormatter": "ms-python.black-formatter",
9+
"editor.formatOnSave": true,
10+
"editor.codeActionsOnSave": {
11+
"source.organizeImports": "always"
12+
},
13+
},
14+
"isort.args": [
15+
"--profile",
16+
"black"
17+
],
18+
"mypy-type-checker.args": [
19+
"--disallow-untyped-calls",
20+
"--disallow-untyped-defs",
21+
"--strict",
22+
"--untyped-calls-exclude=angr",
23+
],
24+
"black-formatter.args": ["--line-length=120"],
25+
"autoDocstring.docstringFormat": "sphinx-notypes"
26+
}

DESIGN.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Project architecture
2+
3+
The main component of this tool is the Ghidra plugin, `AngrIntegrationPlugin` (in `plugin/AngrIntegration`). This creates a
4+
Ghidra UI Component (in `AngrIntegrationProvider`), and creates an `AngrInterface` which is responsible for communicating
5+
with angr. It also aquires the `ConsoleService` for printing to the console and wraps it in it's own methods for
6+
outputting data.
7+
8+
## `AngrInterface`
9+
10+
Responsible for running scripts for the plugin. Stores the paths to python and keeps track of currently running worker
11+
threads.
12+
13+
When the `AngrIntegrationProvider` tells the interface to run angr, a `Process` is created, which corresponds to an
14+
actually running instance of Python (in the venv). This is passed to a Swing `SwingWorker`, which polls the
15+
stdin/out/err every 20ms for new output. If there is new output, it will send it to either the REPL or the console,
16+
depending on if the REPL is active or not.
17+
18+
The `AngrInterface` is also responsible for interpreteting several special commands the python process can send, which are
19+
all prefixed by a string that's unlikely to be hit normally (currently "`!<*`"). These can do things like send status
20+
updates to the UI, or cause the `AngrInterface` to create the REPL window and start sending data to that instead.
21+
22+
If the REPL is active, it will call `checkSendInput` on the `AngrREPL` object every 20ms, which forwards updates from
23+
the user down the pipes to the angr process.
24+
25+
## `AngrIntegrationProvider`
26+
27+
High level component for the UI. Constructs each tab of the UI, registers event handlers, and does any other UI setup
28+
that needs doing. The tables, components that are shown or hidden by buttons, and Hook panels are delegated to other
29+
classes due to their complexity.
30+
31+
Shows status reports from the `AngrInterface` next to the run button. Receives events from the `AngrIntegrationPlugin`
32+
when the program is changed, to allow the various components to adjust.
33+
34+
When the run button is clicked, the `Provider` gathers all the fields from the UI into a `AngrConfiguration` object,
35+
which is serialized and written to a file in `/tmp`. Then the `AngrInterface` invokes the `angr_main` script, which
36+
reads that file and uses it to run angr!
37+
38+
## `GoalView` and `StateView`
39+
40+
These subclass Ghidra's `OptionalComponent` which is an abstract class that defines a component that can be shown, and also respond to events when the program is changed or readied. These are used to define the components in the UI when the corresponding button is selected for exploration goal or entry point respectively. When it's time to construct the `AngrConfiguration`, the `getConfig` function is called on them which should return the `ExplorationGoal` or `EntryPoint` that should be written to the `AngrConfiguration`.
41+
42+
Each `_GoalView` corresponds to a `_Goal` that represents that goal in an `AngrConfiguration`, and respectively for `_StateView`.
43+
44+
## `Table` and `TableModel`
45+
46+
These are just specialisations of `JTable`s and `TableModel`s that configure the table to fit our needs.
47+
48+
## `HookView`
49+
50+
This component draws the edit panel for an individual hook. Unlike most of the UI, changes made in the UI are
51+
immediately written to an underlying array of `Hook`s, which means that only one `HookView` needs to exist.
52+
53+
## `AngrREPL`
54+
55+
Wraps a `InterpreterComponentProvider` in a small interface for reading and writing to it.
56+
57+
## Python
58+
59+
### `get_angr_version`
60+
61+
Invoked by the plugin when loading or the venv changes, to check that the correct version of angr is loaded.
62+
63+
### `angr_main`
64+
65+
The main entry point to angr in the plugin. This reads a passed in data file, which should be a JSON object created from
66+
the `AngrInterface`, which defines everything that's been written into the UI.
67+
68+
This does some setup, which includes using the `symbolic_field` module to construct symbolic variables and constraints
69+
from provided python strings, and inserting the progress reporter `ExplorationTechinique` from `progress_reporter`,
70+
which periodically writes progress reports which are picked up by the `AngrInterface` connected to stdout. It will also
71+
load the architecture definition from the provided config, which contains many hooks that can trigger across the whole
72+
process.
73+
74+
Then it runs the main angr process, which should probably take a while! When done, it will print some cursory
75+
information about the recovered states and, if configured to do so, signal the interface to move to a REPL before
76+
starting a repl interpreter itself.

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM gradle:jdk19
2+
3+
RUN apt-get update && apt-get install python3-pip -y && rm -rf /var/lib/apt/lists/*
4+
RUN bash -c "AIOHTTP_NO_EXTENSIONS=1 pip3 install pygithub"
5+
6+
COPY docker_build.py /docker_build.py
7+
8+
CMD [ "python3", "-u", "/docker_build.py" ]

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)