Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
6boris committed Oct 16, 2023
1 parent 11f31d2 commit d7d6363
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 568 deletions.
70 changes: 35 additions & 35 deletions contracts/CTF/Damn-Vulnerable-DeFi/00.Base/DamnVulnerableDeFi.sol
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { ERC721Burnable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
// import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
// import { ERC721Burnable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
// import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";

/**
* @title DamnValuableToken
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz)
*/
// /**
// * @title DamnValuableToken
// * @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz)
// */

contract DamnValuableToken is ERC20 {
constructor() ERC20("DamnValuableToken", "DVT") {
_mint(msg.sender, type(uint256).max);
}
}
// contract DamnValuableToken is ERC20 {
// constructor() ERC20("DamnValuableToken", "DVT") {
// _mint(msg.sender, type(uint256).max);
// }
// }

/**
* @title DamnValuableNFT
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz)
* @notice Implementation of a mintable and burnable NFT with role-based access controls
*/
contract DamnValuableNFT is ERC721, ERC721Burnable, AccessControl {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
uint256 public tokenIdCounter;
// /**
// * @title DamnValuableNFT
// * @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz)
// * @notice Implementation of a mintable and burnable NFT with role-based access controls
// */
// contract DamnValuableNFT is ERC721, ERC721Burnable, AccessControl {
// bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
// uint256 public tokenIdCounter;

constructor() ERC721("DamnValuableNFT", "DVNFT") {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
}
// constructor() ERC721("DamnValuableNFT", "DVNFT") {
// _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
// _grantRole(MINTER_ROLE, msg.sender);
// }

function safeMint(address to) public onlyRole(MINTER_ROLE) returns (uint256 tokenId) {
tokenId = tokenIdCounter;
_safeMint(to, tokenId);
++tokenIdCounter;
}
// function safeMint(address to) public onlyRole(MINTER_ROLE) returns (uint256 tokenId) {
// tokenId = tokenIdCounter;
// _safeMint(to, tokenId);
// ++tokenIdCounter;
// }

// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
// // The following functions are overrides required by Solidity.
// function supportsInterface(bytes4 interfaceId) public view override(ERC721, AccessControl) returns (bool) {
// return super.supportsInterface(interfaceId);
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "@solady/utils/LibSort.sol";
import "@openzeppelin/contracts-v4.7.1/utils/Address.sol";
import "@openzeppelin/contracts-v4.7.1/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts-v4.7.1/access/AccessControlEnumerable.sol";
import "../00.Base/DamnValuableNFT.sol";
import { DamnValuableNFT } from "@contracts/CTF/Damn-Vulnerable-DeFi/00.Base/DamnValuableNFT.sol";

contract Exchange is ReentrancyGuard {
using Address for address payable;
Expand Down
2 changes: 2 additions & 0 deletions contracts/CTF/Damn-Vulnerable-DeFi/08.Puppet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
110 changes: 0 additions & 110 deletions contracts/CTF/Damn-Vulnerable-DeFi/08.Puppet/08.Puppet.sol

This file was deleted.

2 changes: 2 additions & 0 deletions contracts/CTF/Damn-Vulnerable-DeFi/09.Puppet-V2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
74 changes: 0 additions & 74 deletions contracts/CTF/Damn-Vulnerable-DeFi/09.Puppet-V2/PuppetV2Pool.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { console2 } from "@dev/forge-std/src/console2.sol";

import { IERC721 } from "@openzeppelin/contracts-v4.7.1/token/ERC721/IERC721.sol";
import { Address } from "@openzeppelin/contracts-v4.7.1/utils/Address.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts-v4.7.1/security/ReentrancyGuard.sol";
import { IERC721 } from "@openzeppelin/contracts-v4.7.1/token/ERC721/IERC721.sol";
import { IERC721Receiver } from "@openzeppelin/contracts-v4.7.1/token/ERC721/IERC721Receiver.sol";
import { DamnValuableNFT } from "../00.Base/DamnValuableNFT.sol";

import { DamnValuableNFT } from "@contracts/CTF/Damn-Vulnerable-DeFi/00.Base/DamnValuableNFT.sol";
import { IUniswapV2Callee } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Callee.sol";
import { IUniswapV2Pair } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

Expand Down Expand Up @@ -190,6 +188,7 @@ contract FreeRiderRecovery is ReentrancyGuard, IERC721Receiver {
}
}

// Wrapped Ether https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#code
interface IWETH {
function name() external view returns (string memory);
function approve(address guy, uint256 amount) external returns (bool);
Expand All @@ -209,10 +208,6 @@ interface IWETH {
event Withdrawal(address indexed src, uint256 amount);
}

interface IMarketplace {
function buyMany(uint256[] calldata tokenIds) external payable;
}

contract FreeRiderHack is IUniswapV2Callee {
IUniswapV2Pair private immutable pair;
FreeRiderNFTMarketplace private immutable marketplace;
Expand Down Expand Up @@ -247,7 +242,6 @@ contract FreeRiderHack is IUniswapV2Callee {
// 2. Unwrap WETH to native ETH
weth.withdraw(NFT_PRICE);

console2.log(address(this).balance);
// 3. Buy 6 NFTS for only 15 ETH total
marketplace.buyMany{ value: NFT_PRICE }(tokens);

Expand Down
2 changes: 2 additions & 0 deletions contracts/CTF/Damn-Vulnerable-DeFi/13.Wallet-Mining.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

This file was deleted.

Loading

0 comments on commit d7d6363

Please sign in to comment.