Skip to content

Instantly share code, notes, and snippets.

Avatar
💭

vasa vasa-develop

💭
View GitHub Profile
View dependencies.sh
//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
View account.sol
pragma solidity ^0.4.19;
contract Account{
/* struct account{
string pubKey;
string priKey;
} */
struct account_user{
string pubKey;
View SetnGet.js
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);
View ipfs-cluster-dependencies.sh
//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
View serialize.sol
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);
View deserialize.js
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 = [];
View genesis.json
{
"config": {
"chainId": 1994,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0
},
"difficulty": "0x0",
"gasLimit": "0x8000000",
@vasa-develop
vasa-develop / EtherStore.sol
Created Jul 21, 2018
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
View EtherStore.sol
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 Jul 21, 2018
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
View Attack.sol
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
View EtherStore.sol
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;
}