~/d4nnyX

← IHack 2026

Pen Rose

Blockchain · IHack 2026

  • Blockchain
  • EVM
  • Smart contract
  • Keccak256
EVM disassembly of the Pen Rose contract showing PUSH/MSTORE opcodes
Disassembling the contract bytecode at re.hanz.dev.

Overview

The challenge gave raw EVM bytecode for a lottery contract. I disassembled it at re.hanz.dev to read the opcodes — it brought back memories of the stack-machine code from my microprocessor course.

Reading the bytecode

Most of it was ordinary machine code, but a 32-byte PUSH caught my eye. Decoding that constant in CyberChef revealed a hardcoded value that looked like a salt, and other opcodes showed the contract using KECCAK256.

CyberChef decoding the 32-byte pushed constant into the string penrose_lucky_number_2026
The pushed constant decodes to the salt string penrose_lucky_number_2026.

The vulnerability

Putting it together, the "secret" winning number is derived entirely from public data:

lucky = keccak256(blockhash(b) || salt)

Both inputs are known: blockhash(b) is on-chain, and the salt is baked into the bytecode. Anything a contract can read, an attacker can read too, so the lottery is fully predictable.

Solving it

The solver extracted the live selectors from the runtime code (guess(uint256,uint256)), computed lucky for the chosen block, and submitted the guess. isSolved() returned true.

b          = head - 1
bh         = blockhash(b)
salt       = b"penrose_lucky_number_2026".ljust(32, b"\x00")
lucky      = keccak(bytes.fromhex(bh[2:]) + salt)
# guess(b, lucky) -> isSolved() == true
Solver terminal output showing SUCCESS and isSolved returning 1
The winning guess lands and isSolved() returns 1.

ihack{it's_a_lottery_game_with_suprising_little_details!_thank_you_for_using_xvmre_at_re.hanz.dev_c67036dfe972fa25678a231b86f74efb}

Takeaways

There is no secrecy on a public chain. Block hashes, timestamps and contract storage are all readable, so deriving a "random" or "secret" value from them — even mixed with a hardcoded salt — gives no security at all. On-chain randomness needs a source the contract cannot fully predict, such as a commit-reveal scheme or a verifiable randomness oracle.