Write Up/Ethernaut
-
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Delegate { address public owner; constructor(address _owner) { owner = _owner; } function pwn() public { owner = msg.sender; } } contract Delegation { address public owner; Delegate delegate; constructor(address _delegateAddress) { delegate = Delegate(_delegateAddress); owner = msg.sender; } fallback() external { (bool result,) = a..
[Ethernaut] Delegation// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Delegate { address public owner; constructor(address _owner) { owner = _owner; } function pwn() public { owner = msg.sender; } } contract Delegation { address public owner; Delegate delegate; constructor(address _delegateAddress) { delegate = Delegate(_delegateAddress); owner = msg.sender; } fallback() external { (bool result,) = a..
2023.02.01 -
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Token { mapping(address => uint) balances; uint public totalSupply; constructor(uint _initialSupply) public { balances[msg.sender] = totalSupply = _initialSupply; } function transfer(address _to, uint _value) public returns (bool) { require(balances[msg.sender] - _value >= 0); balances[msg.sender] -= _value; balances[_to] += _value..
[Ethernaut] Token// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Token { mapping(address => uint) balances; uint public totalSupply; constructor(uint _initialSupply) public { balances[msg.sender] = totalSupply = _initialSupply; } function transfer(address _to, uint _value) public returns (bool) { require(balances[msg.sender] - _value >= 0); balances[msg.sender] -= _value; balances[_to] += _value..
2023.02.01 -
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Preservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public owner; uint storedTime; // Sets the function signature for delegatecall bytes4 constant setTimeSignature = bytes4(keccak256("setTime(uint256)")); constructor(address _timeZone1LibraryAddress, address _timeZone..
[Ethernaut] Preservation// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Preservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public owner; uint storedTime; // Sets the function signature for delegatecall bytes4 constant setTimeSignature = bytes4(keccak256("setTime(uint256)")); constructor(address _timeZone1LibraryAddress, address _timeZone..
2023.02.01 -
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Telephone { address public owner; constructor() { owner = msg.sender; } function changeOwner(address _owner) public { if (tx.origin != msg.sender) { owner = _owner; } } } 우리의 mission은 해당 contract의 owner를 탈취하는 것이다. 코드를 보면 owner는 msg.sender로 해당 contract를 호출한 주소이다. changeOwner() 함수를 보면 tx.origin != msg.sender가 같지 않으면 owner가 우리가 입력한 _o..
[Ethernaut] Telephone// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Telephone { address public owner; constructor() { owner = msg.sender; } function changeOwner(address _owner) public { if (tx.origin != msg.sender) { owner = _owner; } } } 우리의 mission은 해당 contract의 owner를 탈취하는 것이다. 코드를 보면 owner는 msg.sender로 해당 contract를 호출한 주소이다. changeOwner() 함수를 보면 tx.origin != msg.sender가 같지 않으면 owner가 우리가 입력한 _o..
2023.01.30 -
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract CoinFlip { uint256 public consecutiveWins; uint256 lastHash; uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968; constructor() { consecutiveWins = 0; } function flip(bool _guess) public returns (bool) { uint256 blockValue = uint256(blockhash(block.number - 1)); if (lastHash == blockValue)..
[Ethernaut] CoinFlip// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract CoinFlip { uint256 public consecutiveWins; uint256 lastHash; uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968; constructor() { consecutiveWins = 0; } function flip(bool _guess) public returns (bool) { uint256 blockValue = uint256(blockhash(block.number - 1)); if (lastHash == blockValue)..
2023.01.30 -
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import 'openzeppelin-contracts-06/math/SafeMath.sol'; contract Fallout { using SafeMath for uint256; mapping (address => uint) allocations; address payable public owner; /* constructor */ function Fal1out() public payable { owner = msg.sender; allocations[owner] = msg.value; } modifier onlyOwner { require( msg.sender == owner, "caller is no..
[Ethernaut] Fallout// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import 'openzeppelin-contracts-06/math/SafeMath.sol'; contract Fallout { using SafeMath for uint256; mapping (address => uint) allocations; address payable public owner; /* constructor */ function Fal1out() public payable { owner = msg.sender; allocations[owner] = msg.value; } modifier onlyOwner { require( msg.sender == owner, "caller is no..
2023.01.29 -
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Fallback { mapping(address => uint) public contributions; address public owner; constructor() { owner = msg.sender; contributions[msg.sender] = 1000 * (1 ether); } modifier onlyOwner { require( msg.sender == owner, "caller is not the owner" ); _; } function contribute() public payable { require(msg.value < 0.001 ether); contributio..
[Ethernaut] Fallback// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Fallback { mapping(address => uint) public contributions; address public owner; constructor() { owner = msg.sender; contributions[msg.sender] = 1000 * (1 ether); } modifier onlyOwner { require( msg.sender == owner, "caller is not the owner" ); _; } function contribute() public payable { require(msg.value < 0.001 ether); contributio..
2023.01.29 -
Ethernaut는 blockchain 해킹의 wargame이다. 기본적인 Language는 Solidity를 사용하고 있으며 ethereum에 기반하여 진행하고 있다. blockchain 해킹은 code auditing도 해야 하지만 코드의 흐름이랑 VM과의 상호작용도 잘해야 한다고 생각한다. 처음부터 차근차근 진행해 보자!! MetaMask는 Ethereum과 blockchain사이 상호작용을 하는 데 사용되는 소프트웨어 암호 화폐 지갑이다. Goerili를 testnet으로 설정을 했다면 Get new instance를 통하여 instance를 만들어야 한다. 하지만 초기에 개발한 지갑에는 ether가 0으로 되어있을 것이다. https://goerlifaucet.com/ 위 주소를 클릭하고 나오는..
[Ethernaut] Hello EthernautEthernaut는 blockchain 해킹의 wargame이다. 기본적인 Language는 Solidity를 사용하고 있으며 ethereum에 기반하여 진행하고 있다. blockchain 해킹은 code auditing도 해야 하지만 코드의 흐름이랑 VM과의 상호작용도 잘해야 한다고 생각한다. 처음부터 차근차근 진행해 보자!! MetaMask는 Ethereum과 blockchain사이 상호작용을 하는 데 사용되는 소프트웨어 암호 화폐 지갑이다. Goerili를 testnet으로 설정을 했다면 Get new instance를 통하여 instance를 만들어야 한다. 하지만 초기에 개발한 지갑에는 ether가 0으로 되어있을 것이다. https://goerlifaucet.com/ 위 주소를 클릭하고 나오는..
2023.01.28