This project contains a smart contract challenge named Doju
and a corresponding test script. The challenge involves interacting with a bonding curve token and steal half of its supply
Solution lies in sellTokens
function, where Doju
contract calls to
with calldata which is abi.encodePacked(minOut,to,amount,...)
, Now, this can be manipulated by using to
as doju address, salt mining to generate an address with last 4 bytes as same as first 4 bytes of doju
address and then using choosing minOut such that, first 4 bytes are transfer
function selector, and last 16 bytes as first 16 bytes of address generated. Although I was not able to generate such an address but it was easy to test it in foundry.
- test_doju(): The main function that executes the solution. It performs the following steps:
- Initializes the
Challenge
contract and retrieves theDoju
token instance. - Claims the tokens from the
Challenge
contract. - Constructs a special address (
CLAIMER_ADDRESS
) based on theDoju
token address. - Deploys a
Taker
contract to theCLAIMER_ADDRESS
. - Sells tokens to the
Doju
contract with a manipulatedminOut
value to exploit it. - Withdraws the tokens to the address
0xc0ffee
. - Asserts that the challenge is solved by checking the balance of the address
0xc0ffee
.
- Initializes the