
Un servidor y agente C2 de POC para explorar exactamente si/cómo se puede utilizar la cadena de bloques de Ethereum para C2.
BlockchainC2 es un pequeño servidor/agente POC para evaluar cómo la Blockchain (específicamente la funcionalidad de Smart Contracts de Ethereum) puede ser utilizada por un atacante para C2.
Los detalles sobre esta aplicación se pueden encontrar aquí.
El Smart Contract utilizado en este POC es bastante simple:
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);
}
}
El objetivo de este código Solidity es pasar eventos entre un servidor y múltiples clientes en forma de eventos.
BlockchainC2 fue diseñado para ejecutarse en MacOS/Linux, pero el agente puede compilarse para ejecutarse en MacOS, Windows o Linux.
Para compilar en MacOS usando brew:
# Install solidity and ethereum
brew tap ethereum/ethereum
brew install ethereum
brew install solidity
# Build
make all
Para compilar en 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
Para compilar de forma cruzada un agente para Windows:
CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" GOOS=windows go build blockchainc2/cmd/bc2agent
Necesitarás configurar una cuenta que pueda ser utilizada por el componente servidor. La forma más sencilla de hacerlo es con geth:
geth account new --keystore /tmp/mykeystore/
cat /tmp/mykeystore/*
Se puede añadir Ether a tu cartera en la testnet Ropsten usando https://faucet.ropsten.be/.
Añade el keychain a tu config.json, por ejemplo:
{
"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
}
Para desplegar un contrato usando bc2server:
./bin/bc2server -config ./config.json -pass Passw0rd -setup
Una vez que el contrato haya sido desplegado, añade la dirección a tu config.json e inicia el servidor con:
./bin/bc2server -config ./config.json -pass Passw0rd
Con el servidor en ejecución, los agentes pueden conectarse usando:
./bin/bc2agent -config ./agent_config.json -pass Passw0rd
Se recomienda usar una cuenta nueva para un agente para evitar errores con transacciones pendientes.