msuiche / porosity Goto Github PK
View Code? Open in Web Editor NEW*UNMAINTAINED* Decompiler and Security Analysis tool for Blockchain-based Ethereum Smart-Contracts
Home Page: https://www.comae.io
*UNMAINTAINED* Decompiler and Security Analysis tool for Blockchain-based Ethereum Smart-Contracts
Home Page: https://www.comae.io
I'm getting an executeInstruction: NOT_IMPLEMENTED for XOR, REVERT, and EXTCODESIZE.
Can you implement these opcodes?
ABI='[{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isbuyable","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"capaccount","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"ensureTXable","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_capaccount","type":"address"}],"name":"setCAPaccount","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_opexaccount","type":"address"}],"name":"setOPEXacount","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"buyPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_ratio","type":"uint256"}],"name":"setOPEXRatio","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"opexaccount","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_set","type":"bool"},{"name":"_finneyprice","type":"uint256"}],"name":"setIsBuyable","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"buy","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"opexratio","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"minimumBalanceInFinney","type":"uint256"}],"name":"setMinBalance","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_'rom","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"}]
BIN=0x606060405236156100f8576000357c01000000000000000000000000000000000000000000000000000000009004806318160ddd1461010157806323b872dd146101295780632c51302a1461016e57806349fc06be146101985780634a501381146101d6578063545743a8146101ea57806370a082311461020757806385ac9f6a146102385780638620410b146102555780638da5cb5b1461027d5780639c243f14146102bb5780639c38cd00146102d85780639dda87ac14610316578063a6f2ae3a1461033c578063a9059cbb1461034b578063b1c7a62314610387578063c91d956c146103af578063f2fde38b146103cc576100f8565b6100ff5b5b565b005b346100025761011360048050506103e9565b6040518082815260200191505060405180910390f35b346100025761015660048080359060200190919080359060200190919080359060200190919050506103f2565b60405180821515815260200191505060405180910390f35b34610002576101806004805050610533565b60405180821515815260200191505060405180910390f35b34610002576101aa6004805050610546565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34610002576101e8600480505061056c565b005b346100025761020560048080359060200190919050506105e1565b005b3461000257610222600480803590602001909190505061067f565b6040518082815260200191505060405180910390f35b346100025761025360048080359060200190919050506106bd565b005b3461000257610267600480505061075b565b6040518082815260200191505060405180910390f35b346100025761028f6004805050610764565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34610002576102d6600480803590602001909190505061078a565b005b34610002576102ea60048050506107f5565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b346100025761033a600480803590602001909190803590602001909190505061081b565b005b61034960048050506108cd565b005b346100025761036f6004808035906020019091908035906020019091905050610b8c565b60405180821515815260200191505060405180910390f35b34610002576103996004805050610cd4565b6040518082815260200191505060405180910390f35b34610002576103ca6004808035906020019091905050610cdd565b005b34610002576103e76004808035906020019091905050610d51565b005b60036000505481565b600081600660005060008673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060005054101580156104335750600082115b156105225781600660005060008573ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054019250508190555081600660005060008673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061052c5661052b565b6000905061052c565b5b9392505050565b600060149054906101000a900460ff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6007600050543373ffffffffffffffffffffffffffffffffffffffff163110156105de573373ffffffffffffffffffffffffffffffffffffffff166108fc6007600050549081150290604051809050600060405180830381858888f1935050505015156105dc57610002566105dd565b5b5b5b565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561063d57610002565b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c010000000000000000000000009081020402179055505b5b50565b6000600660005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000505490506106b8565b919050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561071957610002565b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c010000000000000000000000009081020402179055505b5b50565b60016000505481565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107e657610002565b806002600050819055505b5b50565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561087757610002565b81600060146101000a81548160ff02191690837f010000000000000000000000000000000000000000000000000000000000000090810204021790555066038d7ea4c6800081026001600050819055505b5b5050565b6000600060149054906101000a900460ff16151561094b57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051809050600060405180830381858888f19350505050151561094a57610002565b5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60026000505434811561000257049081150290604051809050600060405180830381858888f1935050505015156109bd57610002565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600260005054348115610002570434039081150290604051809050600060405180830381858888f193505050501515610a3157610002565b6001600050543481156100025704905080600660005060003373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055508060036000828282505401925050819055503373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60026000505484811561000257046040518082815260200191505060405180910390a35b50565b600081600660005060003373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000505410158015610bcd5750600082115b15610cc45781600660005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600660005060008573ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3610cb761056c565b60019050610cce56610ccd565b60009050610cce565b5b92915050565b60026000505481565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d3957610002565b66038d7ea4c6800081026007600050819055505b5b50565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dad57610002565b80600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c010000000000000000000000009081020402179055505b5b5056
The command I am using is:
./porosity --abi $ABI --code $BIN --decompile
But the output contains a lot of errors and I definitely get an impression that some parts of the code are missing, for example in the buy()
function:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x18160DDD
ERROR: JUMPI destination is null.
function totalSupply() {
return store_3;
}
LOC: 3
Hash: 0x23B872DD
ERROR: JUMPI destination is null.
function transferFrom(address,address,uint256) {
if (!(arg_44 > 0x0)) {
}
store[arg_24] = store[arg_24] + arg_44;
store[arg_4] = store[arg_4] - arg_44;
memory[0x40] = 0x1;
return memory[0x40];
}
LOC: 8
Hash: 0x2C51302A
ERROR: JUMPI destination is null.
function isbuyable() {
memory[0x40] = 0x0;
return memory[0x40];
}
LOC: 4
Hash: 0x49FC06BE
ERROR: JUMPI destination is null.
function capaccount() {
return store_4;
}
LOC: 3
Hash: 0x4A501381
ERROR: JUMPI destination is null.
executeInstruction: NOT_IMPLEMENTED: BALANCE
function ensureTXable() {
if (!store_7) {
}
return;
}
LOC: 5
Hash: 0x545743A8
ERROR: JUMPI destination is null.
function setCAPaccount(address) {
if (msg.sender == store_0) {
store[var_9Uy7y] = arg_4 * 0x1;
}
}
LOC: 5
Hash: 0x70A08231
ERROR: JUMPI destination is null.
function balanceOf(address) {
return store[arg_4];
}
LOC: 3
Hash: 0x85AC9F6A
ERROR: JUMPI destination is null.
function setOPEXacount(address) {
if (msg.sender == store_0) {
store[var_S4Af4] = arg_4 * 0x1;
}
}
LOC: 5
Hash: 0x8620410B
ERROR: JUMPI destination is null.
function buyPrice() {
return store_1;
}
LOC: 3
Hash: 0x8DA5CB5B
ERROR: JUMPI destination is null.
function owner() {
return store_0;
}
LOC: 3
Hash: 0x9C243F14
ERROR: JUMPI destination is null.
function setOPEXRatio(uint256) {
if (msg.sender == store_0) {
store[var_M9mx1] = arg_4;
}
}
LOC: 5
Hash: 0x9C38CD00
ERROR: JUMPI destination is null.
function opexaccount() {
return store_5;
}
LOC: 3
Hash: 0x9DDA87AC
ERROR: JUMPI destination is null.
function setIsBuyable(bool,uint256) {
if (msg.sender == store_0) {
store[var_ekIRj] = 0x60000000000000000000000000000000000000000;
store[var_HsnCA] = arg_24 * 0x38D7EA4C68000;
}
}
LOC: 6
Hash: 0xA6F2AE3A
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
function buy() {
if (!msg.value) {
}
}
LOC: 4
Hash: 0xA9059CBB
ERROR: JUMPI destination is null.
executeInstruction: NOT_IMPLEMENTED: BALANCE
executeInstruction: NOT_IMPLEMENTED: BALANCE
function transfer(address,uint256) {
if (!(arg_24 > 0x0)) {
}
store[msg.sender] = store[msg.sender] - arg_24;
store[arg_4] = store[arg_4] + arg_24;
if (!store_7) {
}
memory[0x40] = 0x1;
return memory[0x40];
}
LOC: 10
Hash: 0xB1C7A623
ERROR: JUMPI destination is null.
function opexratio() {
return store_2;
}
LOC: 3
Hash: 0xC91D956C
ERROR: JUMPI destination is null.
function setMinBalance(uint256) {
if (msg.sender == store_0) {
store[var_hO1Z4] = arg_4 * 0x38D7EA4C68000;
}
}
LOC: 5
Hash: 0xF2FDE38B
ERROR: JUMPI destination is null.
function transferOwnership(address) {
if (msg.sender == store_0) {
store[var_2kEWV] = arg_4 * 0x1;
}
}
LOC: 5
When generating graphviz output, if a block ends with REVERT
, porosity will link matching next block in the graph as if REVERT
doesn’t stop contract execution (as if execution continues after a revert opcode).
Given something like:
contract Paying
{
function sendIt(uint b) {
msg.sender.send(b);
}
}
We get the following output on a --decompile
run:
Attempting to parse ABI definition...
Success.
Hash: 0xEDA04C5E
function sendIt(uint256) {
if (!msg.value) {
}
return;
return;
}
LOC: 6
I'll probably look at this myself at some point.
I am attempting to decompile a smart contract's bytecode and it contains NUMBER and MSIZE in its opcodes. When I try to decompile, my terminal returns this and gets stuck
Now performing decompilation:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode command line decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Hash: 0x0D9F5AED
executeInstruction: NOT_IMPLEMENTED: NUMBER
executeInstruction: NOT_IMPLEMENTED: MSIZE
Any ideas why this is happening?
I tried to make it in Ubuntu14.04. However, I got the following error:
g++ -c -o BasicBlocks.o BasicBlocks.cpp
g++ -c -o VMState.o VMState.cpp
In file included from VMState.cpp:18:0:
Porosity.h:22:36: fatal error: boost/dynamic_bitset.hpp: No such file or directory
#include <boost/dynamic_bitset.hpp>
^
compilation terminated.
make: *** [VMState.o] Error 1
maxblock@mbp t1 $ ls -a
. .. t1.bin
maxblock@mbp t1 $ porosity --code-file t1.bin --list
parse: Please at least provide some byte code (--code) or run it in debug mode (--debug) with pre-configured inputs.
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Usage: porosity [options]
Debug:
--debug - Enable debug mode. (testing only - no input parameter needed.)
But if I use --code with data from the same file, it works:
maxblock@mbp t1 $ code=$(<t1.bin)
maxblock@mbp t1 $ porosity --code $code --list
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
[+] Hash: 0x0A19B14A () (1 references)
[+] Hash: 0x2E1A7D4D () (1 references)
[+] Hash: 0x338B5DEA () (1 references)
[+] Hash: 0x3A88360C () (1 references)
[+] Hash: 0x46BE96C3 () (1 references)
[+] Hash: 0x6851C6CE () (1 references)
P.S. Inside t1.bin there is one long line: 0x6060604052.....
Hi,
I have tried to decompile the contract in here https://etherscan.io/address/0x889930aD5b7ea9115e75C04c73209B76Ab70e8c6#code as an example.
But the decompiler gives an error:
Attempting to parse ABI definition...
terminate called after throwing an instance of 'std::invalid_argument'
what(): parse error - unexpected 'n'; expected end of input
I am attaching the files I use.
example.zip
With many contracts, we'll be stuck in a loop forever. Contract code example:
6060604052341561000c57fe5b5b73209c4784ab1e8183cf58ca33cb740efbf3fc18ef600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555073b42b20ddbeabdc2a288be7ff847ff94fb48d2579600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b6104a0806100c86000396000f30060606040523615610055576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063661172761461014857806382c90ac01461017e578063b76ea962146101b4575b6101465b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163460405180905060006040518083038185876187965a03f1925050501561013d577f23919512b2162ddc59b67a65e3b03c419d4105366f7d4a632f5d3c3bee9b1cff600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1610143565b60006000fd5b5b565b005b341561015057fe5b61017c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610225565b005b341561018657fe5b6101b2600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506102c8565b005b610223600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061036b565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156102825760006000fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103255760006000fd5b80600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c85760006000fd5b8173ffffffffffffffffffffffffffffffffffffffff1634826040518082805190602001908083836000831461041d575b80518252602083111561041d576020820191506020810190506020830392506103f9565b505050905090810190601f1680156104495780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876187965a03f192505050151561046e5760006000fd5b5b5b50505600a165627a7a7230582015dd8a30edc4d2b88e51c1e252cdc5a08cd0159c2d5d7b063fdaad85d6e813e40029
Contract::walkAndConnectNodes never finishes executing because it keeps recursively calling itself. Not quite sure yet why.
Calling printBlockReferences
just before, results in the following:
(dest = 0x00000000, numrefs = 0x00000000, refs = {}, JUMPI: 0x00000055, Default: 0x0000000B )
(dest = 0x0000000B, numrefs = 0x00000001, refs = {0x00000000}, JUMPI: 0x00000148, Default: 0x0000003F )
(dest = 0x0000003F, numrefs = 0x00000001, refs = {0x0000000b}, JUMPI: 0x0000017E, Default: 0x0000004A )
(dest = 0x0000004A, numrefs = 0x00000001, refs = {0x0000003f}, JUMPI: 0x000001B4, Default: 0x00000055 )
(dest = 0x00000055, numrefs = 0x00000002, refs = {0x000000000x0000004a}, Default: 0x00000059 )
(dest = 0x00000059, numrefs = 0x00000001, refs = {0x00000055}, JUMPI: 0x0000013D, Default: 0x000000B4 )
(dest = 0x000000B4, numrefs = 0x00000001, refs = {0x00000059}, Default: 0x00000143 )
(dest = 0x0000013D, numrefs = 0x00000001, refs = {0x00000059}, Default: 0x00000143 )
(dest = 0x00000143, numrefs = 0x00000002, refs = {0x000000b40x0000013d}, Default: 0x00000144 )
(dest = 0x00000144, numrefs = 0x00000001, refs = {0x00000143}, Default: 0xDEADBABE )
(dest = 0x00000146, numrefs = 0x00000000, refs = {}, Default: 0x00000000 )
(dest = 0x00000148, numrefs = 0x00000001, refs = {0x0000000b}, JUMPI: 0x00000150, Default: 0x0000014F , hash = 0x66117276, str = func_66117276, )
(dest = 0x0000014F, numrefs = 0x00000001, refs = {0x00000148}, Default: 0x00000150 )
(dest = 0x00000150, numrefs = 0x00000002, refs = {0x000001480x0000014f}, Default: 0x00000225 )
(dest = 0x0000017C, numrefs = 0x00000000, refs = {}, Default: 0x00000000 )
(dest = 0x0000017E, numrefs = 0x00000001, refs = {0x0000003f}, JUMPI: 0x00000186, Default: 0x00000185 , hash = 0x82C90AC0, str = func_82c90ac0, )
(dest = 0x00000185, numrefs = 0x00000001, refs = {0x0000017e}, Default: 0x00000186 )
(dest = 0x00000186, numrefs = 0x00000002, refs = {0x0000017e0x00000185}, Default: 0x000002C8 )
(dest = 0x000001B2, numrefs = 0x00000000, refs = {}, Default: 0x00000000 )
(dest = 0x000001B4, numrefs = 0x00000001, refs = {0x0000004a}, Default: 0x0000036B , hash = 0xB76EA962, str = func_b76ea962, )
(dest = 0x00000223, numrefs = 0x00000000, refs = {}, Default: 0x00000000 )
(dest = 0x00000225, numrefs = 0x00000001, refs = {0x00000150}, JUMPI: 0x00000282, Default: 0x0000027D )
(dest = 0x0000027D, numrefs = 0x00000001, refs = {0x00000225}, Default: 0x00000282 )
(dest = 0x00000282, numrefs = 0x00000002, refs = {0x000002250x0000027d}, Default: 0x000002C4 )
(dest = 0x000002C4, numrefs = 0x00000001, refs = {0x00000282}, Default: 0x000002C5 )
(dest = 0x000002C5, numrefs = 0x00000001, refs = {0x000002c4}, Default: 0xDEADBABE )
(dest = 0x000002C8, numrefs = 0x00000001, refs = {0x00000186}, JUMPI: 0x00000325, Default: 0x00000320 )
(dest = 0x00000320, numrefs = 0x00000001, refs = {0x000002c8}, Default: 0x00000325 )
(dest = 0x00000325, numrefs = 0x00000002, refs = {0x000002c80x00000320}, Default: 0x00000367 )
(dest = 0x00000367, numrefs = 0x00000001, refs = {0x00000325}, Default: 0x00000368 )
(dest = 0x00000368, numrefs = 0x00000001, refs = {0x00000367}, Default: 0xDEADBABE )
(dest = 0x0000036B, numrefs = 0x00000001, refs = {0x000001b4}, JUMPI: 0x000003C8, Default: 0x000003C3 )
(dest = 0x000003C3, numrefs = 0x00000001, refs = {0x0000036b}, Default: 0x000003C8 )
(dest = 0x000003C8, numrefs = 0x00000002, refs = {0x0000036b0x000003c3}, JUMPI: 0x0000041D, Default: 0x000003F9 )
(dest = 0x000003F9, numrefs = 0x00000002, refs = {0x000003c80x00000407}, JUMPI: 0x0000041D, Default: 0x00000407 )
(dest = 0x00000407, numrefs = 0x00000001, refs = {0x000003f9}, Default: 0x000003F9 )
(dest = 0x0000041D, numrefs = 0x00000002, refs = {0x000003c80x000003f9}, JUMPI: 0x00000449, Default: 0x00000430 )
(dest = 0x00000430, numrefs = 0x00000001, refs = {0x0000041d}, Default: 0x00000449 )
(dest = 0x00000449, numrefs = 0x00000002, refs = {0x0000041d0x00000430}, JUMPI: 0x0000046E, Default: 0x00000469 )
(dest = 0x00000469, numrefs = 0x00000001, refs = {0x00000449}, Default: 0x0000046E )
(dest = 0x0000046E, numrefs = 0x00000002, refs = {0x000004490x00000469}, Default: 0x0000046F )
(dest = 0x0000046F, numrefs = 0x00000001, refs = {0x0000046e}, Default: 0x00000470 )
(dest = 0x00000470, numrefs = 0x00000001, refs = {0x0000046f}, Default: 0xDEADBABE )
(dest = 0xDEADBABE, numrefs = 0x00000004, refs = {0x000001440x000002c50x000003680x00000470}, Default: 0x00000000 )
Which ends up in a loop between nodes 0x000003C8 -> 0x0000041D -> 0x00000449 -> 0x0000041D -> 0x000003C8 -> etc. So there's circular referencing going on, but I haven't been able to wrap my head around it yet.
After running it for a couple of iterations, this is the pattern that emerges:
CURRENT: 0000041D - NEXT: 0000046F - JUMPI: 00000000
CURRENT: 0000041D - NEXT: 00000470 - JUMPI: 00000000
CURRENT: 0000041D - NEXT: 00000223 - JUMPI: 00000000
CURRENT: 0000041D - NEXT: 00000000 - JUMPI: 00000000
CURRENT: 000003C8 - NEXT: 000003F9 - JUMPI: 00000000
CURRENT: 000003C8 - NEXT: 00000407 - JUMPI: 0000041D
CURRENT: 0000041D - NEXT: 00000430 - JUMPI: 00000449 <--\
CURRENT: 00000449 - NEXT: 00000469 - JUMPI: 0000046E |
CURRENT: 0000046E - NEXT: 0000046F - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000470 - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000223 - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000000 - JUMPI: 00000000 |
CURRENT: 00000449 - NEXT: 0000046E - JUMPI: 00000000 |
CURRENT: 00000449 - NEXT: 0000046F - JUMPI: 00000000 |
CURRENT: 00000449 - NEXT: 00000470 - JUMPI: 00000000 |
CURRENT: 00000449 - NEXT: 00000223 - JUMPI: 00000000 |
CURRENT: 00000449 - NEXT: 00000000 - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 00000449 - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 00000469 - JUMPI: 0000046E |
CURRENT: 0000046E - NEXT: 0000046F - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000470 - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000223 - JUMPI: 00000000 |
CURRENT: 0000046E - NEXT: 00000000 - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 0000046E - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 0000046F - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 00000470 - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 00000223 - JUMPI: 00000000 |
CURRENT: 0000041D - NEXT: 00000000 - JUMPI: 00000000 |
CURRENT: 000003C8 - NEXT: 000003F9 - JUMPI: 00000000 |
CURRENT: 000003C8 - NEXT: 00000407 - JUMPI: 0000041D ---/
CURRENT: 0000041D - NEXT: 00000430 - JUMPI: 00000449
CURRENT: 00000449 - NEXT: 00000469 - JUMPI: 0000046E
CURRENT: 0000046E - NEXT: 0000046F - JUMPI: 00000000
CURRENT: 0000046E - NEXT: 00000470 - JUMPI: 00000000
CURRENT: 0000046E - NEXT: 00000223 - JUMPI: 00000000
CURRENT: 0000046E - NEXT: 00000000 - JUMPI: 00000000
In README it's written:
Hence, the need for an open-source tool like Porosity
Please add the LICENSE.md if others are allowed to use this library.
Thanks for the good work.
Looks like no matter if I use the --code
or --code-file
arguments, it always outputs the same output:
ϟ porosity --code-file code --debug
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
function mint(address,uint256) {
if (msg.sender == store_0) {
store[arg_4] = arg_24 + store[arg_4];
}
return;
}
LOC: 6
function send(address,uint256) {
if (store[msg.sender] >= arg_24) {
store[msg.sender] = store[msg.sender] - arg_24;
store[arg_4] = arg_24 + store[arg_4];
}
return;
}
LOC: 7
function balances(address) {
return store[memory[0x20]];
}
LOC: 3
function minter() {
store_0 = 0x10000000000000000000000000000000000000000 - 0x1;
return store_0;
}
LOC: 4
Attempting to parse ABI definition...
Success.
function double(uint256) {
memory[0x60] = 0x2 * arg_4;
return memory[0x60];
}
LOC: 4
------------
function triple(uint256) {
memory[0x60] = 0x3 * arg_4;
return memory[0x60];
}
LOC: 4
After execution.
digraph porosity {
rankdir = TB;
size = "12"
graph[fontname = Courier, fontsize = 10.0, labeljust = l, nojustify = true];node[shape = record];
"0x00000000"[label = "loc_0x00000000"];
"0x00000000" -> "0x00000018" [color="red"];
"0x00000000" -> "0x00000024" [color="green"];
"0x00000018"[label = "loc_0x00000018"];
"0x00000018" -> "0x00000022" [color="red"];
"0x00000018" -> "0x00000035" [color="green"];
"0x00000022"[label = "loc_0x00000022"];
"0x00000024"[label = "double(uint256)"];
"0x00000024" -> "0x00000031" [color="black"];
"0x00000031"[label = "loc_0x00000031"];
"0x00000031" -> "0x0000004f" [color="black"];
"0x00000035"[label = "triple(uint256)"];
"0x00000035" -> "0x00000031" [color="black"];
"0x00000045"[label = "loc_0x00000045"];
"0x0000004f"[label = "loc_0x0000004f"];
"0x0000004f" -> "0x00000045" [color="black"];
}
Attempting to parse ABI definition...
Success.
function withdrawBalance() {
if (msg.sender.call.gas(1410031344).value()()) {
store[msg.sender] = 0x0;
}
}
L3 (D8193): Potential reentrant vulnerability found.
LOC: 5
function getBalance(address) {
return store[arg_4];
}
LOC: 3
function addToBalance() {
store[msg.sender] = store[msg.sender] + msg.value;
return;
}
LOC: 4
I even did chmod 000 code
on my code file in order to test if it's even reading from my file, and nothing changes.
I'm on MacOS.
I had to add this to Makefile
to get it to work:
CXX=g++ # or c++, clang works too
CXXFLAGS=-std=c++14
I also had to inline assertThrow
from Assert.h
into Instruction.h
because the compiler complained that it wasn't defined--my C++ knowledge is limited so I don't have a guess as to why.
Hi
I have tried to replicate the example you give here:
abi
and bin
files you give as example.decompile.sh
which initialize abi and bin variable with the content of the aforecreated files and which launches the porosity command to decompile the bin filedecompile.sh
Attempting to parse ABI definition...
terminate called after throwing an instance of 'std::invalid_argument'
what(): parse error - unexpected '"'
./decompile.sh: line 14: 14890 Aborted (core dumped) ../porosity --code $bin --abi $abi --list --verbose 0
I am attaching files.
output.zip
It seems disassembling this code shouln’t require block walking since it’s only for disassembling.
The bytecode below is being used in a deployed smart contract managing more than 700,000 ethers.
./porosity --abi '[{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"owners\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"removeOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"revokeConfirmation\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"isOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"address\"}],\"name\":\"confirmations\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"calcMaxWithdraw\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"pending\",\"type\":\"bool\"},{\"name\":\"executed\",\"type\":\"bool\"}],\"name\":\"getTransactionCount\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"dailyLimit\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"lastDay\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"addOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"isConfirmed\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"getConfirmationCount\",\"outputs\":[{\"name\":\"count\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"transactions\",\"outputs\":[{\"name\":\"destination\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"},{\"name\":\"executed\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getOwners\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"from\",\"type\":\"uint256\"},{\"name\":\"to\",\"type\":\"uint256\"},{\"name\":\"pending\",\"type\":\"bool\"},{\"name\":\"executed\",\"type\":\"bool\"}],\"name\":\"getTransactionIds\",\"outputs\":[{\"name\":\"_transactionIds\",\"type\":\"uint256[]\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"getConfirmations\",\"outputs\":[{\"name\":\"_confirmations\",\"type\":\"address[]\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"transactionCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_required\",\"type\":\"uint256\"}],\"name\":\"changeRequirement\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"confirmTransaction\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"destination\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"submitTransaction\",\"outputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_dailyLimit\",\"type\":\"uint256\"}],\"name\":\"changeDailyLimit\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"MAX_OWNER_COUNT\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"required\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"replaceOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"executeTransaction\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"spentToday\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"_owners\",\"type\":\"address[]\"},{\"name\":\"_required\",\"type\":\"uint256\"},{\"name\":\"_dailyLimit\",\"type\":\"uint256\"}],\"type\":\"constructor\"},{\"payable\":true,\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"dailyLimit\",\"type\":\"uint256\"}],\"name\":\"DailyLimitChange\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"Confirmation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"Revocation\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"Submission\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"Execution\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"transactionId\",\"type\":\"uint256\"}],\"name\":\"ExecutionFailure\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnerAddition\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnerRemoval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"RequirementChange\",\"type\":\"event\"}]' --disassm --code '0x606060405236156101325760e060020a6000350463025e7c278114610180578063173825d9146101b257806320ea8d86146101df5780632f54bf6e146102135780633411c81c146102335780634bc9fdc214610260578063547415251461028357806367eeba0c146102f75780636b0c932d146103055780637065cb4814610313578063784547a71461033e5780638b51d13f1461034e5780639ace38c2146103c2578063a0e67e2b146103fd578063a8abe69a1461046e578063b5dc40c31461054d578063b77bf60014610659578063ba51a6df14610667578063c01a8c8414610693578063c6427474146106a3578063cea0862114610714578063d74f8edd1461073f578063dc8452cd1461074c578063e20056e61461075a578063ee22610b1461078a578063f059cf2b1461079a575b6107a8600034111561017e57604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b565b34610002576107aa60043560038054829081101561000257600091825260209091200154600160a060020a0316905081565b34610002576107a8600435600030600160a060020a031633600160a060020a0316141515610a1a57610002565b34610002576107a8600435600160a060020a033390811660009081526002602052604090205460ff161515610c5f57610002565b34610002576107c660043560026020526000908152604090205460ff1681565b34610002576001602090815260043560009081526040808220909252602435815220546107c69060ff1681565b34610002576107da6007546000906201518001421115610d0f5750600654610d18565b34610002576107da6004356024356000805b600554811015610d1b578380156102be575060008181526020819052604090206003015460ff16155b806102e257508280156102e2575060008181526020819052604090206003015460ff165b156102ef57600191909101905b600101610295565b34610002576107da60065481565b34610002576107da60075481565b34610002576107a860043530600160a060020a031633600160a060020a0316141515610d2257610002565b34610002576107c6600435610801565b34610002576107da6004356000805b600354811015610e52576000838152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff16156103ba57600191909101905b60010161035d565b34610002576000602081905260043581526040902080546001820154600383015461087993600160a060020a03909316926002019060ff1684565b346100025760408051602080820183526000825260038054845181840281018401909552808552610923949283018282801561046257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610444575b50505050509050610d18565b34610002576109236004356024356044356064356040805160208181018352600080835283519182018452808252600554935192939192909182918059106104b35750595b9080825280602002602001820160405280156104ca575b509250600091508190505b600554811015610e58578580156104fe575060008181526020819052604090206003015460ff16155b806105225750848015610522575060008181526020819052604090206003015460ff165b156105455780838381518110156100025760209081029091010152600191909101905b6001016104d5565b34610002576109236004356040805160208181018352600080835283519182018452808252600354935192939192909182918059106105895750595b9080825280602002602001820160405280156105a0575b509250600091508190505b600354811015610ecd576000858152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561065157600380548290811015610002576000918252602090912001548351600160a060020a03909116908490849081101561000257600160a060020a03909216602092830290910190910152600191909101905b6001016105ab565b34610002576107da60055481565b34610002576107a86004355b30600160a060020a031633600160a060020a0316141515610f4957610002565b34610002576107a8600435610974565b3461000257604080516020600460443581810135601f81018490048402850184019095528484526107da948235946024803595606494929391909201918190840183828082843750949650505050505050600061096d848484600083600160a060020a0381161515610b6157610002565b34610002576107a860043530600160a060020a031633600160a060020a031614151561101457610002565b34610002576107da603281565b34610002576107da60045481565b34610002576107a8600435602435600030600160a060020a031633600160a060020a031614151561104f57610002565b34610002576107a86004356109f7565b34610002576107da60085481565b005b60408051600160a060020a039092168252519081900360200190f35b604080519115158252519081900360200190f35b60408051918252519081900360200190f35b600084815260208190526040902092506111c2845b600080805b600354811015610872576000848152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561086357600191909101905b600454821415610e4a57600192505b5050919050565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156109115780601f106108e657610100808354040283529160200191610911565b820191906000526020600020905b8154815290600101906020018083116108f457829003601f168201915b50509550505050505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b905061100d815b33600160a060020a03811660009081526002602052604090205460ff161515610fb457610002565b6000858152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a3610ce6855b6000818152602081905260408120600301548190839060ff16156107ec57610002565b600160a060020a038216600090815260026020526040902054829060ff161515610a4357610002565b600160a060020a0383166000908152600260205260408120805460ff1916905591505b60035460001901821015610b085782600160a060020a0316600360005083815481101561000257600091825260209091200154600160a060020a03161415610b3857600380546000198101908110156100025760009182526020909120015460038054600160a060020a039092169184908110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600380546000198101808355919082908015829011610b4357600083815260209020610b43918101908301610c0e565b600190910190610a66565b505060035460045411159150610c26905057600354610c2690610673565b60055460408051608081018252878152602080820188815282840188815260006060850181905286815280845294852084518154606060020a91820291909104600160a060020a031990911617815591516001808401919091559051805160028085018054818a5298879020999b5096989497601f9481161561010002600019011604830185900484019490939291019083901061137e57805160ff19168380011785555b506113ae9291505b80821115610c225760008155600101610c0e565b5090565b604051600160a060020a038416907f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9090600090a2505050565b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff161515610cee57610002565b6000858152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b505b50505050565b600084815260208190526040902060030154849060ff1615610c9457610002565b50600854600654035b90565b5092915050565b600160a060020a038116600090815260026020526040902054819060ff1615610d4a57610002565b81600160a060020a0381161515610d6057610002565b6003546004546001909101906032821180610d7a57508181115b80610d83575080155b80610d8c575081155b15610d9657610002565b600160a060020a0385166000908152600260205260409020805460ff19166001908117909155600380549182018082559091908281838015829011610dec57600083815260209020610dec918101908301610c0e565b50505060009283525060208220018054600160a060020a031916606060020a88810204179055604051600160a060020a038716917ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d91a25050505050565b600101610806565b50919050565b878703604051805910610e685750595b908082528060200260200182016040528015610e7f575b5093508790505b86811015610ec2578281815181101561000257906020019060200201518489830381518110156100025760209081029091010152600101610e86565b505050949350505050565b81604051805910610edb5750595b908082528060200260200182016040528015610ef2575b509350600090505b81811015610f41578281815181101561000257906020019060200201518482815181101561000257600160a060020a03909216602092830290910190910152600101610efa565b505050919050565b600354816032821180610f5b57508181115b80610f64575080155b80610f6d575081155b15610f7757610002565b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b6000828152602081905260409020548290600160a060020a03161515610fd957610002565b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff161561099c57610002565b9392505050565b60068190556040805182815290517fc71bdc6afaf9b1aa90a7078191d4fc1adf3bf680fca3183697df6b0dc226bca29181900360200190a150565b600160a060020a038316600090815260026020526040902054839060ff16151561107857610002565b600160a060020a038316600090815260026020526040902054839060ff16156110a057610002565b600092505b60035483101561111d5784600160a060020a0316600360005084815481101561000257600091825260209091200154600160a060020a031614156111b7578360036000508481548110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600160a060020a03808616600081815260026020526040808220805460ff1990811690915593881682528082208054909416600117909355915190917f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9091a2604051600160a060020a038516907ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d90600090a25050505050565b6001909201916110a5565b9150818061123157506002808401546000196101006001831615020116041580156112315750600183015461123190600754600090620151800142111561120d574260075560006008555b600654600854830111806112245750600854828101105b1561141057506000611414565b15610ce85760038301805460ff1916600117905581151561125b5760018301546008805490910190555b825460018085015460405160028088018054600160a060020a039096169593949093839285926000199083161561010002019091160480156112de5780601f106112b3576101008083540402835291602001916112de565b820191906000526020600020905b8154815290600101906020018083116112c157829003601f168201915b505091505060006040518083038185876185025a03f1925050501561132d5760405184907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2610ce8565b60405184907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a260038301805460ff19169055811515610ce8575050600101546008805491909103905550565b82800160010185558215610c06579182015b82811115610c06578251826000505591602001919060010190611390565b5050606091909101516003909101805460ff191660f860020a9283029290920491909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a2509392505050565b5060015b91905056'
Other disassemblers I found do complete in time. But with errors as usual.
Porosity is the only tool I know which is able to perform this correctly.
I'm trying to build using MS Code and I'm having trouble building and thought to see if you had made a release.
I just tried decompiling following bytecode. app hangs up forever using 100% CPU. I do not have original source so or ABI and not sure how to debug what is causing the issue.
0x606060405236156101325760e060020a6000350463025e7c278114610180578063173825d9146101b257806320ea8d86146101df5780632f54bf6e146102135780633411c81c146102335780634bc9fdc214610260578063547415251461028357806367eeba0c146102f75780636b0c932d146103055780637065cb4814610313578063784547a71461033e5780638b51d13f1461034e5780639ace38c2146103c2578063a0e67e2b146103fd578063a8abe69a1461046e578063b5dc40c31461054d578063b77bf60014610659578063ba51a6df14610667578063c01a8c8414610693578063c6427474146106a3578063cea0862114610714578063d74f8edd1461073f578063dc8452cd1461074c578063e20056e61461075a578063ee22610b1461078a578063f059cf2b1461079a575b6107a8600034111561017e57604080513481529051600160a060020a033316917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a25b565b34610002576107aa60043560038054829081101561000257600091825260209091200154600160a060020a0316905081565b34610002576107a8600435600030600160a060020a031633600160a060020a0316141515610a1a57610002565b34610002576107a8600435600160a060020a033390811660009081526002602052604090205460ff161515610c5f57610002565b34610002576107c660043560026020526000908152604090205460ff1681565b34610002576001602090815260043560009081526040808220909252602435815220546107c69060ff1681565b34610002576107da6007546000906201518001421115610d1b5750600654610d18565b34610002576107da6004356024356000805b600554811015610d2f578380156102be575060008181526020819052604090206003015460ff16155b806102e257508280156102e2575060008181526020819052604090206003015460ff165b156102ef57600191909101905b600101610295565b34610002576107da60065481565b34610002576107da60075481565b34610002576107a860043530600160a060020a031633600160a060020a0316141515610d3657610002565b34610002576107c6600435610801565b34610002576107da6004356000805b600354811015610e66576000838152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff16156103ba57600191909101905b60010161035d565b34610002576000602081905260043581526040902080546001820154600383015461087993600160a060020a03909316926002019060ff1684565b346100025760408051602080820183526000825260038054845181840281018401909552808552610923949283018282801561046257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610444575b50505050509050610d18565b34610002576109236004356024356044356064356040805160208181018352600080835283519182018452808252600554935192939192909182918059106104b35750595b9080825280602002602001820160405280156104ca575b509250600091508190505b600554811015610e6c578580156104fe575060008181526020819052604090206003015460ff16155b806105225750848015610522575060008181526020819052604090206003015460ff165b156105455780838381518110156100025760209081029091010152600191909101905b6001016104d5565b34610002576109236004356040805160208181018352600080835283519182018452808252600354935192939192909182918059106105895750595b9080825280602002602001820160405280156105a0575b509250600091508190505b600354811015610ee1576000858152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561065157600380548290811015610002576000918252602090912001548351600160a060020a03909116908490849081101561000257600160a060020a03909216602092830290910190910152600191909101905b6001016105ab565b34610002576107da60055481565b34610002576107a86004355b30600160a060020a031633600160a060020a0316141515610f5d57610002565b34610002576107a8600435610974565b3461000257604080516020600460443581810135601f81018490048402850184019095528484526107da948235946024803595606494929391909201918190840183828082843750949650505050505050600061096d848484600083600160a060020a0381161515610b6157610002565b34610002576107a860043530600160a060020a031633600160a060020a031614151561102857610002565b34610002576107da603281565b34610002576107da60045481565b34610002576107a8600435602435600030600160a060020a031633600160a060020a031614151561106357610002565b34610002576107a86004356109f7565b34610002576107da60085481565b005b60408051600160a060020a039092168252519081900360200190f35b604080519115158252519081900360200190f35b60408051918252519081900360200190f35b600084815260208190526040902092506111d6845b600080805b600354811015610872576000848152600160205260408120600380549192918490811015610002576000918252602080832090910154600160a060020a0316835282019290925260400190205460ff161561086357600191909101905b600454821415610e5e57600192505b5050919050565b60408051600160a060020a03861681526020810185905282151560608201526080918101828152845460026000196101006001841615020190911604928201839052909160a0830190859080156109115780601f106108e657610100808354040283529160200191610911565b820191906000526020600020905b8154815290600101906020018083116108f457829003601f168201915b50509550505050505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b9050611021815b33600160a060020a03811660009081526002602052604090205460ff161515610fc857610002565b6000858152600160208181526040808420600160a060020a0333168086529252808420805460ff1916909317909255905187927f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef91a3610ce6855b6000818152602081905260408120600301548190839060ff16156107ec57610002565b600160a060020a038216600090815260026020526040902054829060ff161515610a4357610002565b600160a060020a0383166000908152600260205260408120805460ff1916905591505b60035460001901821015610b085782600160a060020a0316600360005083815481101561000257600091825260209091200154600160a060020a03161415610b3857600380546000198101908110156100025760009182526020909120015460038054600160a060020a039092169184908110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600380546000198101808355919082908015829011610b4357600083815260209020610b43918101908301610c0e565b600190910190610a66565b505060035460045411159150610c26905057600354610c2690610673565b60055460408051608081018252878152602080820188815282840188815260006060850181905286815280845294852084518154606060020a91820291909104600160a060020a031990911617815591516001808401919091559051805160028085018054818a5298879020999b5096989497601f9481161561010002600019011604830185900484019490939291019083901061139257805160ff19168380011785555b506113c29291505b80821115610c225760008155600101610c0e565b5090565b604051600160a060020a038416907f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9090600090a2505050565b600082815260016020908152604080832033600160a060020a038116855292529091205483919060ff161515610cee57610002565b6000858152600160209081526040808320600160a060020a0333168085529252808320805460ff191690555187927ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e991a35b505b50505050565b600084815260208190526040902060030154849060ff1615610c9457610002565b50600854600654035b90565b6008546006541015610d0f57506000610d18565b5092915050565b600160a060020a038116600090815260026020526040902054819060ff1615610d5e57610002565b81600160a060020a0381161515610d7457610002565b6003546004546001909101906032821180610d8e57508181115b80610d97575080155b80610da0575081155b15610daa57610002565b600160a060020a0385166000908152600260205260409020805460ff19166001908117909155600380549182018082559091908281838015829011610e0057600083815260209020610e00918101908301610c0e565b50505060009283525060208220018054600160a060020a031916606060020a88810204179055604051600160a060020a038716917ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d91a25050505050565b600101610806565b50919050565b878703604051805910610e7c5750595b908082528060200260200182016040528015610e93575b5093508790505b86811015610ed6578281815181101561000257906020019060200201518489830381518110156100025760209081029091010152600101610e9a565b505050949350505050565b81604051805910610eef5750595b908082528060200260200182016040528015610f06575b509350600090505b81811015610f55578281815181101561000257906020019060200201518482815181101561000257600160a060020a03909216602092830290910190910152600101610f0e565b505050919050565b600354816032821180610f6f57508181115b80610f78575080155b80610f81575081155b15610f8b57610002565b60048390556040805184815290517fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a9181900360200190a1505050565b6000828152602081905260409020548290600160a060020a03161515610fed57610002565b600083815260016020908152604080832033600160a060020a038116855292529091205484919060ff161561099c57610002565b9392505050565b60068190556040805182815290517fc71bdc6afaf9b1aa90a7078191d4fc1adf3bf680fca3183697df6b0dc226bca29181900360200190a150565b600160a060020a038316600090815260026020526040902054839060ff16151561108c57610002565b600160a060020a038316600090815260026020526040902054839060ff16156110b457610002565b600092505b6003548310156111315784600160a060020a0316600360005084815481101561000257600091825260209091200154600160a060020a031614156111cb578360036000508481548110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b600160a060020a03808616600081815260026020526040808220805460ff1990811690915593881682528082208054909416600117909355915190917f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9091a2604051600160a060020a038516907ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d90600090a25050505050565b6001909201916110b9565b91508180611245575060028084015460001961010060018316150201160415801561124557506001830154611245906007546000906201518001421115611221574260075560006008555b600654600854830111806112385750600854828101105b1561142457506000611428565b15610ce85760038301805460ff1916600117905581151561126f5760018301546008805490910190555b825460018085015460405160028088018054600160a060020a039096169593949093839285926000199083161561010002019091160480156112f25780601f106112c7576101008083540402835291602001916112f2565b820191906000526020600020905b8154815290600101906020018083116112d557829003601f168201915b505091505060006040518083038185876185025a03f192505050156113415760405184907f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7590600090a2610ce8565b60405184907f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923690600090a260038301805460ff19169055811515610ce8575050600101546008805491909103905550565b82800160010185558215610c06579182015b82811115610c065782518260005055916020019190600101906113a4565b5050606091909101516003909101805460ff191660f860020a9283029290920491909117905560058054600101905560405182907fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5190600090a2509392505050565b5060015b91905056
Porosity version: 20171027.5
solidity version: 0.4.9+commit.364da425.Linux.g++
& 0.4.17+commit.bdeb9e52.Linux.g++
Testing environment: Ubuntu 16.04
I'm testing how porosity performs when dealing with 'inheritance' of contract, so I start with the sample Ethereum contract - Greeter. And I compile the contract using solidity v0.4.9 & v0.4.17 to see if the version affects the result.
In both versions, the decompilation works "fine" for contract Mortal
but gets segmentation fault for contract Greeter
.
pragma solidity ^0.4.9;
contract mortal {
/* Define variable owner of the type address */
address owner;
/* This function is executed at initialization and sets the owner of the contract */
function mortal() { owner = msg.sender; }
/* Function to recover the funds on the contract */
function kill() { if (msg.sender == owner) selfdestruct(owner); }
}
contract greeter is mortal {
/* Define variable greeting of the type string */
string greeting;
/* This runs when the contract is executed */
function greeter(string _greeting) public {
greeting = _greeting;
}
/* Main function */
function greet() constant returns (string) {
return greeting;
}
}
mortal
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x41C0E1B5
executeInstruction: NOT_IMPLEMENTED: REVERT
function kill() {
if (!msg.value) {
}
return;
}
LOC: 5
greeter
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x41C0E1B5
executeInstruction: NOT_IMPLEMENTED: REVERT
function kill() {
if (!msg.value) {
}
return;
}
LOC: 5
Hash: 0xCFAE3217
executeInstruction: NOT_IMPLEMENTED: REVERT
Segmentation fault (core dumped)
hi
i have downloaded the zipped project and unzipped it .
then , upon running "make" ,i get the error :
make
g++ -std=c++14 -c -o Contract.o Contract.cpp
g++ -std=c++14 -c -o Debug.o Debug.cpp
g++ -std=c++14 -c -o Disassm.o Disassm.cpp
g++ -std=c++14 -c -o Instruction.o Instruction.cpp
g++ -std=c++14 -c -o Output.o Output.cpp
g++ -std=c++14 -c -o Porosity.o Porosity.cpp
g++ -std=c++14 -c -o SHA3.o SHA3.cpp
g++ -std=c++14 -c -o Statement.o Statement.cpp
g++ -std=c++14 -c -o Utils.o Utils.cpp
g++ -std=c++14 -c -o VMState.o VMState.cpp
g++ -std=c++14 BasicBlocks.o CommonData.o Contract.o Debug.o Disassm.o Instruction.o Output.o Porosity.o SHA3.o Statement.o Utils.o VMState.o -o porosity
Porosity.o: In function parse(int, char**, _Arguments*)': Porosity.cpp:(.text+0x342): undefined reference to
dev::fromHex(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, dev::WhenError)'
Porosity.cpp:(.text+0x4c8): undefined reference to dev::fromHex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dev::WhenError)' Porosity.cpp:(.text+0x553): undefined reference to
dev::fromHex(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, dev::WhenError)'
Porosity.cpp:(.text+0x6f2): undefined reference to dev::fromHex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dev::WhenError)' Porosity.cpp:(.text+0x733): undefined reference to
dev::fromHex(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, dev::WhenError)'
Porosity.o:Porosity.cpp:(.text+0x947): more undefined references to `dev::fromHex(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, dev::WhenError)' follow
collect2: error: ld returned 1 exit status
make: *** [porosity] Error 1
operative system centos 7
0x6080604052600436106101b65763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302fb0c5e81146101bb5780630f15f4c0146101e45780630f2eb511146101f9578063109324d0146102205780632430af2814610235578063259ec12d1461024a578063287fac961461032d5780632f2a38d214610345578063378aa7011461039c57806339e7fddc146103fe5780633bed33ce1461043c57806340d970b3146104545780635270972514610469578063528021211461047e57806372d995621461049f57806373688914146104b75780637625391a146104cc57806376279ccb146104e7578063786b844b1461056457806378e9792514610579578063792dc19f1461058e5780637ff1fefb146105bf578063978bbdb9146105d7578063b3b95e30146105ec578063b3cdcc0314610601578063b9fdcf5c1461061c578063ba7efcdd14610631578063c9e32b8614610646578063d795a3f51461065b578063d9a7291c14610673578063e7e62d3614610688578063f069f88c146106a0578063f079914f146106b5578063f84b903e146106ca578063fcba933d146106df575b600080fd5b3480156101c757600080fd5b506101d06106f4565b604080519115158252519081900360200190f35b3480156101f057600080fd5b506101d0610703565b34801561020557600080fd5b5061020e610815565b60408051918252519081900360200190f35b34801561022c57600080fd5b5061020e61081b565b34801561024157600080fd5b5061020e610821565b34801561025657600080fd5b5061027873ffffffffffffffffffffffffffffffffffffffff60043516610827565b604051808060200180602001878152602001868152602001858152602001848152602001838103835289818151815260200191508051906020019060200280838360005b838110156102d45781810151838201526020016102bc565b50505050905001838103825288818151815260200191508051906020019060200280838360005b838110156103135781810151838201526020016102fb565b505050509050019850505050505050505060405180910390f35b34801561033957600080fd5b506101d0600435610a49565b34801561035157600080fd5b5061037673ffffffffffffffffffffffffffffffffffffffff60043516602435610b15565b604080519485526020850193909352838301919091526060830152519081900360800190f35b3480156103a857600080fd5b506103b1610df9565b6040805197885273ffffffffffffffffffffffffffffffffffffffff9096166020880152868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b34801561040a57600080fd5b50610413610e2e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561044857600080fd5b506101d0600435610e4a565b34801561046057600080fd5b506104136110be565b34801561047557600080fd5b506104136110da565b6101d073ffffffffffffffffffffffffffffffffffffffff600435166110f6565b3480156104ab57600080fd5b506101d060043561159e565b3480156104c357600080fd5b50610413611804565b3480156104d857600080fd5b506101d0600435602435611820565b3480156104f357600080fd5b50610502600435602435611a2c565b6040518080602001848152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561054e578181015183820152602001610536565b5050505090500194505050505060405180910390f35b34801561057057600080fd5b506101d0611b33565b34801561058557600080fd5b5061020e611ca2565b34801561059a57600080fd5b506101d073ffffffffffffffffffffffffffffffffffffffff60043516602435611ca8565b3480156105cb57600080fd5b506101d0600435611fc0565b3480156105e357600080fd5b5061020e61208c565b3480156105f857600080fd5b5061020e612092565b34801561060d57600080fd5b50610376600435602435612098565b34801561062857600080fd5b5061020e6121b7565b34801561063d57600080fd5b5061020e6121bd565b34801561065257600080fd5b5061020e6121c3565b34801561066757600080fd5b506101d06004356121c8565b34801561067f57600080fd5b5061020e612294565b34801561069457600080fd5b506101d060043561229a565b3480156106ac57600080fd5b5061020e612366565b3480156106c157600080fd5b506101d061236c565b3480156106d657600080fd5b506101d061237a565b3480156106eb57600080fd5b5061020e612383565b60105462010000900460ff1681565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480610741575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561074c57600080fd5b33803b80156107bc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff16156107d257600080fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff1662010000179055600c5442908101600b5560115560019250505090565b60075481565b60085481565b600f5481565b6060806000806000806000600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805490506040519080825280602002602001820160405280156108a1578160200160208202803883390190505b5073ffffffffffffffffffffffffffffffffffffffff8916600090815260026020908152604091829020548251818152818302810190920190925291985080156108f5578160200160208202803883390190505b5073ffffffffffffffffffffffffffffffffffffffff891660009081526002602081905260408220600381015491810154600190910154939950909750955090935090505b73ffffffffffffffffffffffffffffffffffffffff8816600090815260026020526040902054811015610a295773ffffffffffffffffffffffffffffffffffffffff8816600090815260026020526040902080548290811061099857fe5b90600052602060002090600202016000015487828151811015156109b857fe5b602090810290910181019190915273ffffffffffffffffffffffffffffffffffffffff891660009081526002909152604090208054829081106109f757fe5b9060005260206000209060020201600101548682815181101515610a1757fe5b6020908102909101015260010161093a565b60085415610a3b576008549150610a3f565b4291505b5091939550919395565b601054600090610100900460ff161515610ac457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480610b01575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515610b0c57600080fd5b50600e55600190565b60008080808080808080808a1515610b2b57429a505b60085415610b39576008549a505b60009550600094505b73ffffffffffffffffffffffffffffffffffffffff8c16600090815260026020526040902054851015610d395760065473ffffffffffffffffffffffffffffffffffffffff8d166000908152600260205260409020805487908110610ba357fe5b906000526020600020906002020160000154811515610bbe57fe5b60075473ffffffffffffffffffffffffffffffffffffffff8f166000908152600260205260409020805493909204965091610c1f919088908110610bfe57fe5b9060005260206000209060020201600101548d61238990919063ffffffff16565b811515610c2857fe5b049250610c3b848463ffffffff61239b16565b60055473ffffffffffffffffffffffffffffffffffffffff8e1660009081526002602052604090208054929450610c939288908110610c7657fe5b60009182526020909120600290910201549063ffffffff61239b16565b9050808210610cb357610cac8a8263ffffffff6123c416565b9950610cc6565b610cc38a8363ffffffff6123c416565b99505b610cd6868263ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff8d1660009081526002602052604090208054919750610d2c9187908110610d0e57fe5b60009182526020909120600290910201548a9063ffffffff6123c416565b9850600190940193610b42565b73ffffffffffffffffffffffffffffffffffffffff8c1660009081526002602081905260409091200154610d74908b9063ffffffff6123c416565b9950858a1115610d82578599505b73ffffffffffffffffffffffffffffffffffffffff8c16600090815260026020526040902060010154610dbc908b9063ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff909c166000908152600260205260409020600301549b9c989b9a504299505050505050505050565b601154601254601354601454600354600854949573ffffffffffffffffffffffffffffffffffffffff90941694929391924292565b60095473ffffffffffffffffffffffffffffffffffffffff1681565b600080808033803b8015610ebf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff161515610f3857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415610f6157600f54600854610f5790429063ffffffff61238916565b10610f6157600080fd5b610f6b3342610b15565b509550509450610f8487856123c490919063ffffffff16565b851015610f9057600080fd5b33600090815260026020526040902060030154610fb3908863ffffffff6123c416565b33600090815260026020526040902060030155600454606490610fdd90899063ffffffff61239b16565b811515610fe657fe5b60095460405192909104945073ffffffffffffffffffffffffffffffffffffffff169084156108fc029085906000818181858888f19350505050158015611031573d6000803e3d6000fd5b50336108fc611046898663ffffffff61238916565b6040518115909202916000818181858888f1935050505015801561106e573d6000803e3d6000fd5b5060408051888152602081018590524281830152905133917f0f2a99c361d45a0044e59048aa15f677817cf8b02ac33f8fa3c40b2118844150919081900360600190a25060019695505050505050565b600a5473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806111046123d1565b33803b801561117457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff1615156111ed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b600854156112455760095460405173ffffffffffffffffffffffffffffffffffffffff909116903480156108fc02916000818181858888f1935050505015801561123b573d6000803e3d6000fd5b5060019650611593565b66038d7ea4c6800034101561125957600080fd5b33600090815260026020526040902054601e1161127557600080fd5b600b54349650421161130a5761128b3342610b15565b5050955050600d548510156112b25784600d54039350838611156112ad578395505b6112b7565b600095505b8534111561130a5760095460405173ffffffffffffffffffffffffffffffffffffffff909116903488900380156108fc02916000818181858888f19350505050158015611308573d6000803e3d6000fd5b505b85151561131a5760019650611593565b33600090815260026020526040902054151561138b57600380546001810182556000919091527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790555b6040805180820182528781524260208083019182523360009081526002808352948120805460018181018355918352929091208451929095029094019081559051920191909155925073ffffffffffffffffffffffffffffffffffffffff88161580159061140f575073ffffffffffffffffffffffffffffffffffffffff88163314155b8015611431575073ffffffffffffffffffffffffffffffffffffffff88163014155b156114a95761147e6006548781151561144657fe5b73ffffffffffffffffffffffffffffffffffffffff8b166000908152600260208190526040909120015491900463ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff8916600090815260026020819052604090912001555b6008541515611535576007546014544203106114f757601280547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055601386905542601455611535565b60135486111561153557601280547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790556013869055426014555b60408051348152602081018890524281830152905173ffffffffffffffffffffffffffffffffffffffff8a169133917f82c91b29cbe839be500c1a5f65c8aba0a32d634f8c02275a10af0c72425e9fe09181900360600190a3600196505b505050505050919050565b6000806000806115ac6123d1565b33803b801561161c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff16151561169557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b66038d7ea4c680008810156116a957600080fd5b600854156116b657600080fd5b336000908152600260205260408120541180156116e2575033600090815260026020526040902054601e115b15156116ed57600080fd5b6116f73342610b15565b509197509550935061170f848963ffffffff6123c416565b86101561171b57600080fd5b600b54421161174257600d54611737868a63ffffffff6123c416565b111561174257600080fd5b33600090815260026020526040902060030154611765908963ffffffff6123c416565b3360008181526002602081815260408084206003810196909655805180820182528e815242818401818152858552885460018181018b55998852968590208351979096029095019586559351949096019390935582518d815290810191909152815193965091927f5f9b5ce1d7ec7b554529284a94d3930206ff8019f832a0bfb56c0b2cbfc729e99281900390910190a2506001979650505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b6000805473ffffffffffffffffffffffffffffffffffffffff1633148061185e575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561186957600080fd5b60105462010000900460ff1615156118e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415156118f057600080fd5b60105460ff161561190057600080fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905560125473ffffffffffffffffffffffffffffffffffffffff16156119775760125473ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090206001018390555b600a5460405173ffffffffffffffffffffffffffffffffffffffff9091169083156108fc029084906000818181858888f193505050501580156119be573d6000803e3d6000fd5b50600a5460125460408051868152602081018690524281830152905173ffffffffffffffffffffffffffffffffffffffff9384169392909216917f7e17553ec90b166aa31bc78264bc554aeb6ce994e54abcde0616116f3da701fd9181900360600190a35060015b92915050565b6003546060906000808585018311611a7257858303604051908082528060200260200182016040528015611a6a578160200160208202803883390190505b509350611aa0565b84604051908082528060200260200182016040528015611a9c578160200160208202803883390190505b5093505b5060005b8481108015611ab4575082868201105b15611b285760038054828801908110611ac957fe5b600091825260209091200154845173ffffffffffffffffffffffffffffffffffffffff90911690859083908110611afc57fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101611aa4565b809150509250925092565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480611b71575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515611b7c57600080fd5b60105462010000900460ff161515611bf557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415611c6457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f67616d652068617665206265656e20636c6f7365640000000000000000000000604482015290519081900360640190fd5b42600881905560408051918252517f827e8bff9f46048f8351964d2c871d09e4f4231513cf2fcb786649c68732e24f9181900360200190a150600190565b60115481565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480611ce6575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515611cf157600080fd5b60105462010000900460ff161515611d6a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b6008541515611dda57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f67616d652069732072756e6e696e670000000000000000000000000000000000604482015290519081900360640190fd5b600f54600854611df190429063ffffffff61238916565b1015611e5e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f63616e6e6f742064726177206c656674207269676874206e6f77000000000000604482015290519081900360640190fd5b60105460ff161515611ef757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f63616e6e6f742064726177206c656674206265666f726520746865206163746960448201527f6f6e206f6620646973747269627574696f6e0000000000000000000000000000606482015290519081900360840190fd5b811515611f0357303191505b73ffffffffffffffffffffffffffffffffffffffff83161515611f24573392505b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084906000818181858888f19350505050158015611f67573d6000803e3d6000fd5b5060408051838152426020820152815173ffffffffffffffffffffffffffffffffffffffff8616927f2c41df98ee15d0c9e912d9e2aae8079dd7696d86bdba7e82ad3bff2f897b9cd4928290030190a250600192915050565b601054600090610100900460ff16151561203b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612078575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561208357600080fd5b50600855600190565b60045481565b600b5481565b600080808080808080805b89851080156120b55750600354858c01105b156121a9576120f660038c87018154811015156120ce57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1642610b15565b5093509350935061214e60038c870181548110151561211157fe5b600091825260209091200154600e5473ffffffffffffffffffffffffffffffffffffffff90911690612149904263ffffffff6123c416565b610b15565b5050509050612166848a6123c490919063ffffffff16565b9850612178888263ffffffff6123c416565b975061218a878463ffffffff6123c416565b965061219c868363ffffffff6123c416565b95506001909401936120a3565b505050505092959194509250565b60055481565b600d5481565b601e81565b601054600090610100900460ff16151561224357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612280575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561228b57600080fd5b50600755600190565b600c5481565b601054600090610100900460ff16151561231557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612352575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561235d57600080fd5b50600b55600190565b60065481565b601054610100900460ff1681565b60105460ff1681565b600e5481565b60008282111561239557fe5b50900390565b60008215156123ac57506000611a26565b508181028183828115156123bc57fe5b0414611a2657fe5b81810182811015611a2657fe5b6040805180820190915260008082526020820152905600a165627a7a723058207da407e6e9a7cc61a49e9274589d13f0b78ab712ca9ede03307f70382ff3e3230029
I wrote a test script to audit the top 10,000 contracts by value stored; here's what I came up with:
Worth noting that this used --decompile
without --abi
.
Will clean up and share test script and data at some point today; it might be useful to add it (or a subset of it) to a CI process.
I've copied the vulnerable.sol
file from the readme and am trying the following commands:
solcjs --abi -o output vulnerable.sol
solcjs --bin -o output vulnerable.sol
$abi = Get-Content .\output\vulnerable_sol_SendBalance.abi
$bin = Get-Content .\output\vulnerable_sol_SendBalance.bin
Upon then running commands like .\porosity --abi $abi --code $bin --decompile --verbose 0
or .\porosity --abi $abi --code $bin --disassm
I get the following:
Debug Error!
Program: : C:...\porosity.exe
abort() has been called
(Press Retry to debug the application)
The program also generates a different abi/bin for me to what the readme gives, using the exact same vulnerable.sol
contract. This is my vulnerable_sol_SendBalance.abi
generated for me:
[{"constant":false,"inputs":[],"name":"withdrawBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"addToBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"u","type":"address"}],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
And the .bin:
60606040526000600160006101000a81548160ff021916908315150217905550341561002a57600080fd5b5b61024f8061003a6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635fd8c71014610054578063c0e317fb14610069578063f8b2cb4f1461007e575b600080fd5b341561005f57600080fd5b6100676100cb565b005b341561007457600080fd5b61007c61018b565b005b341561008957600080fd5b6100b5600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506101da565b6040518082815260200191505060405180910390f35b3373ffffffffffffffffffffffffffffffffffffffff166111116000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051600060405180830381858888f19350505050151561014457600080fd5b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b565b346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b9190505600a165627a7a72305820507e433b649b743e7ebd61621446c039ca839abe247a44049eb57bcc5226fe2d0029
Also this is to do with solc not porosity, but the command solcjs --bin-runtime -o output vulnerable.sol
I can't run (I get a
Invalid option selected, must specify either --bin or --abi
error).
Any help appreciated.
The command line length is limited. Please make Porosity to read bytecode from input file.
ABI='[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"proposals","outputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"},{"name":"votingDeadline","type":"uint256"},{"name":"executed","type":"bool"},{"name":"proposalPassed","type":"bool"},{"name":"numberOfVetos","type":"uint256"},{"name":"proposalHash","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"}],"name":"veto","outputs":[{"name":"voteID","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"transactionBytecode","type":"bytes"}],"name":"executeProposal","outputs":[{"name":"result","type":"int256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"numProposals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"debatingPeriodInMinutes","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"minutesForDebate","type":"uint256"}],"name":"changeVotingRules","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"finneyAmount","type":"uint256"},{"name":"JobDescription","type":"string"},{"name":"transactionBytecode","type":"bytes"}],"name":"newProposal","outputs":[{"name":"proposalID","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"recipient","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"description","type":"string"}],"name":"ProposalAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"position","type":"bool"},{"indexed":false,"name":"voter","type":"address"}],"name":"Voted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"result","type":"int256"},{"indexed":false,"name':"active","type":"bool"}],"name":"ProposalTallied","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"debatingPeriodInMinutes","type":"uint256"}],"name":"ChangeOfRules","type":"event"}]
BIN=0x606060405236156100a0576000357c010000000000000000000000000000000000000000000000000000000090048063013cf08b146100a95780631d28dec7146101ab578063237e9492146101dc578063400e39491461025457806369bd34361461027c5780638da5cb5b146102a4578063ac69c09c146102e2578063dfe12c3114610303578063f2fde38b146103c2578063fc0c546a146103df576100a0565b6100a75b5b565b005b34610002576100c4600480803590602001909190505061041d565b604051808973ffffffffffffffffffffffffffffffffffffffff1681526020018881526020018060200187815260200186151581526020018515158152602001848152602001836000191681526020018281038252888181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156101955780601f1061016a57610100808354040283529160200191610195565b820191906000526020600020905b81548152906001019060200180831161017857829003601f168201915b5050995050505050505050505060405180910390f35b34610002576101c660048080359060200190919050506104bd565b6040518082815260200191505060405180910390f35b346100025761023e6004808035906020019091908035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506108b6565b6040518082815260200191505060405180910390f35b34610002576102666004805050610d9e565b6040518082815260200191505060405180910390f35b346100025761028e6004805050610da7565b6040518082815260200191505060405180910390f35b34610002576102b66004805050610db0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103016004808035906020019091908035906020019091905050610dd6565b005b34610002576103ac6004808035906020019091908035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050909091908035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050909091905050610ebb565b6040518082815260200191505060405180910390f35b34610002576103dd600480803590602001909190505061143f565b005b34610002576103f160048050506114dd565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600260005081815481101561000257906000526020600020906009020160005b915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101600050549080600201600050908060030160005054908060040160009054906101000a900460ff16908060040160019054906101000a900460ff16908060050160005054908060060160005054905088565b600060006000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a0823133600060405160200152604051827c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b156100025760325a03f1156100025750505060405180519060200150141561058857610002565b600260005083815481101561000257906000526020600020906009020160005b509050600115158160080160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156105f857610002565b806007016000508054809190600101909081548183558181151161068257818360005260206000209182019101610681919061062f565b8082111561067d5760006000820160006101000a81549060ff02191690556000820160016101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010161062f565b5090565b5b5050509150815060406040519081016040528060018152602001338152602001508160070160005083815481101561000257906000526020600020900160005b5060008201518160000160006101000a81548160ff02191690837f010000000000000000000000000000000000000000000000000000000000000090810204021790555060208201518160000160016101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c0100000000000000000000000090810204021790555090505060018160080160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055506001820181600501600050819055507f86abfce99b7dd908bec0169288797f85049ec73cbe046ed9de818fab3a497ae0836001336040518084815260200183151581526020018273ffffffffffffffffffffffffffffffffffffffff168152602001935050505060405180910390a1600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634a501381604051817c0100000000000000000000000000000000000000000000000000000000028152600401809050600060405180830381600087803b156100025760325a03f115610002575050505b5b50919050565b600060006000600060006000600260005088815481101561000257906000526020600020906009020160005b509450846003016000505442108061090857508460040160009054906101000a900460ff165b806109b457508460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856001016000505488604051808473ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018381526020018280519060200190808383829060006004602084601f0104600302600f01f150905001935050505060405180910390206000191685600601600050546000191614155b156109be57610002565b60009350600092505b8460070160005080549050831015610b08578460070160005083815481101561000257906000526020600020900160005b509150600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a082318360000160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600060405160200152604051827c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b156100025760325a03f115610002575050506040518051906020015090508160000160009054906101000a900460ff1615610afa57808401935083505b5b82600101925082506109c7565b6002600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd600060405160200152604051817c0100000000000000000000000000000000000000000000000000000000028152600401809050602060405180830381600087803b156100025760325a03f115610002575050506040518051906020015081156100025704841015610cf75760018560040160006101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055508460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1666038d7ea4c6800086600101600050540288604051808280519060200190808383829060006004602084601f0104600302600f01f150905090810190601f168015610c8e5780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876185025a03f1925050501515610cb257610002565b60018560040160016101000a81548160ff02191690837f0100000000000000000000000000000000000000000000000000000000000000908102040217905550610d38565b60008560040160016101000a81548160ff02191690837f01000000000000000000000000000000000000000000000000000000000000009081020402179055505b7fe9de5427a63c4de2f5b13ac1749e48fccf7a58f27348e3013e572b0ece62d01b88878760040160019054906101000a900460ff16604051808481526020018381526020018215158152602001935050505060405180910390a15b505050505092915050565b60036000505481565b60016000505481565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e3257610002565b81600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c01000000000000000000000000908102040217905550806001600050819055507fc594bbef86dc6af772d58da5eb4f1d1e3c65feaec732130f40ff6590e28799a86001600050546040518082815260200191505060405180910390a15b5b5050565b60006000600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f1b57610002565b6002600050805480919060010190908154818355818115116110cb576009028160090283600052602060002091820191016110ca9190610f56565b808211156110c65760006000820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000506000905560028201600050805460018160011615610100020316600290046000825580601f10610fbe5750610ffb565b601f016020900490600052602060002090810190610ffa9190610fdc565b80821115610ff65760008181506000905550600101610fdc565b5090565b5b5060038201600050600090556004820160006101000a81549060ff02191690556004820160016101000a81549060ff02191690556005820160005060009055600682016000506000905560078201600050805460008255906000526020600020908101906110bb9190611069565b808211156110b75760006000820160006101000a81549060ff02191690556000820160016101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101611069565b5090565b5b5050600901610f56565b5090565b5b50505091508150600260005082815481101561000257906000526020600020906009020160005b509050600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c0100000000000000000000000090810204021790555084816001016000508190555083816002016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106111b357805160ff19168380011785556111e4565b828001600101855582156111e4579182015b828111156111e35782518260005055916020019190600101906111c5565b5b50905061120f91906111f1565b8082111561120b57600081815060009055506001016111f1565b5090565b5050600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168584604051808473ffffffffffffffffffffffffffffffffffffffff166c010000000000000000000000000281526014018381526020018280519060200190808383829060006004602084601f0104600302600f01f150905001935050505060405180910390208160060160005081905550603c600160005054024201816003016000508190555060008160040160006101000a81548160ff02191690837f010000000000000000000000000000000000000000000000000000000000000090810204021790555060008160040160016101000a81548160ff02191690837f0100000000000000000000000000000000000000000000000000000000000000908102040217905550600081600501600050819055507f646fec02522b41e7125cfc859a64fd4f4cefd5dc3b6237ca0abe251ded1fa88182600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168787604051808581526020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156114185780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1600182016003600050819055505b5b509392505050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561149b57610002565b80600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690836c010000000000000000000000009081020402179055505b5b50565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156
Using the command:
./porosity --abi $ABI --code $BIN --decompile
the only output I get is:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x013CF08B
ERROR: JUMPI destination is null.
ERROR: JUMPI destination is null.
End then it gets stuck in some kind of an infinite loop I believe...
Hi,
trying to decompile a contract, the execution gives SegmentationFault.
Here is the output:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
[+] Hash: 0x09DFDC71 (currentPyramidBalanceApproximately) (1 references)
[+] Hash: 0x253459E3 (feesSeperateFromBalanceApproximately) (1 references)
[+] Hash: 0x4229616D (collectPercentOfFees) (1 references)
[+] Hash: 0x57D4021B (nextPayoutWhenPyramidBalanceTotalsApproximately) (1 references)
[+] Hash: 0x686F2C90 (collectAllFees) (1 references)
[+] Hash: 0x6FBAAA1E (currentMultiplier) (1 references)
[+] Hash: 0x8A5FB3CA (currentFeePercentage) (1 references)
[+] Hash: 0x9DBC4F9B (participantDetails) (1 references)
[+] Hash: 0xA26DBF26 (totalParticipants) (1 references)
[+] Hash: 0xA6F9DAE1 (changeOwner) (1 references)
[+] Hash: 0xB4022950 (collectFeesInEther) (1 references)
[+] Hash: 0xCED92670 (changeMultiplier) (1 references)
[+] Hash: 0xD11F13DF (numberOfParticipantsWaitingForPayout) (1 references)
[+] Hash: 0xFAE14192 (changeFeePercentage) (1 references)
Now performing decompilation:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x09DFDC71
executeInstruction: NOT_IMPLEMENTED: CODECOPY
function currentPyramidBalanceApproximately() {
memory[0x40] = 0x20 + 0x40;
memory[0x40] = 0x40 + 0x100;
}
LOC: 4
Hash: 0x253459E3
function feesSeperateFromBalanceApproximately() {
store_1 = store_1 / 0xDE0B6B3A7640000;
return store_1;
}
LOC: 4
Hash: 0x4229616D
./decompile.sh: line 16: 6234 Segmentation fault (core dumped) ../porosity --code $bin --abi $abi --decompile --verbose 0
See the attached files
dynPyr.zip
Hi,
was analyzing Slockit Byte-code for vulnerabilities using porosity. I am not getting any output.
Bytecode:
https://live.ether.camp/account/598b7457cdabab2f3d361b77e12cd42dc8617cdd
ABI:
https://live.ether.camp/account/598b7457cdabab2f3d361b77e12cd42dc8617cdd/contract
Steps:
create output/DynamicToken.abi
https://gist.github.com/sid226/2119c9745dc0336dc3c8f4a05b59c7e7
create output/DynamicToken.bin
https://gist.github.com/sid226/975149153c354486b3884fa7cc8521bb
OS: Ubuntu 16.04.2 LTS
Commands:
abi=$(< output/DynamicToken.abi)
bin=$(< output/DynamicToken.bin)
porosity --code $bin --abi $abi --list --verbose 0
porosity --abi $abi --code $bin –disassm
porosity --abi $abi --code $bin --decompile --verbose 0
Output:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies [email protected]
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
I build on Ubuntu 5.4.0-6ubuntu1~16.04.9. And got an error:
/home/ubuntu/git/porosity/porosity/porosity/Common.h:48:66: fatal error: boost_multiprecision_number_compare_bug_workaround.hpp: No such file or directory
compilation terminated.
CMakeFiles/porosity.dir/build.make:62: recipe for target 'CMakeFiles/porosity.dir/Debug.cpp.o' failed
make[2]: *** [CMakeFiles/porosity.dir/Debug.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/porosity.dir/all' failed
make[1]: *** [CMakeFiles/porosity.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
My steps to build:
cd /home/ubuntu/git/porosity/porosity/porosity/ && cmake .
make
Compiling on Ubuntu 16.04 will currently fail as the included boost library is 1.58 that will enter this branch and fail https://github.com/comaeio/porosity/blob/master/porosity/porosity/Common.h#L48 There also isn't any documentation about dependencies and installation steps and the necessity of -std=c++1y
flag when compiling with g++ or boost versions needed.
On this line, gasLimit is compared with ~9 billion, a number larger than the largest int on most/all platforms.
https://github.com/comaeio/porosity/blob/cdca1693857fe99af546e294756c693536731833/porosity/porosity/VMState.cpp#L344
This definition should be int64_t gasLimit = int64_t...
:
https://github.com/comaeio/porosity/blob/cdca1693857fe99af546e294756c693536731833/porosity/porosity/VMState.cpp#L314
this contract only has bytecode ,without abi .I use porosity to decompile the bytecode ;
bitmaindeMacBook-Pro-3:porosity bobby$ ./porosity --code 0x6080604052600436106101b65763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302fb0c5e81146101bb5780630f15f4c0146101e45780630f2eb511146101f9578063109324d0146102205780632430af2814610235578063259ec12d1461024a578063287fac961461032d5780632f2a38d214610345578063378aa7011461039c57806339e7fddc146103fe5780633bed33ce1461043c57806340d970b3146104545780635270972514610469578063528021211461047e57806372d995621461049f57806373688914146104b75780637625391a146104cc57806376279ccb146104e7578063786b844b1461056457806378e9792514610579578063792dc19f1461058e5780637ff1fefb146105bf578063978bbdb9146105d7578063b3b95e30146105ec578063b3cdcc0314610601578063b9fdcf5c1461061c578063ba7efcdd14610631578063c9e32b8614610646578063d795a3f51461065b578063d9a7291c14610673578063e7e62d3614610688578063f069f88c146106a0578063f079914f146106b5578063f84b903e146106ca578063fcba933d146106df575b600080fd5b3480156101c757600080fd5b506101d06106f4565b604080519115158252519081900360200190f35b3480156101f057600080fd5b506101d0610703565b34801561020557600080fd5b5061020e610815565b60408051918252519081900360200190f35b34801561022c57600080fd5b5061020e61081b565b34801561024157600080fd5b5061020e610821565b34801561025657600080fd5b5061027873ffffffffffffffffffffffffffffffffffffffff60043516610827565b604051808060200180602001878152602001868152602001858152602001848152602001838103835289818151815260200191508051906020019060200280838360005b838110156102d45781810151838201526020016102bc565b50505050905001838103825288818151815260200191508051906020019060200280838360005b838110156103135781810151838201526020016102fb565b505050509050019850505050505050505060405180910390f35b34801561033957600080fd5b506101d0600435610a49565b34801561035157600080fd5b5061037673ffffffffffffffffffffffffffffffffffffffff60043516602435610b15565b604080519485526020850193909352838301919091526060830152519081900360800190f35b3480156103a857600080fd5b506103b1610df9565b6040805197885273ffffffffffffffffffffffffffffffffffffffff9096166020880152868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b34801561040a57600080fd5b50610413610e2e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561044857600080fd5b506101d0600435610e4a565b34801561046057600080fd5b506104136110be565b34801561047557600080fd5b506104136110da565b6101d073ffffffffffffffffffffffffffffffffffffffff600435166110f6565b3480156104ab57600080fd5b506101d060043561159e565b3480156104c357600080fd5b50610413611804565b3480156104d857600080fd5b506101d0600435602435611820565b3480156104f357600080fd5b50610502600435602435611a2c565b6040518080602001848152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561054e578181015183820152602001610536565b5050505090500194505050505060405180910390f35b34801561057057600080fd5b506101d0611b33565b34801561058557600080fd5b5061020e611ca2565b34801561059a57600080fd5b506101d073ffffffffffffffffffffffffffffffffffffffff60043516602435611ca8565b3480156105cb57600080fd5b506101d0600435611fc0565b3480156105e357600080fd5b5061020e61208c565b3480156105f857600080fd5b5061020e612092565b34801561060d57600080fd5b50610376600435602435612098565b34801561062857600080fd5b5061020e6121b7565b34801561063d57600080fd5b5061020e6121bd565b34801561065257600080fd5b5061020e6121c3565b34801561066757600080fd5b506101d06004356121c8565b34801561067f57600080fd5b5061020e612294565b34801561069457600080fd5b506101d060043561229a565b3480156106ac57600080fd5b5061020e612366565b3480156106c157600080fd5b506101d061236c565b3480156106d657600080fd5b506101d061237a565b3480156106eb57600080fd5b5061020e612383565b60105462010000900460ff1681565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480610741575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561074c57600080fd5b33803b80156107bc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff16156107d257600080fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff1662010000179055600c5442908101600b5560115560019250505090565b60075481565b60085481565b600f5481565b6060806000806000806000600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001805490506040519080825280602002602001820160405280156108a1578160200160208202803883390190505b5073ffffffffffffffffffffffffffffffffffffffff8916600090815260026020908152604091829020548251818152818302810190920190925291985080156108f5578160200160208202803883390190505b5073ffffffffffffffffffffffffffffffffffffffff891660009081526002602081905260408220600381015491810154600190910154939950909750955090935090505b73ffffffffffffffffffffffffffffffffffffffff8816600090815260026020526040902054811015610a295773ffffffffffffffffffffffffffffffffffffffff8816600090815260026020526040902080548290811061099857fe5b90600052602060002090600202016000015487828151811015156109b857fe5b602090810290910181019190915273ffffffffffffffffffffffffffffffffffffffff891660009081526002909152604090208054829081106109f757fe5b9060005260206000209060020201600101548682815181101515610a1757fe5b6020908102909101015260010161093a565b60085415610a3b576008549150610a3f565b4291505b5091939550919395565b601054600090610100900460ff161515610ac457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480610b01575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515610b0c57600080fd5b50600e55600190565b60008080808080808080808a1515610b2b57429a505b60085415610b39576008549a505b60009550600094505b73ffffffffffffffffffffffffffffffffffffffff8c16600090815260026020526040902054851015610d395760065473ffffffffffffffffffffffffffffffffffffffff8d166000908152600260205260409020805487908110610ba357fe5b906000526020600020906002020160000154811515610bbe57fe5b60075473ffffffffffffffffffffffffffffffffffffffff8f166000908152600260205260409020805493909204965091610c1f919088908110610bfe57fe5b9060005260206000209060020201600101548d61238990919063ffffffff16565b811515610c2857fe5b049250610c3b848463ffffffff61239b16565b60055473ffffffffffffffffffffffffffffffffffffffff8e1660009081526002602052604090208054929450610c939288908110610c7657fe5b60009182526020909120600290910201549063ffffffff61239b16565b9050808210610cb357610cac8a8263ffffffff6123c416565b9950610cc6565b610cc38a8363ffffffff6123c416565b99505b610cd6868263ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff8d1660009081526002602052604090208054919750610d2c9187908110610d0e57fe5b60009182526020909120600290910201548a9063ffffffff6123c416565b9850600190940193610b42565b73ffffffffffffffffffffffffffffffffffffffff8c1660009081526002602081905260409091200154610d74908b9063ffffffff6123c416565b9950858a1115610d82578599505b73ffffffffffffffffffffffffffffffffffffffff8c16600090815260026020526040902060010154610dbc908b9063ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff909c166000908152600260205260409020600301549b9c989b9a504299505050505050505050565b601154601254601354601454600354600854949573ffffffffffffffffffffffffffffffffffffffff90941694929391924292565b60095473ffffffffffffffffffffffffffffffffffffffff1681565b600080808033803b8015610ebf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff161515610f3857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415610f6157600f54600854610f5790429063ffffffff61238916565b10610f6157600080fd5b610f6b3342610b15565b509550509450610f8487856123c490919063ffffffff16565b851015610f9057600080fd5b33600090815260026020526040902060030154610fb3908863ffffffff6123c416565b33600090815260026020526040902060030155600454606490610fdd90899063ffffffff61239b16565b811515610fe657fe5b60095460405192909104945073ffffffffffffffffffffffffffffffffffffffff169084156108fc029085906000818181858888f19350505050158015611031573d6000803e3d6000fd5b50336108fc611046898663ffffffff61238916565b6040518115909202916000818181858888f1935050505015801561106e573d6000803e3d6000fd5b5060408051888152602081018590524281830152905133917f0f2a99c361d45a0044e59048aa15f677817cf8b02ac33f8fa3c40b2118844150919081900360600190a25060019695505050505050565b600a5473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806111046123d1565b33803b801561117457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff1615156111ed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b600854156112455760095460405173ffffffffffffffffffffffffffffffffffffffff909116903480156108fc02916000818181858888f1935050505015801561123b573d6000803e3d6000fd5b5060019650611593565b66038d7ea4c6800034101561125957600080fd5b33600090815260026020526040902054601e1161127557600080fd5b600b54349650421161130a5761128b3342610b15565b5050955050600d548510156112b25784600d54039350838611156112ad578395505b6112b7565b600095505b8534111561130a5760095460405173ffffffffffffffffffffffffffffffffffffffff909116903488900380156108fc02916000818181858888f19350505050158015611308573d6000803e3d6000fd5b505b85151561131a5760019650611593565b33600090815260026020526040902054151561138b57600380546001810182556000919091527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790555b6040805180820182528781524260208083019182523360009081526002808352948120805460018181018355918352929091208451929095029094019081559051920191909155925073ffffffffffffffffffffffffffffffffffffffff88161580159061140f575073ffffffffffffffffffffffffffffffffffffffff88163314155b8015611431575073ffffffffffffffffffffffffffffffffffffffff88163014155b156114a95761147e6006548781151561144657fe5b73ffffffffffffffffffffffffffffffffffffffff8b166000908152600260208190526040909120015491900463ffffffff6123c416565b73ffffffffffffffffffffffffffffffffffffffff8916600090815260026020819052604090912001555b6008541515611535576007546014544203106114f757601280547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055601386905542601455611535565b60135486111561153557601280547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790556013869055426014555b60408051348152602081018890524281830152905173ffffffffffffffffffffffffffffffffffffffff8a169133917f82c91b29cbe839be500c1a5f65c8aba0a32d634f8c02275a10af0c72425e9fe09181900360600190a3600196505b505050505050919050565b6000806000806115ac6123d1565b33803b801561161c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736f7272792068756d616e73206f6e6c79000000000000000000000000000000604482015290519081900360640190fd5b60105462010000900460ff16151561169557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b66038d7ea4c680008810156116a957600080fd5b600854156116b657600080fd5b336000908152600260205260408120541180156116e2575033600090815260026020526040902054601e115b15156116ed57600080fd5b6116f73342610b15565b509197509550935061170f848963ffffffff6123c416565b86101561171b57600080fd5b600b54421161174257600d54611737868a63ffffffff6123c416565b111561174257600080fd5b33600090815260026020526040902060030154611765908963ffffffff6123c416565b3360008181526002602081815260408084206003810196909655805180820182528e815242818401818152858552885460018181018b55998852968590208351979096029095019586559351949096019390935582518d815290810191909152815193965091927f5f9b5ce1d7ec7b554529284a94d3930206ff8019f832a0bfb56c0b2cbfc729e99281900390910190a2506001979650505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b6000805473ffffffffffffffffffffffffffffffffffffffff1633148061185e575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561186957600080fd5b60105462010000900460ff1615156118e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415156118f057600080fd5b60105460ff161561190057600080fd5b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905560125473ffffffffffffffffffffffffffffffffffffffff16156119775760125473ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090206001018390555b600a5460405173ffffffffffffffffffffffffffffffffffffffff9091169083156108fc029084906000818181858888f193505050501580156119be573d6000803e3d6000fd5b50600a5460125460408051868152602081018690524281830152905173ffffffffffffffffffffffffffffffffffffffff9384169392909216917f7e17553ec90b166aa31bc78264bc554aeb6ce994e54abcde0616116f3da701fd9181900360600190a35060015b92915050565b6003546060906000808585018311611a7257858303604051908082528060200260200182016040528015611a6a578160200160208202803883390190505b509350611aa0565b84604051908082528060200260200182016040528015611a9c578160200160208202803883390190505b5093505b5060005b8481108015611ab4575082868201105b15611b285760038054828801908110611ac957fe5b600091825260209091200154845173ffffffffffffffffffffffffffffffffffffffff90911690859083908110611afc57fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101611aa4565b809150509250925092565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480611b71575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515611b7c57600080fd5b60105462010000900460ff161515611bf557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b60085415611c6457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f67616d652068617665206265656e20636c6f7365640000000000000000000000604482015290519081900360640190fd5b42600881905560408051918252517f827e8bff9f46048f8351964d2c871d09e4f4231513cf2fcb786649c68732e24f9181900360200190a150600190565b60115481565b6000805473ffffffffffffffffffffffffffffffffffffffff16331480611ce6575060015473ffffffffffffffffffffffffffffffffffffffff1633145b1515611cf157600080fd5b60105462010000900460ff161515611d6a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f6f6e6c7920616374697661746564000000000000000000000000000000000000604482015290519081900360640190fd5b6008541515611dda57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f67616d652069732072756e6e696e670000000000000000000000000000000000604482015290519081900360640190fd5b600f54600854611df190429063ffffffff61238916565b1015611e5e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f63616e6e6f742064726177206c656674207269676874206e6f77000000000000604482015290519081900360640190fd5b60105460ff161515611ef757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f63616e6e6f742064726177206c656674206265666f726520746865206163746960448201527f6f6e206f6620646973747269627574696f6e0000000000000000000000000000606482015290519081900360840190fd5b811515611f0357303191505b73ffffffffffffffffffffffffffffffffffffffff83161515611f24573392505b60405173ffffffffffffffffffffffffffffffffffffffff84169083156108fc029084906000818181858888f19350505050158015611f67573d6000803e3d6000fd5b5060408051838152426020820152815173ffffffffffffffffffffffffffffffffffffffff8616927f2c41df98ee15d0c9e912d9e2aae8079dd7696d86bdba7e82ad3bff2f897b9cd4928290030190a250600192915050565b601054600090610100900460ff16151561203b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612078575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561208357600080fd5b50600855600190565b60045481565b600b5481565b600080808080808080805b89851080156120b55750600354858c01105b156121a9576120f660038c87018154811015156120ce57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1642610b15565b5093509350935061214e60038c870181548110151561211157fe5b600091825260209091200154600e5473ffffffffffffffffffffffffffffffffffffffff90911690612149904263ffffffff6123c416565b610b15565b5050509050612166848a6123c490919063ffffffff16565b9850612178888263ffffffff6123c416565b975061218a878463ffffffff6123c416565b965061219c868363ffffffff6123c416565b95506001909401936120a3565b505050505092959194509250565b60055481565b600d5481565b601e81565b601054600090610100900460ff16151561224357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612280575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561228b57600080fd5b50600755600190565b600c5481565b601054600090610100900460ff16151561231557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f74657374206f6e6c790000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60005473ffffffffffffffffffffffffffffffffffffffff16331480612352575060015473ffffffffffffffffffffffffffffffffffffffff1633145b151561235d57600080fd5b50600b55600190565b60065481565b601054610100900460ff1681565b60105460ff1681565b600e5481565b60008282111561239557fe5b50900390565b60008215156123ac57506000611a26565b508181028183828115156123bc57fe5b0414611a2657fe5b81810182811015611a2657fe5b6040805180820190915260008082526020820152905600a165627a7a723058207da407e6e9a7cc61a49e9274589d13f0b78ab712ca9ede03307f70382ff3e3230029 --decompile --list
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
the screen hangs !!!
I use command make to bulid this tool,the output is :
bitmaindeMacBook-Pro-3:porosity bobby$ make
c++ -std=c++14 -c -o Utils.o Utils.cpp
c++ -std=c++14 -c -o Contract.o Contract.cpp
c++ -std=c++14 -c -o Statement.o Statement.cpp
c++ -std=c++14 -c -o Porosity.o Porosity.cpp
c++ -std=c++14 -c -o Output.o Output.cpp
c++ -std=c++14 -c -o SHA3.o SHA3.cpp
c++ -std=c++14 -c -o BasicBlocks.o BasicBlocks.cpp
c++ -std=c++14 -c -o CommonData.o CommonData.cpp
c++ -std=c++14 -c -o Debug.o Debug.cpp
c++ -std=c++14 -c -o Instruction.o Instruction.cpp
c++ -std=c++14 -c -o Disassm.o Disassm.cpp
c++ -std=c++14 -c -o VMState.o VMState.cpp
VMState.cpp:344:26: warning: result of comparison of constant 9999965936 with expression of type 'int' is always true [-Wtautological-constant-out-of-range-compare]
if (gasLimit != 0x2540B5EF0) exp << ".gas(" << gasLimit << ")";
~~~~~~~~ ^ ~~~~~~~~~~~
1 warning generated.
c++ -std=c++14 Utils.o Contract.o Statement.o Porosity.o Output.o SHA3.o BasicBlocks.o CommonData.o Debug.o Instruction.o Disassm.o VMState.o -o porosity
bitmaindeMacBook-Pro-3:porosity bobby$
bitmaindeMacBook-Pro-3:porosity bobby$
is successful to build or not ???
Hi
I have tried to decompile a simple contract, taken from etherscan.io.
Running porosity command with --list
option is fine, but then when I try to run with --decompile
option the execution never ends and I have to kill the process.
Here is the output:
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <[email protected]>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Attempting to parse ABI definition...
Success.
Hash: 0x06FDDE03
I am attaching files. To run porosity I have created a script named decompile.sh
https://etherscan.io/address/0x66385555FC121D18Dc95eC3A8ECd51AB2B660dE5
Hello, I have tried to decompile this contract using porosity, but it just hangs, consumes full cpu core all the time.
It is some strange puzzle-scam, the "verified" source code is probably faked somehow and it also probably contains some anti-decompiling measures.
Just letting you know
Hello,
I have downloaded the zipped project and unzipped it.
Then, upon running "make all", I get the error:
g++ -std=c++14 -c -o Disassm.o Disassm.cpp
In file included from Disassm.cpp:18:0:
Porosity.h:22:36: fatal error: boost/dynamic_bitset.hpp: No such file or directory
compilation terminated.
: recipe for target 'Disassm.o' failed
make: *** [Disassm.o] Error 1
Operative system: Ubuntu 16.04 LTS
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.