// **gs初始化
public void doInit()
{
//init
System.out.println("=== init begin ====");
Object[] init_param = new Object[1];
Integer init = 103;
DvmObject<?> ret = module.callStaticJniMethodObject(
emulator, "main(I[Ljava/lang/Object;)[Ljava/lang/Object;",
init,
ProxyDvmObject.createObject(vm, init_param));
System.out.println("=== init end ====");
}
//patch C0 53 00 B5, 将反转条件跳转CBZ-->CBNZ 会报:[main]E/**G: [make_header:491] [-] Error pp not init
byte[] CBNZ = new byte[]{(byte) 0xC0, (byte)0x53, (byte)0x00, (byte)0xB5};
UnidbgPointer p = UnidbgPointer.pointer(emulator,dm.getModule().base + 地址);
p.write(CBNZ);
MyDbg.addBreakPoint(dm.getModule(), 地址, (emulator, address) -> {
System.out.println("====== patch 反转条件跳转CBZ-->CBNZ ======");
return true;
});//干掉一个free (这个会影响结果) 会报:[main]E/**G: [make_header:491] [-] Error pp not init
byte[] NOP = new byte[]{(byte)0xC1F, (byte)0xC20, (byte)0xC03, (byte)0xD5};
UnidbgPointer p = UnidbgPointer.pointer(emulator,dm.getModule().base + 地址 );
p.write(NOP);
MyDbg.addBreakPoint(dm.getModule(), 地址, (emulator, address) -> {
System.out.println("======= 干掉一个free =======");
return true;
});
{
"b1":".**g.xbt文件名",
"b2":"***",
"b3":"***",
"b4":"yY8lbpaUOZeQ3fyCiccRrM66O+Nzo/mhwP4wIa8C8JOZ6aJgSdfTJl2a6Q4oeMBx+2P4ySmoN/AtDHutJNGd/lImZaXQkwd00ZyfFGn2PmTk4uorMcnQUrKbmPRHlcKx6iOwmt8RoYf9C7l7bGWQ/COl6HcUT199wCWGjI5+u4mxfvLmiCSqhJ8qbLgVx9KQrRLXW1oDY1sf1RdNl1cYe6GfpF8kwgNMQJif9EIUBw0Td64cduT7MKAFjA3oew02IyWX2aSJaOuWaULTUqO4al9SIyRYojxQCEiMzF5UMxV6Zwu2lw1uZ6+22fJgxbEBv2LeGUpPPzXGF6E2vC0vb9sE5in3CkrKHwM+QfA5CasSPwpAmzQyr5iGyl9o6g==",
"b5":"7e640fcb8293d390b3758974b75e9dad5082bed9",
"b7":"1724176633106",
"b6":"30ed898f8d129b6d16c3f0c49efae07e8de4ee0e"}
// 固定时间戳 修改获取毫秒时间戳系统函数返回值十六进制
hook.replace(dm.getModule().base + 地址, new ReplaceCallback() {
@Override
public HookStatus onCall(Emulator<?> emulator, long originFunction) {
return super.onCall(emulator, originFunction);
}@Override
public HookStatus onCall(Emulator<?> emulator, HookContext context, long originFunction) {
System.out.println("\n=========== HooZz 修改固定时间戳 =========\n");
return super.onCall(emulator, context, originFunction);
}@Override
public void postCall(Emulator<?> emulator, HookContext context) {
long a = (long) emulator.getBackend().reg_read(Arm64Const.UC_ARM64_REG_X0);
System.out.println("修改前时间戳:"+Long.toHexString(a));
emulator.getBackend().reg_write(Arm64Const.UC_ARM64_REG_W0,0x18f70ef8d12L);
System.out.println("修改后时间戳:"+ Long.toString(0x18f70ef8d12L,16));
}
},true);
# 压缩算法
def fun_compress(self, json):
# json_len=len(json)
# # 使用compressBound计算压缩后的最大可能字节数
# comp_bound = zlib.compressBound(json_len)
# 使用compress方法压缩数据
comp_data = zlib.compress(json.encode('utf-8'))
return bytearray(comp_data)
# salt = 时间戳+一段0x28固定值
def fun_sf(self, salt):
salt = bytearray(salt, "utf-8")
# 使用列表推导式创建一个从0到255的整数列表
int_list = [i for i in range(256)]
# 将整数列表转换为 bytearray
ret_arr = bytearray(int_list) # X0var2 = 0 # W11
salt_len = len(salt) # W10
for i in range(0x100):
# print(f"{i:02x}")
salt_chunk = int(i / salt_len) # W13 SDIV W13, W10, W2
ret_i = ret_arr[i] # W12 LDRB W12, [X0,X10]
salt_chunk = i - salt_chunk * salt_len # W13 MSUB W13, W13, W2, W10
salt_chunk = salt[salt_chunk] # W13 LDRB W13, [X1,W13,UXTW]
var2 = ret_i + var2 # W11 ADD W11, W12, W11
var2 = var2 + salt_chunk # W11 ADD W11, W11, W13salt_chunk = var2 & 0xff # X13 AND X13, X11, #0xFF
ret_arr[i] = ret_arr[salt_chunk] # W14 LDRB W14, [X0,X13]
# W13 STRB W14, [X0,X10]
ret_arr[salt_chunk] = ret_i # W12 STRB W12, [X0,X13]return ret_arr
# 寄存器格式为dword格式
def tool_range0xff(self, var):
return var & 0xff
def fun_xor(self, buf_sf, comp_json):
buf_sf.append(0) # 扩容到0x102
buf_sf.append(0) # 扩容到0x102
self.**gstools.tool_bytearray2str(buf_sf)
comp_json_len = len(comp_json)
i = 0
# try:
while True:
comp_json_len -= 1 # SUBS X10, X10, #1 ; X0=X0-1=--len
buf_0x100 = self.**gstools.tool_range0xff(
buf_sf[0x100]) # LDRB W11, [X0,#0x100] ; W11=X0[0x100]=buf[0x100]
buf_0x101 = self.**gstools.tool_range0xff(
buf_sf[0x101]) # LDRB W12, [X0,#0x101] ; W12=buf_0x101 =X0[0x101]=*(buf + 0x101);buf_0x100_i = self.**gstools.tool_range0xff(
buf_0x100 + 1) # ADD W11, W11, #1 ; W11=W11+1=buf[0x100]+1buf_sf[0x100] = buf_0x100_i # STRB W11, [X0,#0x100] ; X0[0x100]=W11
buf_0x100_i = buf_0x100_i & 0xff # AND X11, X11, #0xFF ; X11=W11&0xff
buf_var = self.**gstools.tool_range0xff(
buf_sf[buf_0x100_i]) # LDRB W13, [X0,X11] ; W13=X0[X11]
buf_0x101 = buf_0x101 + buf_var # ADD W12, W12, W13 ; W12=W12+W13buf_sf[0x101] = self.**gstools.tool_range0xff(
buf_0x101) # STRB W12, [X0,#0x101] ; X0[0x101]=W12
buf_0x101 = buf_0x101 & 0xff # AND X12, X12, #0xFF ; X12=X12&0xffbuf_var = self.**gstools.tool_range0xff(
buf_sf[buf_0x101]) # LDRB W13, [X0,X12] ; W13=X0[X12]
var = self.**gstools.tool_range0xff(
buf_sf[buf_0x100_i]) # LDRB W14, [X0,X11] ; W14=X0[X11]
buf_sf[buf_0x100_i] = buf_var # STRB W13, [X0,X11] ; X0[X11]=W13
buf_sf[buf_0x101] = var # STRB W14, [X0,X12] ; X0[X12]=W14
buf_0x100_i = self.**gstools.tool_range0xff(
buf_sf[0x100]) # LDRB W11, [X0,#0x100] ; W11=X0[0x100]
buf_0x101 = self.****gstools.tool_range0xff(
buf_sf[0x101]) # LDRB W12, [X0,#0x101] ; W12=X0[0x101]
buf_0x100_i = self.**gstools.tool_range0xff(
buf_sf[buf_0x100_i]) # LDRB W11, [X0,X11] ; W11=X0[X11]
buf_0x101 = self.**gstools.tool_range0xff(
buf_sf[buf_0x101]) # LDRB W12, [X0,X12] ; W12=X0[X12]var_comp_json = self.**gstools.tool_range0xff(
comp_json[i]) # LDRB W13, [X1],#1 ; W13=*X1+1
# i += 1buf_0x100_i = buf_0x101 + buf_0x100_i # ADD W11, W12, W11 ; W11=W12+W11
buf_0x100_i = buf_0x100_i & 0xFF # AND X11, X11, #0xFF ; X11=X11&0xFFbuf_0x100_i = self.**gstools.tool_range0xff(
buf_sf[buf_0x100_i]) # LDRB W11, [X0,X11] ; W11=X0[X11]
buf_0x100_i = buf_0x100_i ^ var_comp_json # EOR W11, W11, W13 ; W11=W11^W13comp_json[i] = buf_0x100_i # STRB W11, [X2],#1 ; *X2+1=W11
i += 1
# print(f"i:{hex(i)} {hex(buf_0x100_i)}")
# comp_json[i] = buf_sf[buf_sf[buf_sf[0x101]] + buf_sf[buf_sf[0x100]]] ^ var_comp_jsonif comp_json_len == 0:
break
# except:
# print("error i:",i)return comp_json
def fun_base64(self, comp_json):
ret = base64.b64encode(comp_json)
return ret
b4 = comp_json.decode('utf-8')
self.b1 = ".**g.xbt文件名" # jpg文件名 版本固定
# xbt字节加密iv 版本固定(需要判断下)
self.xbt_eny = "5A 36 58 38 65 66 74 42 4E 6D 53 35 56 4B 6F 47 71 53 2F 71 34 70 44 53 36 76 72 32 53 4B 76 74 34 61 31 49 65 61 37 67 6A 54 35 52 64 32 4C 2F 65 39 76 78 4D 6D 74 69 78 58 57 75 72 75 2B 68"# 这个函数xbt & body 字节加密
def fun_body_eny(self, comm_body, enc):
# print("准备加密body:",comm_body)
logger.debug("准备加密body:{}".format(comm_body))
comm_arr = bytearray(comm_body, 'utf-8')
enc_arr = self.**gstools.tool_str2bytearr(enc)
comm_len = len(comm_arr)
enc_len = len(enc_arr)buf = bytearray(comm_arr)
i = 0
if comm_len <= enc_len:
while True:v14 = self.**gstools.tool_range0xff(enc_arr[i])
v13 = self.**gstools.tool_range0xff(i // comm_len)
var = self.**gstools.tool_range0xff(i - v13 * comm_len)
v15 = self.**gstools.tool_range0xff(comm_arr[var])i += 1
buf[var] = self.**gstools.tool_range0xff(v14 ^ v15)
# print(f"i:{hex(i)},v14:{hex(v14)},v15:{hex(v15)},v14 ^ v15:{hex(v14 ^ v15)}")
if i == enc_len:
break
else:
while True:
v11 = self**dgstools.tool_range0xff(comm_arr[i])var = self.**gstools.tool_range0xff(i - (i // enc_len) * enc_len)
v12 = self.**gstools.tool_range0xff(enc_arr[var])buf[i] = self.**gstools.tool_range0xff(v11 ^ v12)
i += 1
if i == comm_len:
breakreturn buf
self.body_eny = self.fun_body_eny(self.b1, self.xbt_eny)
# comm_body加密
body_eny = self.fun_body_eny(body, self.body_eny)
# md5算法
def fun_md5(self, buf):
var_mad5 = hashlib.md5()
var_mad5.update(buf.encode("utf-8"))return var_mad5.hexdigest()
def fun_aes(self, plaintext, key, iv): # 对明文进行填充,使其长度为16的倍数
padded_plaintext = pad(plaintext, AES.block_size)
# 创建AES的CBC模式对象
cipher = AES.new(key, AES.MODE_CBC, iv)
# 加密 bytes
ciphertext = cipher.encrypt(padded_plaintext)
return ciphertext
# sha1加密
def fun_sha1(self, commbody_aes):
sha1 = hashlib.sha1()
sha1.update(commbody_aes)
# print(sha1.hexdigest())
return sha1.hexdigest()
# b6_data = '{"b1":"{}","b2":"{}","b3":"{}","b4":"{}","b5":"{}","b7":"{}","b6":"{}"}' % b1,b2,b3,b4,b5,b7
看雪ID:YongG一G
https://bbs.kanxue.com/user-home-800845.htm
# 往期推荐
2、恶意木马历险记
球分享
球点赞
球在看
点击阅读原文查看更多