
वेबअसेंबली मॉड्यूल (wasm) और ब्लॉकचेन स्मार्ट कॉन्ट्रैक्ट्स (BTC/ETH/NEO/EOS) के लिए सुरक्षा विश्लेषण उपकरण
इस प्रोजेक्ट को प्रायोजित करने के लिए QuoScient का बहुत-बहुत धन्यवाद।
Octopus WebAssembly मॉड्यूल और ब्लॉकचेन स्मार्ट कॉन्ट्रैक्ट के लिए एक सुरक्षा विश्लेषण ढांचा है।
Octopus का उद्देश्य बंद-स्रोत WebAssembly मॉड्यूल और स्मार्ट कॉन्ट्रैक्ट के बाइटकोड का विश्लेषण करने का एक आसान तरीका प्रदान करना है, ताकि उनके आंतरिक व्यवहार को गहराई से समझा जा सके।
Octopus निम्नलिखित प्रकार के प्रोग्राम/स्मार्ट कॉन्ट्रैक्ट का समर्थन करता है:
| BTC | ETH (EVM) | ETH (WASM) | EOS | NEO | WASM | ||
|---|---|---|---|---|---|---|---|
| एक्सप्लोरर | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ⭕ | |
| डिसअसेंबलर | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| नियंत्रण प्रवाह विश्लेषण | ✖️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| कॉल प्रवाह विश्लेषण | ✖️ | ➕ | ✔️ | ✔️ | ➕ | ✔️ | |
| IR रूपांतरण (SSA) | ✖️ | ✔️ | ➕ | ➕ | ✖️ | ✔️ | |
| प्रतीकात्मक निष्पादन | ✖️ | ➕ | ➕ | ➕ | ✖️ | ➕ |
✔️ पूर्ण / ➕ कार्य प्रगति पर / ✖️ बाकी / ⭕ लागू नहीं
Octopus Linux (आदर्श रूप से Ubuntu 16.04) पर समर्थित है और इसे Python >=3.5 (आदर्श रूप से 3.6) की आवश्यकता है।
निर्भरताएँ:
sudo apt-get update && sudo apt-get install python-pip graphviz xdg-utils -y
- Octopus इंस्टॉल करें:```
# Download Octopus
git clone https://github.com/pventuzelo/octopus
cd octopus
# Install Octopus library/CLI and its dependencies
python3 setup.py install
या```
pip3 install octopus
- परीक्षण चलाएँ```
# Run tests for all platforms (disassembly, CFG, ...)
./run_tests.sh
# Run tests that require internet access (explorer tests)
./run_explorer_tests.sh
# Run tests for only one platforms
# {btc, eth, eos, neo, wasm}_run_tests.sh
cd octopus/tests/
./wasm_run_tests.sh
एक डॉकर कंटेनर जो टूलसेट प्रदान करता है, docker hub पर उपलब्ध है। टर्मिनल में, निम्नलिखित कमांड चलाएँ:``` docker pull smartbugs/octopus docker run -it smartbugs/octopus cd octopus python3 octopus_eth_evm.py -s -f examples/ETH/evm_bytecode/61EDCDf5bb737ADffE5043706e7C5bb1f1a56eEA.bytecode
## कमांड-लाइन टूल्स
* WebAssembly: [octopus_wasm.py](https://github.com/fuzzinglabs/octopus/blob/master/octopus_wasm.py)
* Ethereum (EVM): [octopus_eth_evm.py](https://github.com/fuzzinglabs/octopus/blob/master/octopus_eth_evm.py)
## APIs का उपयोग करके गहन उदाहरण
<details><summary>WebAssembly</summary>
<p>
#### डिस्सेम्बलर
एक Wasm मॉड्यूल का डिसअसेंबली:```python
from octopus.arch.wasm.disassembler import WasmDisassembler
FILE = "examples/wasm/samples/helloworld.wasm"
with open(FILE, 'rb') as f:
module_bytecode = f.read()
disasm = WasmDisassembler()
# return list of functions instructions (list)
print(disasm.disassemble_module(module_bytecode))
#[[<octopus.arch.wasm.instruction.WasmInstruction at 0x7f85e4904278>,<octopus.arch.wasm.instruction.WasmInstruction at 0x7f85e4904f60>,<octopus.arch.wasm.instruction.WasmInstruction at 0x7f85e4904ef0>]]
print()
# return text of functions code
print(disasm.disassemble_module(module_bytecode, r_format='text'))
# func 0
# i32.const 0
# call 0
# end
wasm बाइटकोड का डिसअसेंबली:```python from octopus.arch.wasm.disassembler import WasmDisassembler
bytecode = b'\x02\x7fA\x18\x10\x1cA\x00\x0f\x0b'
disasm = WasmDisassembler(bytecode)
print(disasm.disassemble())
#[<octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904eb8>, <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904278>, <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904390>, <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904ef0>, <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904f60>, <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4901048>] print() print(disasm.disassemble(r_format='reverse'))
#{0: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4901048>, 1: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904240>, 2: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904f60>, 3: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904ef0>, 4: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904278>, 5: <octopus.arch.wasm.instruction.WasmInstruction object at 0x7f85e4904390>} print() print(disasm.disassemble(r_format='text'))
#### ModuleAnalyzer```python
from octopus.arch.wasm.analyzer import WasmModuleAnalyzer
FILE = "examples/wasm/samples/hello_wasm_studio.wasm"
with open(FILE, 'rb') as f:
module_bytecode = f.read()
# return list of functions instructions (list)
# attributes analysis=True by default
analyzer = WasmModuleAnalyzer(module_bytecode)