
イーサリアムブロックチェーンがC2に使用できるかどうか、またどのように使用できるかを探るためのPOC C2サーバーとエージェント
BlockchainC2は、攻撃者がC2にブロックチェーン(特にEthereumのスマートコントラクト機能)をどのように利用できるかを評価するための小さなPOCサーバー/エージェントです。
このアプリケーションの詳細はこちらで確認できます。
この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のいずれでも実行できるようにコンパイルできます。
brewを使用してMacOSでビルドする場合:
# 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/*
https://faucet.ropsten.be/ を使用して、Ropstenテストネット上のウォレットにEtherを追加できます。
たとえば、キーチェーンを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
保留中のトランザクションによるエラーを回避するには、エージェントに新しいアカウントを使用することをお勧めします。