无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 454|回复: 11
打印 上一主题 下一主题

[转贴] 【2025/01/16】攻防世界、BUUCTF竞赛题目研究

[复制链接]
跳转到指定楼层
1#
发表于 2025-1-16 21:02:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 SYSTEM-RAMOS 于 2025-1-16 21:02 编辑

1.攻防世界:csaw2013reversing2  
IDA打开,将main函数反编译为C语言文件后,得到
  1. <blockquote>int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
复制代码
1.看到第16行代码,输出flag,lpMem中保存着flag值。
2.第8行代码,为lpMen申请内存空间。
3.第9行代码,为lpMem赋值。其中&unk_409B10的值为
  1. .data:00409B10 unk_409B10      db 0BBh                 ; DATA XREF: _main+33↑o
  2. .data:00409B11                 db 0CCh
  3. .data:00409B12                 db 0A0h
  4. .data:00409B13                 db 0BCh
  5. .data:00409B14                 db 0DCh
  6. .data:00409B15                 db 0D1h
  7. .data:00409B16                 db 0BEh
  8. .data:00409B17                 db 0B8h
  9. .data:00409B18                 db 0CDh
  10. .data:00409B19                 db 0CFh
  11. .data:00409B1A                 db 0BEh
  12. .data:00409B1B                 db 0AEh
  13. .data:00409B1C                 db 0D2h
  14. .data:00409B1D                 db 0C4h
  15. .data:00409B1E                 db 0ABh
  16. .data:00409B1F                 db  82h
  17. .data:00409B20                 db 0D2h
  18. .data:00409B21                 db 0D9h
  19. .data:00409B22                 db  93h
  20. .data:00409B23                 db 0B3h
  21. .data:00409B24                 db 0D4h
  22. .data:00409B25                 db 0DEh
  23. .data:00409B26                 db  93h
  24. .data:00409B27                 db 0A9h
  25. .data:00409B28                 db 0D3h
  26. .data:00409B29                 db 0CBh
  27. .data:00409B2A                 db 0B8h
  28. .data:00409B2B                 db  82h
  29. .data:00409B2C                 db 0D3h
  30. .data:00409B2D                 db 0CBh
  31. .data:00409B2E                 db 0BEh
  32. .data:00409B2F                 db 0B9h
  33. .data:00409B30                 db  9Ah
  34. .data:00409B31                 db 0D7h
  35. .data:00409B32                 db 0CCh
  36. .data:00409B33                 db 0DDh
