网站首页 > 易语言相关 > 易语言图文教程 正文
pcqq协议 0836中有一个official算法,貌似和稳定性有关,汇编代码为
mov eax, [ebp+0Ch]
mov eax, [eax]
add eax, 08h
push eax
mov edx, [ebp+08h]
mov edx, [edx]
add edx, 08h
mov ecx, [ebp+10h]
mov ecx, [ecx]
add ecx, 08h
call 00000024Ch
mov esp, ebp
pop ebp
retn 000Ch
sub esp, 14h
mov eax, [edx]
push ebx
mov [esp+14h], ecx
mov ebx, 00000010h
mov ecx, [esp+1Ch]
push ebp
push esi
mov esi, [edx+04h]
mov edx, [ecx+04h]
mov [esp+0Ch], edx
mov edx, [ecx]
mov ebp, [esp+0Ch]
mov [esp+10h], edx
mov edx, [ecx+0Ch]
mov ecx, [ecx+08h]
push edi
bswap esi
bswap eax
mov edi, 9E3779B9h
mov [esp+1Ch], edx
mov [esp+18h], ecx
mov edx, esi
mov ecx, esi
shr edx, 05h
shl ecx, 04h
add edx, ebp
add ecx, [esp+14h]
xor edx, ecx
lea ecx, [esi+edi]
xor edx, ecx
add eax, edx
mov edx, eax
mov ecx, eax
shl edx, 04h
add edx, [esp+18h]
shr ecx, 05h
add ecx, [esp+1Ch]
xor edx, ecx
lea ecx, [eax+edi]
xor edx, ecx
lea edi, [edi-61C88647h]
add esi, edx
dec ebx
jne 00000041h
mov ebp, [esp+20h]
bswap esi
pop edi
bswap eax
mov [ebp+04h], esi
mov [ebp+00h], eax
mov eax, ebp
pop esi
pop ebp
pop ebx
add esp, 14h
retn 0004h
翻译成c++:
#include "stdafx.h"
typedef unsigned char BYTE;
BYTE* Long2Bytes(unsigned long n);
unsigned long Bytes2Long(BYTE *bytes);
BYTE* ReverseBytes(BYTE* data, int size);
void Official(BYTE *data, BYTE *key, BYTE *result);
BYTE* SubBytes(BYTE *bytes, int start, int count);
void PrintBytes(BYTE *bytes, int size);
int _tmain(int argc, _TCHAR* argv[])
{
BYTE *data = new BYTE[8]{1, 2, 3, 4, 5, 6, 7, 8};//要加密的数据
BYTE *key = new BYTE[16]{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};//加密key
BYTE *result = new BYTE[8]{0};//加密结果
Official(data, key, result);
PrintBytes(result,8);
delete[] data;
delete[] key;
delete[] result;
getchar();
return 0;
}
void PrintBytes(BYTE *bytes, int size){
for (int i = 0; i < size; i++){
printf("%d ",bytes[i]);
}
}
void Official(BYTE *data, BYTE *key, BYTE *result){
unsigned long eax = Bytes2Long(SubBytes(data,0,4));
unsigned long esi = Bytes2Long(SubBytes(data, 4, 4));
unsigned long var4 = Bytes2Long(ReverseBytes(SubBytes(key, 0, 4), 4));
unsigned long ebp = Bytes2Long(ReverseBytes(SubBytes(key, 4, 4), 4));
unsigned long var3 = Bytes2Long(ReverseBytes(SubBytes(key, 8, 4), 4));
unsigned long var2 = Bytes2Long(ReverseBytes(SubBytes(key, 12, 4), 4));
//printf("%lu %lu %lu %lu %lu %lu\n", eax,esi,var4, ebp, var3, var2);
unsigned long edi = 0x9E3779B9;
unsigned long edx = 0;
unsigned long ecx = 0;
for (int i = 0; i < 16; i++){
edx = esi;
ecx = esi;
edx = edx >> 5;
ecx = ecx << 4;
edx += ebp;
ecx += var4;
edx = edx ^ ecx;
ecx = esi + edi;
edx = edx ^ ecx;
eax += edx;
edx = eax;
ecx = eax;
edx = edx << 4;
edx = edx + var3;
ecx = ecx >> 5;
ecx += var2;
edx = edx ^ ecx;
ecx = eax + edi;
edx = edx ^ ecx;
edi -= 0x61C88647;
esi += edx;
}
memcpy(result,Long2Bytes(eax), 4);
memcpy(result+4, Long2Bytes(esi), 4);
}
BYTE* Long2Bytes(unsigned long n){
BYTE *temp = new BYTE[4];
temp[0] = n / 16777216;
temp[1] = (n - temp[0] * 16777216)/65536;
temp[2] = (n - temp[0] * 16777216 - temp[1] * 65536) / 256;
temp[3] = (n - temp[0] * 16777216 - temp[1] * 65536-temp[2]*256);
return temp;
}
unsigned long Bytes2Long(BYTE *bytes){
unsigned long a =bytes[0] * 16777216;
unsigned long b = bytes[1] * 65536;
unsigned long c = bytes[2] * 256;
unsigned long d = bytes[3];
unsigned long n = a + b + c + d;
return n;
}
//因为数据在内存中是从低到高存放的,所以要反取字节
BYTE* ReverseBytes(BYTE* bytes, int size){
BYTE *temp = new BYTE[size];
for (int i = 0; i < size; i++){
temp[i] = bytes[size - i - 1];
}
return temp;
}
BYTE* SubBytes(BYTE* bytes, int start, int count){
BYTE *temp = new BYTE[count];
for (int i = 0; i < count; i++){
temp[i] = bytes[start + i];
}
return temp;
}
来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:21414575 )
- 上一篇: TP-link登陆JS加密源码
- 下一篇: 网易云音乐登录易语言源码
猜你喜欢
- 2022-03-17 微信【3.5.0.46】版本消息基址
- 2020-12-19 易语言学习
- 2019-09-04 VBoxManage 命令行使用
- 2019-04-04 pcqq official汇编算法翻译
- 2018-12-02 易语言应用XP注册表解释文档
- 2018-10-08 易语言支持库开发文档
- 2018-10-03 程序进程和线程基础知识
- 2018-09-30 Windows XP注册表修改精粹
- 2018-09-30 SQL数据库完全操作手册
- 2018-09-29 EXCEL编程手册
你 发表评论:
欢迎- 百度站内搜索
- 关注微信公众号
- 网站分类
-
- 网站公告
- 电子书书籍
- 程序员工具箱
- 编程工具
- 易语言相关
- 网络相关源码
- 图形图像源码
- 系统工具源码
- 易语言模块源码
- 易语言支持库
- 数据库类源码
- 易语言例程
- 易语言游戏开发
- 易语言模块
- 多媒体类源码
- 易语言资源网
- 易语言视频教程
- JS分析教程
- 易语言图文教程
- 易语言常见问题及笔记
- 工具源码
- 易语言版本
- 网络编程
- javascript
- PHP编程
- html
- 正则表达式
- 面试题
- nodejs
- 其它综合
- 脚本专栏
- python
- 按键精灵相关
- 按键精灵图文教程
- 按键精灵视频教程
- 按键精灵Q语言
- 按键精灵安卓版
- golang
- 游戏安全
- 火山相关
- 火山安卓软件
- 火山常见问题及笔记
- 火山安卓源码
- 火山视频教程
- 火山PC版本下载
- 火山PC视窗例程
- 互联网那些事
- 引流推广
- 项目揭秘
- 网络营销
- 营销软件
- QQ营销软件
- 娱乐软件
- 机器人插件
- 培训教程
- 技术教程
- 活动线报
- 数据库
- Redis
- Access
- MongoDB
- Mysql
- 问答
- 其它
- 易语言
- 在线教程
- 多线程培训班
- 觅风易语言教程
- 模拟系列教程
- 集中营易语言教程
- 历史数据
- 需求
- 随机tag
- 最新评论
-
演示站点已关闭,请自行搭建。可以使用ng的反向d理实现绑定多域名纠正:参数type:0代表删除,1增加,2修改,4cha询
三叶资源网 评论于:03-03访客 评论于:08-29
访客 评论于:07-31
stanlyjin 评论于:07-29
stanlyjin 评论于:07-29
访客 评论于:07-29
访客 评论于:07-13
访客 评论于:07-11
访客 评论于:07-01
访客 评论于:06-27
已有2位网友发表了看法:
易语言教程下载 评论于 [2019-09-03 12:14:15] 回复
pcqq 0836
易语言例子 评论于 [2019-09-14 15:40:29] 回复
易语言+official算法