APK逆向2-WP

前言

  • 不要被题目给蒙蔽了,这根本不是 安卓 逆向!

分析

APK逆向2-WP_第1张图片

  • C# 编写的程序,用 dnspy 反编译

      using System;
      using System.Diagnostics;
      using System.IO;
      
      namespace Rev_100
      {
      	// Token: 0x02000002 RID: 2
      	internal class Program
      	{
      		// Token: 0x06000001 RID: 1
      		private static void Main(string[] args)
      		{
      			string arg_0B_0 = "Super Secret Key";
      			string text2 = Program.read();
      			string text3 = arg_0B_0;
      			string flag = "CTF{";
      			for (int i = 0; i < text3.Length; i++)
      			{
      				char x = text3[i];
      				flag += Program.search(x, text2);
      			}
      			flag += "}";
      			Console.WriteLine(flag);
      			Console.WriteLine("Success!");
      		}
      
      		// Token: 0x06000002 RID: 2
      		private static string read()
      		{
      			string[] expr_1F = Process.GetCurrentProcess().MainModule.FileName.Split(new char[]
      			{
      				'\\'
      			});
      			string arg_2B_0 = expr_1F[expr_1F.Length - 1];
      			string result = "";
      			using (StreamReader streamReader = new StreamReader(arg_2B_0))
      			{
      				result = streamReader.ReadToEnd();
      			}
      			return result;
      		}
      
      		// Token: 0x06000003 RID: 3
      		private static string search(char x, string text)
      		{
      			int length = text.Length;
      			for (int i = 0; i < length; i++)
      			{
      				if (x == text[i])
      				{
      					return Convert.ToString(i * 1337 % 256, 16).PadLeft(2, '0');
      				}
      			}
      			return "??";
      		}
      	}
      }
    
  • 程序很简单,就是连接本地服务器,然后读取自身数据传到 Search() 函数中做个变换,将结果一一发送给服务器。

  • 这里有个坑需要注意,因为是读取自身数据,我们不能重构他的代码,否则编译出来的程序数据回合原来的不一致!

  • 所以这里涉及到一个小技巧,就是用 pythonhttp 模块搭建一个服务器来接受程序发来的数据。

脚本

import http.server
server_address = ('127.0.0.1', 31337)
handler_class = http.server.BaseHTTPRequestHandler
Server = http.server.HTTPServer(server_address, handler_class)
Server .serve_forever()

在这里插入图片描述

你可能感兴趣的:(逆向)