复制代码
从第13行代码我们知道,第10~15行代码在对lpMem操作,又因为 ExitProcess(0xFFFFFFFF);所以猜测,这段if结构没有执行(执行的话,就会直接退出,不会有跳出MessageBox对话框),于是使用OD对程序进行调试:
  1. 00111307 > [        DISCUZ_CODE_1181        ]nbsp; E8 531A0000   call 00112D5F
  2. 0011130C   .^ E9 95FEFFFF   jmp 001111A6
  3. 00111311   >  8BFF          mov edi,edi
  4. 00111313  /.  55            push ebp
  5. 00111314  |.  8BEC          mov ebp,esp
  6. 00111316  |.  81EC 28030000 sub esp,0x328
  7. 0011131C  |.  A3 589C1100   mov dword ptr ds:[0x119C58],eax
  8. 00111321  |.  890D 549C1100 mov dword ptr ds:[0x119C54],ecx
  9. 00111327  |.  8915 509C1100 mov dword ptr ds:[0x119C50],edx
  10. 0011132D  |.  891D 4C9C1100 mov dword ptr ds:[0x119C4C],ebx
  11. 00111333  |.  8935 489C1100 mov dword ptr ds:[0x119C48],esi
  12. 00111339  |.  893D 449C1100 mov dword ptr ds:[0x119C44],edi
  13. 0011133F  |.  66:8C15 709C1>mov word ptr ds:[0x119C70],ss
  14. 00111346  |.  66:8C0D 649C1>mov word ptr ds:[0x119C64],cs
  15. 0011134D  |.  66:8C1D 409C1>mov word ptr ds:[0x119C40],ds
  16. 00111354  |.  66:8C05 3C9C1>mov word ptr ds:[0x119C3C],es
  17. 0011135B  |.  66:8C25 389C1>mov word ptr ds:[0x119C38],fs
  18. 00111362  |.  66:8C2D 349C1>mov word ptr ds:[0x119C34],gs
  19. 00111369  |.  9C            pushfd
  20. 0011136A  |.  8F05 689C1100 pop dword ptr ds:[0x119C68]
  21. 00111370  |.  8B45 00       mov eax,dword ptr ss:[ebp]
  22. 00111373  |.  A3 5C9C1100   mov dword ptr ds:[0x119C5C],eax
  23. 00111378  |.  8B45 04       mov eax,dword ptr ss:[ebp+0x4]
  24. 0011137B  |.  A3 609C1100   mov dword ptr ds:[0x119C60],eax
  25. 00111380  |.  8D45 08       lea eax,[arg.1]
  26. 00111383  |.  A3 6C9C1100   mov dword ptr ds:[0x119C6C],eax
  27. 00111388  |.  8B85 E0FCFFFF mov eax,[local.200]
  28. 0011138E  |.  C705 A89B1100>mov dword ptr ds:[0x119BA8],0x10001
  29. 00111398  |.  A1 609C1100   mov eax,dword ptr ds:[0x119C60]
  30. 0011139D  |.  A3 5C9B1100   mov dword ptr ds:[0x119B5C],eax
  31. 001113A2  |.  C705 509B1100>mov dword ptr ds:[0x119B50],0xC0000409
  32. 001113AC  |.  C705 549B1100>mov dword ptr ds:[0x119B54],0x1
  33. 001113B6  |.  A1 04901100   mov eax,dword ptr ds:[0x119004]
  34. 001113BB  |.  8985 D8FCFFFF mov [local.202],eax
  35. 001113C1  |.  A1 08901100   mov eax,dword ptr ds:[0x119008]
  36. 001113C6  |.  8985 DCFCFFFF mov [local.201],eax
  37. 001113CC  |.  FF15 14601100 call dword ptr ds:[<&KERNEL32.IsDebugger>; [IsDebuggerPresent
  38. 001113D2  |.  A3 A09B1100   mov dword ptr ds:[0x119BA0],eax
  39. 001113D7  |.  6A 01         push 0x1
  40. 001113D9  |.  E8 1C1A0000   call 00112DFA
  41. 001113DE  |.  59            pop ecx
  42. 001113DF  |.  6A 00         push 0x0                                 ; /pTopLevelFilter = NULL
  43. 001113E1  |.  FF15 34601100 call dword ptr ds:[<&KERNEL32.SetUnhandl>; \SetUnhandledExceptionFilter
  44. 001113E7  |.  68 3C611100   push 0011613C                            ; /pExceptionInfo = pro3.0011613C
  45. 001113EC  |.  FF15 30601100 call dword ptr ds:[<&KERNEL32.UnhandledE>; \UnhandledExceptionFilter
  46. 001113F2  |.  833D A09B1100>cmp dword ptr ds:[0x119BA0],0x0
  47. 001113F9  |.  75 08         jnz X00111403
  48. 001113FB  |.  6A 01         push 0x1
  49. 001113FD  |.  E8 F8190000   call 00112DFA
  50. 00111402  |.  59            pop ecx
  51. 00111403  |>  68 090400C0   push 0xC0000409                          ; /ExitCode = C0000409 (-1073740791.)
  52. 00111408  |.  FF15 2C601100 call dword ptr ds:[<&KERNEL32.GetCurrent>; |[GetCurrentProcess
  53. 0011140E  |.  50            push eax                                 ; |hProcess
  54. 0011140F  |.  FF15 28601100 call dword ptr ds:[<&KERNEL32.TerminateP>; \TerminateProcess
  55. 00111415  |.  C9            leave
  56. 00111416  \.  C3            retn
复制代码
右键查找全部字符串,找到“Flag”的位置
  1. 001110A5   .  6A 02         push 0x2                                 ; /Style = MB_ABORTRETRYIGNORE|MB_APPLMODAL
  2. 001110A7   .  68 20781100   push 00117820                            ; |Title = "Flag"
  3. 001110AC   .  FF75 F4       push dword ptr ss:[ebp-0xC]              ; |Text
  4. 001110AF   .  6A 00         push 0x0                                 ; |hOwner = NULL
  5. 001110B1   .  FF15 E4601100 call dword ptr ds:[<&USER32.MessageBoxA>>; \MessageBoxA
  6. 001110B7   .  EB 14         jmp X001110CD
  7. 001110B9   >  6A 02         push 0x2                                 ; /Style = MB_ABORTRETRYIGNORE|MB_APPLMODAL
  8. 001110BB   .  68 20781100   push 00117820                            ; |Title = "Flag"
  9. 001110C0   .  8B45 F4       mov eax,dword ptr ss:[ebp-0xC]           ; |
  10. 001110C3   .  40            inc eax                                  ; |
  11. 001110C4   .  50            push eax                                 ; |Text
  12. 001110C5   .  6A 00         push 0x0                                 ; |hOwner = NULL
  13. 001110C7   .  FF15 E4601100 call dword ptr ds:[<&USER32.MessageBoxA>>; \MessageBoxA
复制代码
通过设置断点调试,我们可以了解到,if结构和第1个“Flag”处没有执行。
if结构对应汇编代码:
  1. 00111083   .  E8 A2FFFFFF   call 0011102A
  2. 00111088   .  85C0          test eax,eax
  3. 0011108A   .  75 0A         jnz X00111096
  4. 0011108C   .  FF15 14601100 call dword ptr ds:[<&KERNEL32.IsDebugger>; [IsDebuggerPresent
  5. 00111092   .  85C0          test eax,eax
  6. 00111094      74 23         je X001110B9
  7. 00111096   >  41            inc ecx
  8. 00111097   .  41            inc ecx
  9. 00111098   .  41            inc ecx
  10. 00111099   .  41            inc ecx
  11. 0011109A   .  CC            int3
  12. 0011109B   .  8B55 F4       mov edx,dword ptr ss:[ebp-0xC]
  13. 0011109E   .  E8 5DFFFFFF   call 00111000
  14. 001110A3   .  EB 4A         jmp X001110EF
复制代码
既然这个if结构中有对flag值的操作,而且还跳过了,秉承“偷鸡摸狗,必定有内幕”的侦探心理,在OD修改代码,使得程序执行if结构,再跳转到第二个MessageBox处,对代码进行修改:
  1. 00111083   .  E8 A2FFFFFF   call 0011102A
  2. 00111088   .  85C0          test eax,eax
  3. 0011108A   .  75 0A         jnz X00111096
  4. 0011108C   .  FF15 14601100 call dword ptr ds:[<&KERNEL32.IsDebugger>; [IsDebuggerPresent
  5. 00111092   .  85C0          test eax,eax
  6. 00111094      90            nop
  7. 00111095      90            nop
  8. 00111096   >  41            inc ecx
  9. 00111097   .  41            inc ecx
  10. 00111098   .  41            inc ecx
  11. 00111099   .  41            inc ecx
  12. 0011109A      90            nop
  13. 0011109B   .  8B55 F4       mov edx,dword ptr ss:[ebp-0xC]
  14. 0011109E   .  E8 5DFFFFFF   call 00111000
  15. 001110A3      EB 14         jmp X001110B9
复制代码
运行即可得到FLAG。
2.攻防世界:crackme   
用简单的ODdump脱就行了。载入IDA,修改判断处的代码,直接打印出正确答案即可。
  1. from ida_bytes import get_bytes
  2. s = ''
  3. data = get_bytes(0x402130, 0x402140-0x402130)
  4. r = get_bytes(0x402150, 0x402200-0x402150)
  5. print(len(r))
  6. for i in range(int((len(r))/4)):
  7.     s += chr(ord(data[i % 16]) ^ ord(r[i * 4]))
  8. print(s)
复制代码

3.攻防世界:testre反编译后,找到了一个比较字符串的函数,他还专门拆开来写。我们需要按照顺序将字符串进行拼接,得到D9cS9N9iHjMLTdA8YSMRMp,另在代码看见“58”,猜测可能是base58加密,使用工具解密后即可得到flag。

4.攻防世界:Newbie_calculations
经IDA分析后,直接修改答案处的输出代码:
  1. #include<iostream>
  2. #include<cstdio>
  3. using namespace std;
  4. int sub_401000(int a1, int a2)
  5. {
  6.     return a1+a2;
  7. }
  8. int sub_401100(int a1, int a2)
  9. {
  10.     return a1*a2;
  11. }
  12. int sub_401220(int a1, int a2)
  13. {
  14.     return a1-a2;
  15. }
  16. int main()
  17. {
  18.   int v3; // eax
  19.   int v4; // eax
  20.   int v5; // eax
  21.   int v6; // eax
  22.   int v7; // eax
  23.   int v8; // eax
  24.   int v9; // eax
  25.   int v10; // eax
  26.   int v11; // eax
  27.   int v12; // eax
  28.   int v13; // eax
  29.   int v14; // eax
  30.   int v15; // eax
  31.   int v16; // eax
  32.   int v17; // eax
  33.   int v18; // eax
  34.   int v19; // eax
  35.   int v20; // eax
  36.   int v21; // eax
  37.   int v22; // eax
  38.   int v23; // eax
  39.   int v24; // eax
  40.   int v25; // eax
  41.   int v26; // eax
  42.   int v27; // eax
  43.   int v28; // eax
  44.   int v29; // eax
  45.   int v30; // eax
  46.   int v31; // eax
  47.   int v32; // eax
  48.   int v33; // eax
  49.   int v34; // eax
  50.   int v35; // eax
  51.   int v36; // eax
  52.   int v37; // eax
  53.   int v38; // eax
  54.   int v39; // eax
  55.   int v40; // eax
  56.   int v41; // eax
  57.   int v42; // eax
  58.   int v43; // eax
  59.   int v44; // eax
  60.   int v45; // eax
  61.   int v46; // eax
  62.   int v47; // eax
  63.   int v48; // eax
  64.   int v49; // eax
  65.   int v50; // eax
  66.   int v51; // eax
  67.   int v52; // eax
  68.   int v53; // eax
  69.   int v54; // eax
  70.   int v55; // eax
  71.   int v56; // eax
  72.   int v57; // eax
  73.   int v58; // eax
  74.   int v59; // eax
  75.   int v60; // eax
  76.   int v61; // eax
  77.   int v62; // eax
  78.   int v63; // eax
  79.   int v64; // eax
  80.   int v65; // eax
  81.   int v66; // eax
  82.   int v67; // eax
  83.   int v68; // eax
  84.   int v69; // eax
  85.   int v70; // eax
  86.   int v71; // eax
  87.   int v72; // eax
  88.   int v73; // eax
  89.   int v74; // eax
  90.   int v75; // eax
  91.   int v76; // eax
  92.   int v77; // eax
  93.   int v78; // eax
  94.   int v79; // eax
  95.   int v80; // eax
  96.   int v81; // eax
  97.   int v82; // eax
  98.   int v83; // eax
  99.   int v84; // eax
  100.   int v85; // eax
  101.   int v86; // eax
  102.   int v87; // eax
  103.   int v88; // eax
  104.   int v89; // eax
  105.   int v90; // eax
  106.   int v91; // eax
  107.   int v92; // eax
  108.   int v93; // eax
  109.   int v94; // eax
  110.   int v95; // eax
  111.   int v96; // eax
  112.   int v97; // eax
  113.   int v98; // eax
  114.   int v99; // eax
  115.   int v100; // eax
  116.   int v101; // eax
  117.   int v102; // eax
  118.   int v103; // eax
  119.   int v104; // eax
  120.   int v105; // eax
  121.   int v106; // eax
  122.   int v107; // eax
  123.   int v108; // eax
  124.   int v109; // ST1C_4
  125.   int v110; // eax
  126.   int v111; // eax
  127.   int v112; // ST20_4
  128.   int v113; // eax
  129.   int v114; // eax
  130.   int v115; // ST20_4
  131.   int v116; // eax
  132.   signed int i; // [esp+4h] [ebp-90h]
  133.   signed int j; // [esp+8h] [ebp-8Ch]
  134.   int v120[32]; // [esp+Ch] [ebp-88h]
  135.   int v121; // [esp+8Ch] [ebp-8h]

  136.   for ( i = 0; i < 32; ++i )
  137.     v120[i] = 1;
  138.   v121 = 0;
  139.   puts("Your flag is:");
  140.   v3 = sub_401100(v120[0], 1000000000);
  141.   v4 = sub_401220(v3, 999999950);
  142.   v120[0] = sub_401100(v4, 2);
  143.   v5 = sub_401000(v120[1], 5000000);
  144.   v6 = sub_401220(v5, 6666666);
  145.   v7 = sub_401000(v6, 1666666);
  146.   v8 = sub_401000(v7, 45);
  147.   v9 = sub_401100(v8, 2);
  148.   v120[1] = sub_401000(v9, 5);
  149.   v10 = sub_401100(v120[2], 1000000000);
  150.   v11 = sub_401220(v10, 999999950);
  151.   v12 = sub_401100(v11, 2);
  152.   v120[2] = sub_401000(v12, 2);
  153.   v13 = sub_401000(v120[3], 55);
  154.   v14 = sub_401220(v13, 3);
  155.   v15 = sub_401000(v14, 4);
  156.   v120[3] = sub_401220(v15, 1);
  157.   v16 = sub_401100(v120[4], 100000000);
  158.   v17 = sub_401220(v16, 99999950);
  159.   v18 = sub_401100(v17, 2);
  160.   v120[4] = sub_401000(v18, 2);
  161.   v19 = sub_401220(v120[5], 1);
  162.   v20 = sub_401100(v19, 1000000000);
  163.   v21 = sub_401000(v20, 55);
  164.   v120[5] = sub_401220(v21, 3);
  165.   v22 = sub_401100(v120[6], 1000000);
  166.   v23 = sub_401220(v22, 999975);
  167.   v120[6] = sub_401100(v23, 4);
  168.   v24 = sub_401000(v120[7], 55);
  169.   v25 = sub_401220(v24, 33);
  170.   v26 = sub_401000(v25, 44);
  171.   v120[7] = sub_401220(v26, 11);
  172.   v27 = sub_401100(v120[8], 10);
  173.   v28 = sub_401220(v27, 5);
  174.   v29 = sub_401100(v28, 8);
  175.   v120[8] = sub_401000(v29, 9);
  176.   v30 = sub_401000(v120[9], 0);
  177.   v31 = sub_401220(v30, 0);
  178.   v32 = sub_401000(v31, 11);
  179.   v33 = sub_401220(v32, 11);
  180.   v120[9] = sub_401000(v33, 53);
  181.   v34 = sub_401000(v120[10], 49);
  182.   v35 = sub_401220(v34, 2);
  183.   v36 = sub_401000(v35, 4);
  184.   v120[10] = sub_401220(v36, 2);
  185.   v37 = sub_401100(v120[11], 1000000);
  186.   v38 = sub_401220(v37, 999999);
  187.   v39 = sub_401100(v38, 4);
  188.   v120[11] = sub_401000(v39, 50);
  189.   v40 = sub_401000(v120[12], 1);
  190.   v41 = sub_401000(v40, 1);
  191.   v42 = sub_401000(v41, 1);
  192.   v43 = sub_401000(v42, 1);
  193.   v44 = sub_401000(v43, 1);
  194.   v45 = sub_401000(v44, 1);
  195.   v46 = sub_401000(v45, 10);
  196.   v120[12] = sub_401000(v46, 32);
  197.   v47 = sub_401100(v120[13], 10);
  198.   v48 = sub_401220(v47, 5);
  199.   v49 = sub_401100(v48, 8);
  200.   v50 = sub_401000(v49, 9);
  201.   v120[13] = sub_401000(v50, 48);
  202.   v51 = sub_401220(v120[14], 1);
  203.   v52 = sub_401100(v51, -294967296);
  204.   v53 = sub_401000(v52, 55);
  205.   v120[14] = sub_401220(v53, 3);
  206.   v54 = sub_401000(v120[15], 1);
  207.   v55 = sub_401000(v54, 2);
  208.   v56 = sub_401000(v55, 3);
  209.   v57 = sub_401000(v56, 4);
  210.   v58 = sub_401000(v57, 5);
  211.   v59 = sub_401000(v58, 6);
  212.   v60 = sub_401000(v59, 7);
  213.   v120[15] = sub_401000(v60, 20);
  214.   v61 = sub_401100(v120[16], 10);
  215.   v62 = sub_401220(v61, 5);
  216.   v63 = sub_401100(v62, 8);
  217.   v64 = sub_401000(v63, 9);
  218.   v120[16] = sub_401000(v64, 48);
  219.   v65 = sub_401000(v120[17], 7);
  220.   v66 = sub_401000(v65, 6);
  221.   v67 = sub_401000(v66, 5);
  222.   v68 = sub_401000(v67, 4);
  223.   v69 = sub_401000(v68, 3);
  224.   v70 = sub_401000(v69, 2);
  225.   v71 = sub_401000(v70, 1);
  226.   v120[17] = sub_401000(v71, 20);
  227.   v72 = sub_401000(v120[18], 7);
  228.   v73 = sub_401000(v72, 2);
  229.   v74 = sub_401000(v73, 4);
  230.   v75 = sub_401000(v74, 3);
  231.   v76 = sub_401000(v75, 6);
  232.   v77 = sub_401000(v76, 5);
  233.   v78 = sub_401000(v77, 1);
  234.   v120[18] = sub_401000(v78, 20);
  235.   v79 = sub_401100(v120[19], 1000000);
  236.   v80 = sub_401220(v79, 999999);
  237.   v81 = sub_401100(v80, 4);
  238.   v82 = sub_401000(v81, 50);
  239.   v120[19] = sub_401220(v82, 1);
  240.   v83 = sub_401220(v120[20], 1);
  241.   v84 = sub_401100(v83, -294967296);
  242.   v85 = sub_401000(v84, 49);
  243.   v120[20] = sub_401220(v85, 1);
  244.   v86 = sub_401220(v120[21], 1);
  245.   v87 = sub_401100(v86, 1000000000);
  246.   v88 = sub_401000(v87, 54);
  247.   v89 = sub_401220(v88, 1);
  248.   v90 = sub_401000(v89, 1000000000);
  249.   v120[21] = sub_401220(v90, 1000000000);
  250.   v91 = sub_401000(v120[22], 49);
  251.   v92 = sub_401220(v91, 1);
  252.   v93 = sub_401000(v92, 2);
  253.   v120[22] = sub_401220(v93, 1);
  254.   v94 = sub_401100(v120[23], 10);
  255.   v95 = sub_401220(v94, 5);
  256.   v96 = sub_401100(v95, 8);
  257.   v97 = sub_401000(v96, 9);
  258.   v120[23] = sub_401000(v97, 48);
  259.   v98 = sub_401000(v120[24], 1);
  260.   v99 = sub_401000(v98, 3);
  261.   v100 = sub_401000(v99, 3);
  262.   v101 = sub_401000(v100, 3);
  263.   v102 = sub_401000(v101, 6);
  264.   v103 = sub_401000(v102, 6);
  265.   v104 = sub_401000(v103, 6);
  266.   v120[24] = sub_401000(v104, 20);
  267.   v105 = sub_401000(v120[25], 55);
  268.   v106 = sub_401220(v105, 33);
  269.   v107 = sub_401000(v106, 44);
  270.   v108 = sub_401220(v107, 11);
  271.   v120[25] = sub_401000(v108, 42);
  272.   v120[26] = sub_401000(v120[26], v120[25]);
  273.   v120[27] = sub_401000(v120[27], v120[12]);
  274.   v109 = v120[27];
  275.   v110 = sub_401220(v120[28], 1);
  276.   v111 = sub_401000(v110, v109);
  277.   v120[28] = sub_401220(v111, 1);
  278.   v112 = v120[23];
  279.   v113 = sub_401220(v120[29], 1);
  280.   v114 = sub_401100(v113, 1000000);
  281.   v120[29] = sub_401000(v114, v112);
  282.   v115 = v120[27];
  283.   v116 = sub_401000(v120[30], 1);
  284.   v120[30] = sub_401100(v116, v115);
  285.   v120[31] = sub_401000(v120[31], v120[30]);
  286.   printf("CTF{");
  287.   for ( j = 0; j < 32; ++j )
  288.     printf("%c", v120[j]);
  289.   printf("}\n");
  290.   return 0;
  291. }
复制代码

5.攻防世界:elrond32
  1. # import string
  2. a=[15, 31, 4, 9, 28, 18, 66, 9, 12, 68, 13, 7, 9, 6, 45, 55, 89, 30, 0, 89, 15, 8, 28, 35, 54, 7, 85, 2, 12, 8, 65, 10, 20]
  3. # T = 'iendagsr'
  4. T = 'isengard'

  5. for i in range(len(a)):
  6.     print(chr(a[i] ^ ord(T[i%len(T)])),end='')
复制代码

6.BUUCTF:[FlareOn4]IgniteMe
  1. byte_403000=[0x0D,0x26,0x49, 0x45, 0x2A, 0x17, 0x78, 0x44, 0x2B, 0x6C, 0x5D,0x5E, 0x45, 0x12, 0x2F, 0x17, 0x2B, 0x44, 0x6F, 0x6E, 0x56, 0x9,0x5F, 0x45, 0x47, 0x73, 0x26, 0x0A, 0x0D, 0x13, 0x17, 0x48, 0x42,0x1, 0x40, 0x4D, 0x0C, 0x2, 0x69, 0x0]
  2. flag=""
  3. L=len(byte_403000)-1
  4. for i in range(len(byte_403000)):
  5.     if i==0:
  6.        byte_403000[L-i]= byte_403000[L-i]^0x4
  7.     byte_403000[L-i-1] = byte_403000[L-i-1]^byte_403000[L-i]
  8.     flag+=chr(byte_403000[L-i])
  9. print(byte_403000)
  10. print(flag[::-1])

复制代码

7.BUUCTF:特殊的 BASE64
反编译后,查看主函数部分代码:
  1. int __cdecl main(int argc, const char **argv, const char **envp)
  2. {
  3.   __int64 v3; // rax
  4.   __int64 v4; // rax
  5.   std::string result; // [rsp+20h] [rbp-60h]
  6.   std::string rightFlag; // [rsp+30h] [rbp-50h]
  7.   std::string str; // [rsp+40h] [rbp-40h]
  8.   char v9; // [rsp+4Fh] [rbp-31h]
  9.   std::string v10; // [rsp+50h] [rbp-30h]

  10.   _main();
  11.   std::string::string(&str);
  12.   std::allocator<char>::allocator(&v9);
  13.   std::string::string(&rightFlag, "mTyqm7wjODkrNLcWl0eqO8K8gc1BPk1GNLgUpI==", &v9);
  14.   std::allocator<char>::~allocator(&v9);
  15.   v3 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "Please input your flag!!!!");
  16.   std::ostream::operator<<(v3, refptr__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_);
  17.   std::operator>><char,std::char_traits<char>,std::allocator<char>>(refptr__ZSt3cin, &str);
  18.   std::string::string(&v10, &str);
  19.   base64Encode(&result);
  20.   std::string::~string(&v10);
  21.   if ( std::operator==<char>(&result, &rightFlag) )
  22.     v4 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "The flag is right!!!!!!!!!");
  23.   else
  24.     v4 = std::operator<<<std::char_traits<char>>(refptr__ZSt4cout, "This is a wrong flag!!!!!!!!");
  25.   std::ostream::operator<<(v4, refptr__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_);
  26.   std::string::~string(&result);
  27.   std::string::~string(&rightFlag);
  28.   std::string::~string(&str);
  29.   return 0;
  30. }
复制代码
  1. std::string __cdecl base64Encode(std::string *p_decode)
  2. {
  3.   std::string *v1; // rdx
  4.   char *v2; // rax
  5.   int v3; // eax
  6.   int v4; // ebx
  7.   char *v5; // rax
  8.   int v6; // eax
  9.   int v7; // ebx
  10.   char *v8; // rax
  11.   int v9; // eax
  12.   _BYTE *v10; // rax
  13.   int v11; // eax
  14.   char *v12; // rax
  15.   int v13; // eax
  16.   _BYTE *v14; // rax
  17.   int v15; // eax
  18.   char *v16; // rax
  19.   int v17; // eax
  20.   int v18; // ebx
  21.   char *v19; // rax
  22.   int v20; // eax
  23.   _BYTE *v21; // rax
  24.   int v22; // eax
  25.   __int64 v24; // [rsp+0h] [rbp-80h]
  26.   char v25; // [rsp+2Fh] [rbp-51h]
  27.   int pos_0; // [rsp+30h] [rbp-50h]
  28.   int pos; // [rsp+34h] [rbp-4Ch]
  29.   int len; // [rsp+38h] [rbp-48h]
  30.   int i; // [rsp+3Ch] [rbp-44h]
  31.   std::string *p_encodeResult; // [rsp+60h] [rbp-20h]
  32.   std::string *p_decodea; // [rsp+68h] [rbp-18h]

  33.   p_encodeResult = p_decode;
  34.   p_decodea = v1;
  35.   std::allocator<char>::allocator((char *)&v24 + 47);
  36.   std::string::string(p_encodeResult, &unk_489084, &v25);
  37.   std::allocator<char>::~allocator(&v25);
  38.   len = std::string::length(p_decodea);
  39.   for ( i = 0; len / 3 > i; ++i )
  40.   {
  41.     v2 = (char *)std::string::operator[](p_decodea, 3 * i);
  42.     v3 = *(char *)std::string::operator[](&baseKey, *v2 >> 2);
  43.     std::string::operator+=(p_encodeResult);
  44.     v4 = 16 * (*(_BYTE *)std::string::operator[](p_decodea, 3 * i) & 3);
  45.     v5 = (char *)std::string::operator[](p_decodea, 3 * i + 1);
  46.     v6 = *(char *)std::string::operator[](&baseKey, v4 | (*v5 >> 4));
  47.     std::string::operator+=(p_encodeResult);
  48.     v7 = 4 * (*(_BYTE *)std::string::operator[](p_decodea, 3 * i + 1) & 0xF);
  49.     v8 = (char *)std::string::operator[](p_decodea, 3 * i + 2);
  50.     v9 = *(char *)std::string::operator[](&baseKey, v7 | (*v8 >> 6));
  51.     std::string::operator+=(p_encodeResult);
  52.     v10 = (_BYTE *)std::string::operator[](p_decodea, 3 * i + 2);
  53.     v11 = *(char *)std::string::operator[](&baseKey, *v10 & 0x3F);
  54.     std::string::operator+=(p_encodeResult);
  55.   }
  56.   if ( len % 3 == 1 )
  57.   {
  58.     pos = 3 * (len / 3);
  59.     v12 = (char *)std::string::operator[](p_decodea, 3 * (len / 3));
  60.     v13 = *(char *)std::string::operator[](&baseKey, *v12 >> 2);
  61.     std::string::operator+=(p_encodeResult);
  62.     v14 = (_BYTE *)std::string::operator[](p_decodea, pos);
  63.     v15 = *(char *)std::string::operator[](&baseKey, 16 * (*v14 & 3));
  64.     std::string::operator+=(p_encodeResult);
  65.     std::string::operator+=(p_encodeResult, "==");
  66.   }
  67.   if ( len % 3 == 2 )
  68.   {
  69.     pos_0 = 3 * (len / 3);
  70.     v16 = (char *)std::string::operator[](p_decodea, 3 * (len / 3));
  71.     v17 = *(char *)std::string::operator[](&baseKey, *v16 >> 2);
  72.     std::string::operator+=(p_encodeResult);
  73.     v18 = 16 * (*(_BYTE *)std::string::operator[](p_decodea, pos_0) & 3);
  74.     v19 = (char *)std::string::operator[](p_decodea, pos_0 + 1);
  75.     v20 = *(char *)std::string::operator[](&baseKey, v18 | (*v19 >> 4));
  76.     std::string::operator+=(p_encodeResult);
  77.     v21 = (_BYTE *)std::string::operator[](p_decodea, pos_0 + 1);
  78.     v22 = *(char *)std::string::operator[](&baseKey, 4 * (*v21 & 0xF));
  79.     std::string::operator+=(p_encodeResult);
  80.     std::string::operator+=(p_encodeResult, "=");
  81.   }
  82.   return (std::string)p_encodeResult;
  83. }
复制代码
最后编写python脚本进行解码:
  1. import base64
  2. str_1 = "mTyqm7wjODkrNLcWl0eqO8K8gc1BPk1GNLgUpI=="
  3. str_base = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0987654321/+"
  4. str_zh_base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  5. flag = base64.b64decode(str_1.translate(str.maketrans(str_base,str_zh_base)))
  6. print(flag)#flag{Special_Base64_By_Lich}'
复制代码

8.BUUCTF:[CFI-CTF 2018]IntroToPE
反编译后发现一个字符串Q0ZJey5OZXRDI18xc19AdzNzMG0zfQ==
直接base4解码,得到密码。


2#
发表于 2025-1-16 22:32:31 | 只看该作者
厉害。学习了。
回复

使用道具 举报

3#
发表于 2025-1-16 22:49:55 | 只看该作者
厉害!看不懂
回复

使用道具 举报

4#
发表于 2025-1-16 22:51:35 | 只看该作者
谢谢分享
回复

使用道具 举报

5#
发表于 2025-1-16 22:54:41 | 只看该作者
感謝大大分享!^^ 辛苦了!
回复

使用道具 举报

6#
发表于 2025-1-16 23:07:01 | 只看该作者
谢谢分享
回复

使用道具 举报

7#
发表于 2025-1-17 00:01:19 | 只看该作者
谢谢分享,支持个。
回复

使用道具 举报

8#
发表于 2025-1-17 07:23:42 | 只看该作者
感谢分享
回复

使用道具 举报

9#
发表于 2025-1-17 09:49:05 | 只看该作者
感谢分享
回复

使用道具 举报

10#
发表于 2025-1-17 09:52:11 | 只看该作者
厉害,谢谢楼主分享。
回复

使用道具 举报

11#
发表于 2025-1-17 11:37:24 | 只看该作者
谢谢分享
回复

使用道具 举报

12#
发表于 2025-1-17 21:27:39 | 只看该作者
谢谢楼主分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2025-2-1 12:56

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表