Web3/BlockChain
-
Privatedata Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import "forge-std/Test.sol"; contract ContractTest is Test { Vault VaultContract; function testReadprivatedata() public { VaultContract = new Vault(123456789); bytes32 leet = vm.load(address(VaultContract), bytes32(uint256(0))); emit log_uint(uint256(leet)); // users in slot 1 - length of array // starting from slot..
[BlockChain] DeFiVulnLabs - PrivatedataPrivatedata Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import "forge-std/Test.sol"; contract ContractTest is Test { Vault VaultContract; function testReadprivatedata() public { VaultContract = new Vault(123456789); bytes32 leet = vm.load(address(VaultContract), bytes32(uint256(0))); emit log_uint(uint256(leet)); // users in slot 1 - length of array // starting from slot..
2023.02.07 -
블록체인 네트워크는 사진과 같은 블록을 체인 형태의 연결되어 있는 분산 데이터 환경에 저장하였다. 그럼 블록을 생성할 때 어떤 노드에서 생성되는 블록을 체인에 연결해야 할까?? 이러한 문제를 해결하는 것이 분산 합의라고 한다. Consensus Algorithm 블록체인 네트워크에서 어떤 참여자에게 블록을 생성활 권한을 주느냐 결정하는 것 탈 중앙화 시스템에서 결정을 내려줄 주체가 없기 때문에, 분산 시스템에서 모두가 동일한 상태를 가지고 있을 수 있도록 하기 위해서 분산 합의는 꼭 필요하다. 성공적인 분산 합의를 위해서 다음과 같은 조건이 필요하다. 올바른 참가들은 모두에 의해 같은 값으로 결정을 내리면서 합의과정이 끝나야 한다. 합의의 결과 결정된 값은 임의의 값이 될 수 없고, 적어도 하나의 올바른..
[BlockChain] PoS / PoW / DPoS블록체인 네트워크는 사진과 같은 블록을 체인 형태의 연결되어 있는 분산 데이터 환경에 저장하였다. 그럼 블록을 생성할 때 어떤 노드에서 생성되는 블록을 체인에 연결해야 할까?? 이러한 문제를 해결하는 것이 분산 합의라고 한다. Consensus Algorithm 블록체인 네트워크에서 어떤 참여자에게 블록을 생성활 권한을 주느냐 결정하는 것 탈 중앙화 시스템에서 결정을 내려줄 주체가 없기 때문에, 분산 시스템에서 모두가 동일한 상태를 가지고 있을 수 있도록 하기 위해서 분산 합의는 꼭 필요하다. 성공적인 분산 합의를 위해서 다음과 같은 조건이 필요하다. 올바른 참가들은 모두에 의해 같은 값으로 결정을 내리면서 합의과정이 끝나야 한다. 합의의 결과 결정된 값은 임의의 값이 될 수 없고, 적어도 하나의 올바른..
2023.02.07 -
Curve Finance 오늘은 DEX 중 하나인 Curvc Finance에 대해 정리하고자 한다. 기대가 많이 된다고??? 그런 자세 아주 조아조아!! Curve Finance는 Swap 플랫폼으로 스테이블 코인 전용 Uniswap 플랫폼이라 보면 된다. https://curve.fi/#/ethereum/swap curve.fi 즉 스테이블 코인간의 교환을 위해 설계된 AMM 프로토콜이다. Curve는 분산형 유동성 집합체로, 누구나 유동성 풀을 자산에 추가하고 수수료를 벌 수 있다. AMM은 가격 알고리즘으로 작동하는 데 Curve를 이용하면 비교적 비슷한 가격대에 있는 토큰 간의 스왑에 매우 유용할 수 있다. 토큰 간의 스왑에 유용하다는 것은 스테이블 코인 간의 교환뿐만 아니라 토큰화된 다른 코인 ..
[BlockChain] DeFi Protocol - CurveCurve Finance 오늘은 DEX 중 하나인 Curvc Finance에 대해 정리하고자 한다. 기대가 많이 된다고??? 그런 자세 아주 조아조아!! Curve Finance는 Swap 플랫폼으로 스테이블 코인 전용 Uniswap 플랫폼이라 보면 된다. https://curve.fi/#/ethereum/swap curve.fi 즉 스테이블 코인간의 교환을 위해 설계된 AMM 프로토콜이다. Curve는 분산형 유동성 집합체로, 누구나 유동성 풀을 자산에 추가하고 수수료를 벌 수 있다. AMM은 가격 알고리즘으로 작동하는 데 Curve를 이용하면 비교적 비슷한 가격대에 있는 토큰 간의 스왑에 매우 유용할 수 있다. 토큰 간의 스왑에 유용하다는 것은 스테이블 코인 간의 교환뿐만 아니라 토큰화된 다른 코인 ..
2023.02.06 -
ReadOnlyReentrancy Source Code // SPDX-License-Identifier: MIT pragma solidity 0.8.13; import "forge-std/Test.sol"; import "./interface.sol"; // Video Reference - https://www.youtube.com/watch?v=0fgGTRlsDxI // forge test --contracts ./src/test/ReadOnlyReentrancy.sol -vv interface ICurve { function get_virtual_price() external view returns (uint); function add_liquidity(uint[2] calldata amounts, ..
[BlockChain] DeFiVulnLabs - ReadOnlyReentrancyReadOnlyReentrancy Source Code // SPDX-License-Identifier: MIT pragma solidity 0.8.13; import "forge-std/Test.sol"; import "./interface.sol"; // Video Reference - https://www.youtube.com/watch?v=0fgGTRlsDxI // forge test --contracts ./src/test/ReadOnlyReentrancy.sol -vv interface ICurve { function get_virtual_price() external view returns (uint); function add_liquidity(uint[2] calldata amounts, ..
2023.02.06 -
Reentrancy Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "forge-std/Test.sol"; // EtherStore is a simple vault, it can manage everyone's ethers. // But it's vulnerable, can you steal all the ethers ? contract EtherStore { mapping(address => uint256) public balances; function deposit() public payable { balances[msg.sender] += msg.value; } function withdrawFunds(uint25..
[BlockChain] DeFiVulnLabs - ReentrancyReentrancy Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "forge-std/Test.sol"; // EtherStore is a simple vault, it can manage everyone's ethers. // But it's vulnerable, can you steal all the ethers ? contract EtherStore { mapping(address => uint256) public balances; function deposit() public payable { balances[msg.sender] += msg.value; } function withdrawFunds(uint25..
2023.02.06 -
Delegatecall Source Code import "forge-std/Test.sol"; // Proxy Contract is designed for helping users call logic contract // Proxy Contract's owner is hardcoded as 0xdeadbeef // Can you manipulate Proxy Contract's owner ? contract Proxy { address public owner = address(0xdeadbeef); // slot0 Delegate delegate; constructor(address _delegateAddress) public { delegate = Delegate(_delegateAddress); }..
[BlockChain] DeFiVulnLabs - DelegatecallDelegatecall Source Code import "forge-std/Test.sol"; // Proxy Contract is designed for helping users call logic contract // Proxy Contract's owner is hardcoded as 0xdeadbeef // Can you manipulate Proxy Contract's owner ? contract Proxy { address public owner = address(0xdeadbeef); // slot0 Delegate delegate; constructor(address _delegateAddress) public { delegate = Delegate(_delegateAddress); }..
2023.02.06 -
Selfdestruct1 Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import "forge-std/Test.sol"; /* 1. Deploy EtherGame 2. Players (say Alice and Bob) decides to play, deposits 1 Ether each. 2. Deploy Attack with address of EtherGame 3. Call Attack.attack sending 5 ether. This will break the game No one can become the winner. What happened? Attack forced the balance of EtherGame t..
[BlockChain] DeFiVulnLabs - SelfdestructSelfdestruct1 Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import "forge-std/Test.sol"; /* 1. Deploy EtherGame 2. Players (say Alice and Bob) decides to play, deposits 1 Ether each. 2. Deploy Attack with address of EtherGame 3. Call Attack.attack sending 5 ether. This will break the game No one can become the winner. What happened? Attack forced the balance of EtherGame t..
2023.02.05 -
Integer overflow1 Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "forge-std/Test.sol"; // This contract is designed to act as a time vault. // User can deposit into this contract but cannot withdraw for atleast a week. // User can also extend the wait time beyond the 1 week waiting period. /* 1. Alice and bob both have 1 Ether balance 2. Deploy TimeLock Contract 3. Al..
[BlockChain] DeFiVulnLabs - Integer overflowInteger overflow1 Source Code // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "forge-std/Test.sol"; // This contract is designed to act as a time vault. // User can deposit into this contract but cannot withdraw for atleast a week. // User can also extend the wait time beyond the 1 week waiting period. /* 1. Alice and bob both have 1 Ether balance 2. Deploy TimeLock Contract 3. Al..
2023.02.05