
एक POC C2 सर्वर और एजेंट यह पता लगाने के लिए कि क्या और कैसे Ethereum ब्लॉकचेन का उपयोग C2 के लिए किया जा सकता है
BlockchainC2 एक छोटा POC सर्वर/एजेंट है जो यह आकलन करने के लिए है कि कैसे ब्लॉकचेन (विशेष रूप से Ethereum का स्मार्ट कॉन्ट्रैक्ट कार्यक्षमता) का उपयोग C2 के लिए हमलावर द्वारा किया जा सकता है।
इस एप्लिकेशन के संबंध में विवरण यहाँ पाए जा सकते हैं।
इस POC में उपयोग किया गया स्मार्ट कॉन्ट्रैक्ट काफी सरल है:
pragma solidity ^0.5.0;
contract EventC2 {
address owner;
event _ServerData(bool f, bool enc, int seq, string agentID, string data);
event _ClientData(bool f, bool enc, int seq, string agentID, string data);
constructor() public {
owner = msg.sender;
}
function AddClientData(string memory agentID, string memory d, int id, bool f, bool enc) public {
emit _ClientData(f, enc, id, agentID, d);
}
function AddServerData(string memory agentID, string memory d, int id, bool f, bool enc) public {
emit _ServerData(f, enc, id, agentID, d);
}
}
इस Solidity कोड का ध्यान सर्वर और कई क्लाइंट के बीच इवेंट के रूप में संदेश पास करना है।
BlockchainC2 को MacOS/Linux पर चलाने के लिए डिज़ाइन किया गया है, लेकिन एजेंट को MacOS, Windows, या Linux पर निष्पादित करने के लिए संकलित किया जा सकता है।
MacOS पर brew का उपयोग करके बिल्ड करने के लिए:
# Install solidity and ethereum
brew tap ethereum/ethereum
brew install ethereum
brew install solidity
# Build
make all
Ubuntu पर बिल्ड करने के लिए:
# Install solidity and ethereum
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc ethereum
# Build
make all
Windows के लिए एजेंट को क्रॉस-कंपाइल करने के लिए:
CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" GOOS=windows go build blockchainc2/cmd/bc2agent
आपको एक खाता सेटअप करना होगा जिसका उपयोग सर्वर घटक द्वारा किया जा सके। ऐसा करने का सबसे आसान तरीका geth के साथ है:
geth account new --keystore /tmp/mykeystore/
cat /tmp/mykeystore/*
Ropsten टेस्टनेट पर अपने वॉलेट में ईथर जोड़ने के लिए https://faucet.ropsten.be/ का उपयोग करें।
अपने config.json में कीचेन जोड़ें, उदाहरण के लिए:
{
"Key": "{\"address\":\"ADDRESS\",\"crypto\":{\"cipher\":\"aes-128-ctr\",\"ciphertext\":\"CT\",\"cipherparams\":{\"iv\":\"IV\"},\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"n\":262144,\"p\":1,\"r\":8,\"salt\":\"06470fcc2121994e014f85e5ab9cdb3714c76b873a1f1186c3e623e87abc4a7a\"},\"mac\":\"SALT\"},\"id\":\"ID\",\"version\":3}",
"Endpoint": "wss://ropsten.infura.io/_ws",
"ContractAddress": "TODO_VIA_SETUP",
"GasPrice": 0
}
bc2server का उपयोग करके कॉन्ट्रैक्ट तैनात करने के लिए:
./bin/bc2server -config ./config.json -pass Passw0rd -setup
एक बार कॉन्ट्रैक्ट तैनात हो जाने के बाद, अपने config.json में पता जोड़ें और सर्वर को इस प्रकार प्रारंभ करें:
./bin/bc2server -config ./config.json -pass Passw0rd
सर्वर चलने के साथ, एजेंटों को इस प्रकार जोड़ा जा सकता है:
./bin/bc2agent -config ./agent_config.json -pass Passw0rd
यह अनुशंसा की जाती है कि लंबित लेन-देन की त्रुटियों से बचने के लिए एजेंट के लिए एक नए खाते का उपयोग किया जाए।