攻防世界WP-reverse-getitcsaw2013reversing2

本文详细解析了通过逆向工程解决程序弹出乱码窗口的问题,从查壳、IDA伪代码分析到使用OD调试,逐步揭露隐藏的flag信息。通过对函数sub_40102A和sub_401000的研究,最终找到了关键的EDX值,成功揭示了flag。

打开之后弹乱码
在这里插入图片描述第一步还是查壳,没有。
第二步拖入IDA,直接看伪代码吧

int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
  int v3; // ecx
  CHAR *lpMem; // [esp+8h] [ebp-Ch]
  HANDLE hHeap; // [esp+10h] [ebp-4h]

  hHeap = HeapCreate(0x40000u, 0, 0);
  lpMem = (CHAR *)HeapAlloc(hHeap, 8u, MaxCount + 1);
  memcpy_s(lpMem, MaxCount, &unk_409B10, MaxCount);
  if ( sub_40102A() || IsDebuggerPresent() )
  {
    __debugbreak();
    sub_401000(v3 + 4, lpMem);
    ExitProcess(0xFFFFFFFF);
  }
  MessageBoxA(0, lpMem + 1, "Flag", 2u);
  HeapFree(hHeap, 0, lpMem);
  HeapDestroy(hHeap);
  ExitProcess(0);
}

最开始看到了IsDebuggerPresent,我以为要跳过这个检测,所以没有管它。注意到memcpy_s(lpMem, MaxCount, &unk_409B10, MaxCount);,然后看看&unk_409B10,结果发现这个就是乱码。
然后点开sub_40102A,发现这个函数永远return 0if判断永远不成立,推测if里面的这个函数sub_401000,很有可能出flag,我们看看这个函数。

unsigned int __fastcall sub_401000(int a1, int a2)
{
  int v2; // esi
  unsigned int v3; // eax
  unsigned int v4; // ecx
  unsigned int result; // eax

  v2 = dword_409B38;
  v3 = a2 + 1 + strlen((const char *)(a2 + 1)) + 1;
  v4 = 0;
  result = ((v3 - (a2 + 2)) >> 2) + 1;
  if ( result )
  {
    do
      *(_DWORD *)(a2 + 4 * v4++) ^= v2;
    while ( v4 < result );
  }
  return result;
}

但是我搞不清楚a1的值,也就是外面v3的值为多少,所以用OD直接跑一跑。
我们首先在IDA中rebase program,方便查看。在OD里面查看e模块,得到基址,然后在IDA中修改。
我们先在OD里面找这个if在哪
在这里插入图片描述可以看到在1221096附近,我们ctrl+g在OD中跳转。
在这里插入图片描述在上方JNZ处下一个断点,让程序跑到这。je会跳转,但是我们想要运行下面的函数,所以不让它跳。int3也要nop掉,不然程序会中断。
然后我们进入关键的函数
在这里插入图片描述
retn上面下一个断点。直接运行,查看EDX中的值
在这里插入图片描述可知flag。

### CTF Reversing x64 ELF 100 Challenge Solution and Hints For the reversing challenge involving an x64 ELF file, understanding how to interpret hexadecimal strings as ASCII characters is crucial. When faced with a string that appears nonsensical at first glance but contains digits from `0` through `F`, it suggests dealing with hexadecimal encoding. Converting such hex values into their corresponding ASCII representations can reveal hidden messages or flags required by challenges. In this specific case, converting each pair of hexadecimal digits (like `66`) into decimal yields ASCII codes which translate directly into readable text characters; for instance, `66` becomes `102` in decimal, representing 'f' according to the ASCII standard[^1]. Following similar conversions (`6c` -> `110` -> 'n'), one might deduce part of the flag format expected within these types of puzzles—often enclosed between curly braces following "flag". Regarding handling ELF files specifically, knowledge about the structure including headers like `ELF64_Ehdr` and sections described via structures such as `ELF64_Shdr` proves beneficial when attempting reverse engineering tasks on binaries formatted under the Executable and Linkable Format specification used primarily across Unix-like systems[^2]. To tackle this particular level effectively: - Examine any provided binary using tools designed for analyzing ELF executables. - Look out for embedded strings or data segments containing potential clues encoded similarly to what was discussed earlier regarding hexadecimal-to-text conversion. - Utilize debugging utilities alongside disassemblers to trace execution flow while paying attention to operations manipulating input/output streams where flags could be checked against user-supplied answers during runtime. ```bash # Example command line tool usage for inspecting ELF binaries readelf -h your_binary_file # Display the ELF header information strings your_binary_file # Extract printable character sequences possibly hinting towards solutions ``` --related questions-- 1. What are common methods employed in decoding obfuscated texts found inside executable programs? 2. How does one approach decompiling or disassembling different architectures beyond just x86_64? 3. Can you explain more about the significance of various fields present within the ELF header concerning program loading and linking processes?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wallacegen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值