
이더리움 블록체인이 C2에 사용될 수 있는지/어떻게 사용될 수 있는지를 탐구하기 위한 POC C2 서버 및 에이전트
BlockchainC2는 공격자가 C2(Command and Control)에 블록체인(특히 이더리움의 스마트 계약 기능)을 어떻게 사용할 수 있는지 평가하기 위한 작은 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
보류 중인 트랜잭션 관련 오류를 피하기 위해 에이전트에는 새 계정을 사용하는 것이 좋습니다.