Files
quorum-examples/examples/7nodes/porosity/scan.js
Patrick Mylund Nielsen 4ff9c1cc98 Add Porosity examples
2017-07-27 14:46:07 -04:00

30 lines
925 B
JavaScript

function scanBlock(blockNumber) {
var b = eth.getBlock(blockNumber);
for (var i = 0; i < b.transactions.length; i++) {
var tx = eth.getTransaction(b.transactions[i]);
var code;
if (tx.v == 37 || tx.v == 38) { // private
code = quorum.getPrivatePayload(tx.input);
if (code === "0x") {
continue // we weren't a party to this transaction
}
} else {
// code = tx.input;
continue; // skip public transactions
}
var isVulnerable = quorum.runPorosity({"code": code, "decompile": true, "silent": true})
if (isVulnerable) {
console.log("Reentrant vulnerability in block " + tx.blockNumber +
":\nTransaction: " + tx.hash +
"\nFrom: " + tx.from +
"\nTo: " + (tx.to === null ? "Contract creation" : tx.to)
);
}
}
}
console.log("Scanning all private transactions for vulnerabilities");
for (var i = 0; i < eth.blockNumber; i++) {
scanBlock(i);
}