Skip to content

Commit 8d344e5

Browse files
committed
initial commit;
0 parents  commit 8d344e5

16 files changed

+1397
-0
lines changed

.gitignore

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
scan-input.txt
3+
scan-output.json
4+
scan-inputs
5+
scan-outputs
6+
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Runtime data
15+
pids
16+
*.pid
17+
*.seed
18+
*.pid.lock
19+
20+
# Directory for instrumented libs generated by jscoverage/JSCover
21+
lib-cov
22+
23+
# Coverage directory used by tools like istanbul
24+
coverage
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# TypeScript v1 declaration files
46+
typings/
47+
48+
# Optional npm cache directory
49+
.npm
50+
51+
# Optional eslint cache
52+
.eslintcache
53+
54+
# Optional REPL history
55+
.node_repl_history
56+
57+
# Output of 'npm pack'
58+
*.tgz
59+
60+
# Yarn Integrity file
61+
.yarn-integrity
62+
63+
# dotenv environment variables file
64+
.env
65+
.env.test
66+
67+
# parcel-bundler cache (https://parceljs.org/)
68+
.cache
69+
70+
# next.js build output
71+
.next
72+
73+
# nuxt.js build output
74+
.nuxt
75+
76+
# vuepress build output
77+
.vuepress/dist
78+
79+
# Serverless directories
80+
.serverless/
81+
82+
# FuseBox cache
83+
.fusebox/
84+
85+
# DynamoDB Local files
86+
.dynamodb/

DISCLAIMER.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### DISCLAIMER
2+
3+
The information within this project is intended to be used only in an
4+
ethical manner. Do not use any information from the project if you do
5+
not have written permission from the owner of the smart contract. If
6+
you perform illegal actions, you are likely to be arrested and
7+
prosecuted to the full extent of the law. We do not take any
8+
responsibility if you misuse any of the information contained within
9+
the project. The information herein must only be used while testing
10+
smart contracts with proper written authorizations from appropriate
11+
persons responsible.

LICENSE.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### LICENSE
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2019 Andrei Dimitrief-Jianu
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

