-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbatch_scan.py
53 lines (41 loc) · 1.19 KB
/
batch_scan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import json
import pandas as pd
import multiprocessing as mp
def scan(folder_path: str, file_name: str):
# main myth scanner
output = os.popen("cd %s && docker run -v $(pwd):/temp qspprotocol/mythril-usolc -xo json /temp/%s" % (folder_path, file_name), "r")
# turn result into string
result = output.read()
# remove the containers
return result
def loop(folder_path: str, save_path):
result_list = []
contracts = os.listdir(folder_path)
total_number = len(contracts)
error = 0
index = 0
for contract in contracts:
try:
result = scan(folder_path, contract)
name = save_path + contract[:-3] + "json"
with open(name, 'w') as f:
f.write(result)
print(f"{index}/{total_number} file scanned.")
except:
print("Error occured.")
error += 1
index += 1
if index % 10 == 0:
os.system("docker rm $(docker ps -aq)")
# if index >=3:
# break
# df = pd.DataFrame(result_list)
# df.to_csv('./eth_game.csv')
print("============================================")
print(f"{index} scanned, {error} failed.")
return 0
def print_hello(content):
print(content)
if __name__ == '__main__':
loop('contract/eth/highrisk', 'contract/eth/highrisk_result/')