Skip to content

Commit 5284b88

Browse files
committed
Merge branch 'merge-mui-server'
* merge-mui-server: (32 commits) [Server] Fix README on usage and installation directions [Server] Remove duplicated dependency [Server] Add notes about duplicated CLI parsing [Server] Support PEP 518 minimum build requirements [Server] Use logger for messages [Server] Fix linting commands [Server] Add CI [Server] Manticore black exclude formatting of server [Server] Remove test binaries [Server] Remove all references to "MUI" [Server] Fixes to dependency and project setup [Server] Add .gitignore, add missing dev-requirement (#101) [Server] Support manual state control (Pause/Kill) (#96) [Server] Add explicit field presence (#88) [Server] Implement native Unicorn emulate until address (#86) [Server] Fix some justfile commands Fix broken CI paths, update documentation [Server] Add tests for starting execution with hooks [Ghidra] Support find/avoid for stateless server [Server] Support all hooks as StartNative field ...
2 parents 568b7b2 + a903ffa commit 5284b88

22 files changed

+3012
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,36 @@ jobs:
115115
env:
116116
COVERALLS_PARALLEL: true
117117
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
119+
manticore-server:
120+
runs-on: ubuntu-20.04
121+
steps:
122+
- uses: actions/checkout@v3
123+
124+
- uses: actions/setup-python@v4
125+
with:
126+
python-version: 3.7
127+
128+
- name: 'Install tools'
129+
run: |
130+
# just command runner https://github.com/casey/just#pre-built-binaries
131+
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to "${HOME}/.local/bin"
132+
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux
133+
sudo chmod +x /usr/bin/solc
134+
135+
- name: 'Lint MUI Server'
136+
working-directory: server
137+
run: |
138+
just init
139+
source venv/bin/activate
140+
just lint
141+
142+
- name: 'Test MUI Server'
143+
working-directory: server
144+
run: |
145+
source venv/bin/activate
146+
just test
147+
118148
# Send notification when all tests have finished to combine coverage results
119149
coverage-finish:
120150
needs: tests

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[tool.black]
22
target-version = ['py36']
33
line-length = 100
4+
extend-exclude = '''
5+
(
6+
venv
7+
| server # Has its own formatting
8+
)
9+
'''

server/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
manticore_server.egg-info/**
2+
**/__pycache__
3+
dist/**
4+
.mypy_cache/**

server/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Manticore Server
2+
Manticore Server is a gRPC service that acts as a wrapper around [Manticore](https://github.com/trailofbits/manticore), to support projects like the [Manticore User Interface (MUI)](https://github.com/trailofbits/ManticoreUI). Manticore Server is designed to allow developers to more easily create tools around Manticore that aren't in Python or to allow for Manticore to be run and managed in the cloud/remotely.
3+
4+
❗NOTE❗: The server is not published or packaged anywhere and is intended to be installed from source in a clean Python virtual environment. The server is only tested for compatibility with the version of Manticore living in the parent directory; this version of Manticore is installed when installing the server.
5+
6+
# Usage
7+
Create a new Python virtual environment:
8+
9+
```bash
10+
python3 -m venv venv
11+
source venv/bin/activate
12+
```
13+
14+
Install the server with `pip install .`. This will install Manticore from the parent directory.
15+
16+
The Manticore Server can be run via `manticore_server`, and it will run on port `50010`.
17+
18+
Your Manticore Server client will require the relevant gRPC client code. You can find out how to generate gRPC client code in your desired language from [the gRPC website](https://grpc.io/docs/languages/).
19+
20+
You may refer to the [Protobuf Specification](manticore_server/ManticoreServer.proto) for information about the RPC services provided and the message types.

server/justfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
init:
2+
test -d venv || python3 -m venv venv
3+
. venv/bin/activate; pip install -U setuptools pip wheel; pip install -e .[dev]
4+
5+
format:
6+
black .
7+
isort .
8+
9+
lint:
10+
black --check .
11+
isort --check .
12+
mypy
13+
14+
generate:
15+
python3 setup.py generate
16+
17+
build: generate
18+
#!/usr/bin/env bash
19+
set -euo
20+
mkdir -p dist
21+
py_ver=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
22+
python3 -m shiv -c manticore_server -o dist/manticore_server --reproducible --no-modify --python "/usr/bin/env python${py_ver}" --compressed .
23+
24+
test:
25+
python3 -m unittest tests/test_*.py
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
syntax = "proto3";
2+
3+
package manticore_server;
4+
5+
service ManticoreServer {
6+
rpc StartNative(NativeArguments) returns (ManticoreInstance) {}
7+
rpc StartEVM(EVMArguments) returns (ManticoreInstance) {}
8+
rpc Terminate(ManticoreInstance) returns (TerminateResponse) {}
9+
rpc GetStateList(ManticoreInstance) returns (ManticoreStateList) {}
10+
rpc GetMessageList(ManticoreInstance) returns (ManticoreMessageList) {}
11+
rpc CheckManticoreRunning(ManticoreInstance) returns (ManticoreRunningStatus) {}
12+
rpc StopServer(StopServerRequest) returns (StopServerResponse) {}
13+
rpc ControlState(ControlStateRequest) returns (ControlStateResponse) {}
14+
}
15+
16+
// LogMessage and StateList message types have "Manticore" in their names to distinguish them from those in mserialize
17+
18+
message ManticoreLogMessage {
19+
string content = 1;
20+
}
21+
22+
message ManticoreMessageList {
23+
repeated ManticoreLogMessage messages = 2;
24+
}
25+
26+
message ManticoreState {
27+
int32 state_id = 3;
28+
uint64 pc = 10;
29+
optional int32 parent_id = 28;
30+
repeated int32 children_ids = 29;
31+
}
32+
33+
message ManticoreStateList {
34+
35+
// state categories in Manticore - based on manticore enums StateStatus and StateList
36+
repeated ManticoreState active_states = 4;
37+
repeated ManticoreState waiting_states = 5;
38+
repeated ManticoreState forked_states = 6;
39+
repeated ManticoreState errored_states = 7;
40+
repeated ManticoreState complete_states = 8;
41+
repeated ManticoreState paused_states = 33;
42+
}
43+
44+
message ManticoreInstance {
45+
string uuid = 9;
46+
}
47+
48+
message TerminateResponse {}
49+
50+
message Hook {
51+
52+
enum HookType {
53+
FIND = 0;
54+
AVOID = 1;
55+
CUSTOM = 2;
56+
GLOBAL = 3;
57+
}
58+
59+
optional uint64 address = 26;
60+
HookType type = 27;
61+
optional string func_text = 31;
62+
}
63+
64+
message NativeArguments {
65+
string program_path = 11;
66+
repeated string binary_args = 16;
67+
repeated string envp = 17;
68+
repeated string symbolic_files = 18;
69+
optional string concrete_start = 19;
70+
optional string stdin_size = 20;
71+
optional string additional_mcore_args = 21;
72+
repeated Hook hooks = 30;
73+
optional uint64 emulate_until = 32;
74+
}
75+
76+
message EVMArguments {
77+
string contract_path = 12;
78+
string contract_name = 13;
79+
string solc_bin = 14;
80+
optional string tx_limit = 22;
81+
optional string tx_account = 23;
82+
repeated string detectors_to_exclude = 24;
83+
optional string additional_flags = 25;
84+
}
85+
86+
message ManticoreRunningStatus {
87+
bool is_running = 15;
88+
}
89+
90+
message StopServerRequest {}
91+
92+
message StopServerResponse {}
93+
94+
message ControlStateRequest {
95+
96+
enum StateAction {
97+
RESUME = 0;
98+
PAUSE = 1;
99+
KILL = 2;
100+
}
101+
102+
int32 state_id = 34;
103+
ManticoreInstance manticore_instance = 35;
104+
StateAction action = 36;
105+
}
106+
107+
message ControlStateResponse {}

server/manticore_server/ManticoreServer_pb2.py

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)