Naga
v1.0.0-beta.1
一種在智能合約中檢測出越來越多的所有者的工具。
Naga需要Python 3.8.10,Solc-Select和Slither。
版本:3.8.10
我們使用Solc-Select來管理和切換Solc編譯器。
pip3 install solc-select安裝Solc所有版本
solc-select install all如果您無法使用命令solc-select ,請參見SET路徑。
Slither是用Python3編寫的堅固性靜態分析框架。 Naga根據Slither進行合同分析。
pip3 install slither-analyzer納迦(Naga)加載一個滑闆對象,以檢測合同中的倒載所有者。
sol_file = "your_contract.sol"
contract_name = None # You can specify the entry contract name, if None, Naga will automatically try to find the entry contract.
erc_force = None # erc20, erc721, erc777, None.
slither = Slither ( sol_file )
naga = Naga ( slither )
naga . detect_entry_contract ( er_force = erc_force ) # Detect the entry contract
entry_c = naga . entry_contract # Get the entry contract object
entry_c . output ( output_file = "output.json" ) # Output the result to output.json
summary = entry_c . output () # Or just get the summary
# You may want know the details of the result. you can print the state variables pool.
for sk , sv in naga . entry_contract . svarn_pool . items ():
print ( sv . canonical_name , sv ) naga/detectors/定義檢測器。您可以通過將其添加到naga/detectors/來註冊自己的探測器。
slither = Slither ( sol_file )
naga = Naga ( slither )
entry_c = naga . entry_contract
naga . detect ( entry_c , erc_force = None , detectors = []) # Specify the detectors you want to use
entry_c . output ( output_file = "output.json" )這是一個擁有超過100,000個合同的數據集。
請確保/home/your_username/.local/bin在$路徑中
您可以使用以下命令檢查和更新$路徑
echo $PATH
sudo vim /etc/profile
export PATH="/home/your_username/.local/bin:$PATH"
source /etc/profile