README.md

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
### Ethereum scanner
2+
3+
The ethereum scanner is a free and open-source tool for contract exploration and discovery. The scanner supports regular expression queries that allow discovery of smart contracts with complex EVM patterns.
4+
5+
### Known issues
6+
7+
If using an ethereum client that does not run in full sync mode, there are some things you should be aware of:
8+
- the current block number of the network might be 0 (provider.getBlockNumber() method returns zero);
9+
- the contract balances displayed might not be accurate (provider.getBalance(contractAddress) returns zero);
10+
11+
Hence, the --block-end implicit value (the network block number) is not a valid block number, and the scan will fail. \
12+
Also, the --balance option will filter out contracts that might have a non-zero balance.
13+
14+
### Command line examples for hex
15+
16+
The hex utility can be easily used to generate a function signature.
17+
18+
```
19+
$ ./hex --input 'transferFrom(address,address,uint256)'
20+
hex 0x23b872dd7302113369cda2901243429419bec145408fa8b352b3dd92b66c680b
21+
$ ./hex --input 'transferFrom(address,address,uint256)' --signature
22+
hex 0x23b872dd
23+
```
24+
25+
### Command line examples for sc4nn3r
26+
27+
The --help option displays the available scan options.
28+
```
29+
$ ./scanner --help
30+
Usage: scanner [options]
31+
32+
Options:
33+
-V, --version output the version number
34+
--client <client> ethereum client (default: "localhost")
35+
--port <port> ethereum client rpc port
36+
--block-start <block> block number scan start
37+
--block-end <block> block number scan end
38+
--query <query> query to execute
39+
--query-file <file> file with query to execute
40+
--search-creation search the data on the creation transaction
41+
--search-runtime search the contract bytecode
42+
--balance search only for contracts with non-zero balance
43+
--output-file <file> file with list of contracts that matched the search criteria
44+
--status displays status info during the scan
45+
--verbose displays contract data during the scan
46+
--summary displays summary at the end of the scan
47+
-h, --help output usage information
48+
```
49+
Simple scan using a function signature in the query.
50+
```
51+
$ ./scanner --port 8545 --block-start 1 --block-end 1000 --query '<<transfer(address,uint256)>>'
52+
```
53+
Simple scan using a hexadecimal string in the query. Please note, the hexadecimal query supports regular expressions.
54+
```
55+
$ ./scanner --port 8545 --block-start 1 --block-end 1000 --query '<<0x21[0-9]{4}3131>>'
56+
```
57+
Scan with a function signature and a hexadecimal string.
58+
```
59+
$ ./scanner --port 8545 --block-start 1 --block-end 1000 --query '<<transfer(address,uint256)>> && ! <<0x21[0-9]{4}3131>>'
60+
```
61+
Scan and display a summary.
62+
```
63+
$ ./scanner --port 8545 --block-start 1 --block-end 1000 --output-file 'scan-output.json' --summary --query '<<transfer(address,uint256)>>'
64+
```
65+
Example of a simple scan output.
66+
```
67+
$ ./scanner --port 14545 --block-start 7264275 --block-end 7264290 --query '<<transfer(address,uint256)>>' --output-file './scan-outputs/scan-20190227-2318.json' --status --summary --search-creation
68+
69+
70+
client localhost
71+
port 14545
72+
block start 7264275
73+
block end 7264290
74+
query <<transfer(address,uint256)>>
75+
search creation bytecode true
76+
search runtime bytecode false
77+
displays status during scan
78+
displays summary at the end of the scan
79+
80+
81+
signer no password provided
82+
83+
84+
network homestead
85+
chain id 1
86+
block# 0
87+
88+
89+
start block 7264275
90+
end block 7264290
91+
query <<transfer(address,uint256)>>
92+
hexaized query <a9059cbb>
93+
94+
95+
current block 7264275
96+
current block 7264276
97+
current block 7264277
98+
current block 7264278
99+
current block 7264279
100+
current block 7264280
101+
current block 7264281
102+
current block 7264282
103+
current block 7264283
104+
current block 7264284
105+
106+
107+
match ---------------------------------------
108+
block number 7264284
109+
transaction hash 0xc9a3f0b1d777fff614ace40881f8b111673b913f463b53cd04bc193a372eff98
110+
contract address 0x5Bac8421aa6426B8B6A53C0cff5f198236484406
111+
owner address 0x6d1803F1E66d923253A7457fC03d23F5a8e20763
112+
transaction nonce 0
113+
transaction value 0
114+
contract balance 0
115+
current block 7264285
116+
current block 7264286
117+
current block 7264287
118+
119+
120+
match ---------------------------------------
121+
block number 7264287
122+
transaction hash 0x130214070b523ebd81e09da4d17511956d3ac42131da12b7c799c7be480bfae9
123+
contract address 0x89511Af1116384E096A9f0BD7175A627B839529C
124+
owner address 0xcDd37Ada79F589c15bD4f8fD2083dc88E34A2af2
125+
transaction nonce 1278
126+
transaction value 0
127+
contract balance 0
128+
current block 7264288
129+
current block 7264289
130+
current block 7264290
131+
132+
133+
scan summary --------------------------------
134+
135+
136+
contract 0x5Bac8421aa6426B8B6A53C0cff5f198236484406
137+
owner 0x6d1803F1E66d923253A7457fC03d23F5a8e20763
138+
block number 7264284
139+
transaction hash 0xc9a3f0b1d777fff614ace40881f8b111673b913f463b53cd04bc193a372eff98
140+
balance 0
141+
142+
143+
contract 0x89511Af1116384E096A9f0BD7175A627B839529C
144+
owner 0xcDd37Ada79F589c15bD4f8fD2083dc88E34A2af2
145+
block number 7264287
146+
transaction hash 0x130214070b523ebd81e09da4d17511956d3ac42131da12b7c799c7be480bfae9
147+
balance 0
148+
149+
150+
done.
151+
scan: 17260.040ms
152+
153+
```

hex

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
*
5+
* hex utility.
6+
* For any suggestions please contact me at andrei.dimitrief.jianu(at)gmail.com
7+
*
8+
* The MIT License (MIT)
9+
*
10+
* Copyright (c) 2019 Andrei Dimitrief-Jianu
11+
*
12+
* Permission is hereby granted, free of charge, to any person obtaining a copy
13+
* of this software and associated documentation files (the "Software"), to deal
14+
* in the Software without restriction, including without limitation the rights
15+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16+
* copies of the Software, and to permit persons to whom the Software is
17+
* furnished to do so, subject to the following conditions:
18+
*
19+
* The above copyright notice and this permission notice shall be included in all
20+
* copies or substantial portions of the Software.
21+
*
22+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28+
* SOFTWARE.
29+
*
30+
*/
31+
32+
const commander = require('commander');
33+
const ethers = require('ethers');
34+
35+
const printUtils = require('./utils/print-utils.js');
36+
37+
function validateCommandLine(commandLine)
38+
{
39+
if (!commandLine.input)
40+
{
41+
printUtils.printError('option \'--input <input>\' missing');
42+
process.exit();
43+
}
44+
}
45+
46+
async function main(commandLine)
47+
{
48+
validateCommandLine(commandLine);
49+
50+
let hex = ethers.utils.id(commandLine.input);
51+
if (commandLine.signature)
52+
{
53+
hex = hex.slice(0,10);
54+
}
55+
56+
printUtils.printToConsole('hex', 10, hex);
57+
}
58+
59+
commander
60+
.option('--input <input>', 'signature')
61+
.option('--signature', 'function signature')
62+
.parse(process.argv);
63+
64+
main(commander);

0 commit comments

Comments
 (0)