BlockChain-Owner-Pwned
Overview
it's a simple Blockchain introductory challenge
Source Code
the contract allows any user to deposit ether into their balance without any checks on the amount or source of the ether. This could potentially lead to issues with re-entrancy attacks or other vulnerabilities if the contract relies on the balance being accurate or if there are other functions that interact with the balance in a complex way. Another concern is that the migrateTo
function allows the contract owner to withdraw all the funds from the contract and transfer them to a specified address. While this can be useful in case of an emergency, it also means that the contract owner has full control over the funds, which could be a security risk if the contract owner is compromised or malicious. It's also worth noting that the contract does not have any access controls or permission mechanisms to restrict access to certain functions or to restrict who can deposit or withdraw ether.
Solution
we have variable
me
with address of the person who calledinitWallet
function andbalance
.Now
deposit
will deposit money in the contract,withdraw
will withdraw funds and send it to us.migrateTo
will transfer all funds to given address only if you are address equal tome
.getBalance
will return you balance.
attack plan is call initWallet
then address will change. once owner is changed we can just send this all funds to our address in me
using migrateTo
function
now Funds in contract are zero so PWNED
and after verifying in website we got the flag.
Flag
Last updated