You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解析bomb lab phase_5汇编代码与查找表获取合法输入字符串

Bomb Lab phase_5 求解方案

规则校验(从汇编提取)

从给出的phase_5汇编代码可以得到核心校验逻辑:

  • 输入字符串长度必须严格为6,否则触发explode_bomb
  • 遍历字符串的每个字符,取每个字符ASCII码与0xf按位与的结果(即低4位)作为查找表下标
  • 将6个下标对应查找表的数值累加,结果必须等于0x28(十进制40)才能通过校验

对应的核心汇编片段如下:

0x5555555553b1 <phase_5>        push   %rbx
0x5555555553b2 <phase_5+1>      mov    %rdi,%rbx
0x5555555553b5 <phase_5+4>      callq  0x55555555560f <string_length>
0x5555555553ba <phase_5+9>      cmp    $0x6,%eax
0x5555555553bd <phase_5+12>     jne    0x5555555553f0 <phase_5+63>
0x5555555553bf <phase_5+14>     mov    %rbx,%rax
0x5555555553c2 <phase_5+17>     lea    0x6(%rbx),%rdi
0x5555555553c6 <phase_5+21>     mov    $0x0,%ecx
0x5555555553cb <phase_5+26>     lea    0x150e(%rip),%rsi        # 0x5555555568e0 <array.3420>
>0x5555555553d2 <phase_5+33>     movzbl (%rax),%edx
0x5555555553d5 <phase_5+36>     and    $0xf,%edx
0x5555555553d8 <phase_5+39>     add    (%rsi,%rdx,4),%ecx
0x5555555553db <phase_5+42>     add    $0x1,%rax
0x5555555553df <phase_5+46>     cmp    %rdi,%rax
0x5555555553e2 <phase_5+49>     jne    0x5555555553d2 <phase_5+33>
0x5555555553e4 <phase_5+51>     cmp    $0x28,%ecx
0x5555555553e7 <phase_5+54>     je     0x5555555553ee <phase_5+61>
0x5555555553e9 <phase_5+56>     callq  0x555555555856 <explode_bomb>
0x5555555553ee <phase_5+61>     pop    %rbx
0x5555555553ef <phase_5+62>     retq
0x5555555553f0 <phase_5+63>     callq  0x555555555856 <explode_bomb>
0x5555555553f5 <phase_5+68>     jmp    0x5555555553bf <phase_5+14>

查找表映射关系

根据gdb导出的查找表内容,整理得到偏移(下标)和对应值的映射如下:

偏移(0~15)对应数值
02
110
26
31
412
516
69
73
84
97
1014
115
1211
138
1415
1513

查找表导出的原始gdb输出如下:

(gdb) x/16wd  0x5555555568e0
0x5555555568e0 <array.3420>:    2       10      6       1
0x5555555568f0 <array.3420+16>: 12      16      9       3
0x555555556900 <array.3420+32>: 4       7       14      5
0x555555556910 <array.3420+48>: 11      8       15      13

构造合法输入

我们需要找到6个0~15的偏移,对应表中数值总和为40,再将每个偏移转成可打印字符即可:

  1. 选一组符合求和要求的偏移,举个例子:[5,4,9,7,3,3],对应值相加为16+12+7+3+1+1=40,刚好满足要求
  2. 将每个偏移转成可打印字符:只要字符ASCII码低4位等于对应偏移即可,比如我们选大写字母:
    • 偏移5:ASCII=69,对应字符E(69 & 0xf =5)
    • 偏移4:ASCII=68,对应字符D(68 & 0xf =4)
    • 偏移9:ASCII=73,对应字符I(73 & 0xf =9)
    • 偏移7:ASCII=71,对应字符G(71 & 0xf =7)
    • 偏移3:ASCII=67,对应字符C(67 & 0xf =3)
    • 偏移3:ASCII=67,对应字符C(67 & 0xf =3)
  3. 得到合法输入字符串:EDIGCC

注:输入不唯一,只要6个字符的ASCII低4位对应表值总和为40即可,使用小写字母、数字、符号都可以,只要符合低4位要求。

内容的提问来源于stack exchange,提问作者LL636

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 04:51:02