Guess the secret number 题目描述 原题链接 原题目要求 GuessTheSecretNumberChallenge 合约的 ether 余额为 0。而调用 guess 并输入答案,如果答案的 hash 等于 answerHash 即可转移 ether 出去。 运行 安装 Foundry 根据Foundry 官方文档配置好运行环境。 安装 Rust 并根据提示继续操作。 获取 secret number 即获得 secret 为 170。具体 rust 代码在 gethash 运行测试 功能简述 因为 guess 的参数是 uint8 类型,因此解空间大小为 256,我们可以在链下暴力破解: 通过遍历 0-256 的 hash,如果有等于 的,输出结果。