int tmp; //var_238
char Recv[]; //Data from server
char Decrypt[]; //0x41AE68
for(tmp=0;tmp<Len(Recv);tmp++) //Len(Recv)=0x5A
Decrypt[tmp]=Recv[tmp]^0x6E;
0x41AE68处存放解密后数据,长度为90 Bytes,跟进查看:
0X03 判断
上图红色方框中指令处理解密后数据。《加密与解密》随书文件中给出一Python脚本如下:
#coding=utf-8
##《加密与解密》第四版
##code by DarkNess0ut
import os
import sys
def Getasm(ea_from, ea_to, range1, range2):
fp = open("code.txt","w")
ea = ea_from
while ea < ea_to:
cmd = GetMnem(ea)
if cmd == "mov" or cmd == "lea":
opcode = Dword(NextNotTail(ea)-4)
if opcode < 0: #opcode < 0,处理 mov edx, [ebp-350]指令,否则处理mov edx, [ebp+350]
opcode = (~opcode + 1)
Message("-> %08X %08X\n" % (ea, opcode))
if range1 <= opcode <= range2:
delta = opcode - range1
MakeComm(ea, "// +0x%04X" % delta) # 加注释到IDA中
fp.write("%08X %s\n" % (ea, GetDisasm(ea)))
ea = NextNotTail(ea)
fp.close()
Message("OK!")
Getasm(0x401000,0x40F951,0x41AE68,0x41AEC1);