吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 16527|回复: 13
收起左侧

[分享] YT88加密狗 增强算法(TEA算法) c#开发源代码

  [复制链接]
teety 发表于 2015-12-27 03:38
本帖最后由 teety 于 2015-12-27 03:47 编辑

//公共函数说明
//***查找加密锁
//int FindPort(int start, ref string OutKeyPath);
//查找指定的加密锁(使用普通算法一)
//int FindPort_2(int start, int in_data, int verf_data, ref string OutKeyPath);
//***获到锁的版本
//int NT_GetIDVersion(ref short version,  string KeyPath);
//获到锁的扩展版本
//int NT_GetIDVersionEx(ref short version,  string KeyPath);
//***获到锁的ID
//int GetID(ref int id_1, ref int id_2, string KeyPath);
//***从加密锁中读取一批字节
//int YReadEx(byte[] OutData, short Address, short mylen, string HKey, string LKey, string KeyPath);
//***从加密锁中读取一个字节数据,一般不使用
//int YRead(ref byte OutData, short Address,string HKey, string LKey, string KeyPath);
//***写一批字节到加密锁中
//int YWriteEx(byte[] InData, short Address, short mylen, string HKey, string LKey, string KeyPath);
//***写一个字节的数据到加密锁中,一般不使用
//int YWrite(byte InData, short Address, string HKey, string LKey, string KeyPath);
//***从加密锁中读字符串
//int YReadString(ref string outstring, short Address, short mylen, string HKey, string LKey, string KeyPath);
//***写字符串到加密锁中
//int YWriteString(string InString, short Address, string HKey, string LKey, string KeyPath);
//***算法函数
//int sWriteEx(int in_data , ref int out_data , string KeyPath);
//int sWrite_2Ex(int in_data , ref int out_data ,string KeyPath);
//int sRead(ref int in_data, string KeyPath);
//int sWrite(int out_data, string KeyPath);
//int sWrite_2(int out_data, string KeyPath);
//***设置写密码
//int SetWritePassword(string W_HKey, string W_LKey, string new_HKey, string new_LKey, string KeyPath);
//***设置读密码
//int SetReadPassword(string W_HKey, string W_LKey, string new_HKey, string new_LKey, string KeyPath);
//'设置增强算法密钥一
//int SetCal_2(string Key , string KeyPath);
//使用增强算法一对字符串进行加密
//int EncString(string InString , ref string outstring , string KeyPath);
//使用增强算法一对二进制数据进行加密
// int Cal(byte[] InBuf, byte[] OutBuf, string KeyPath);
//'设置增强算法密钥二
//int SetCal_New(string Key , string KeyPath);
//使用增强算法二对字符串进行加密
//int EncString_New(string InString , ref string outstring , string KeyPath);
//使用增强算法二对二进制数据进行加密
// int Cal_New(byte[] InBuf, byte[] OutBuf, string KeyPath);
//***初始化加密锁函数
//int ReSet( string Path);
//***获取字符串长度
//int lstrlenA(string InString );

        public void EnCode(byte[] inb, byte[] outb, string Key)//TEA算法加密 程序:增强算法
        {
            UInt32 cnDelta, y, z, a, b, c, d, temp_2;
            UInt32[] buf = new UInt32[16];
            int n, i, nlen;
            UInt32 sum;
            //UInt32 temp, temp_1;
            string temp_string;

            cnDelta = 2654435769;
            sum = 0;
            nlen = Key.Length;
            i = 0;
            for (n = 1; n <= nlen; n = n + 2)
            {
                temp_string = Key.Substring(n - 1, 2);
                buf = HexToInt(temp_string);
                i = i + 1;
            }
            a = 0; b = 0; c = 0; d = 0;
            for (n = 0; n <= 3; n++)
            {
                a = (buf[n] << (n * 8)) | a;
                b = (buf[n + 4] << (n * 8)) | b;
                c = (buf[n + 4 + 4] << (n * 8)) | c;
                d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
            }

            y = 0;
            z = 0;
            for (n = 0; n <= 3; n++)
            {
                temp_2 = inb[n];
                y = (temp_2 << (n * 8)) | y;
                temp_2 = inb[n + 4];
                z = (temp_2 << (n * 8)) | z;
            }

            n = 32;
            while (n > 0)
            {
                sum = cnDelta + sum;
                /*temp = (z << 4) & 0xFFFFFFFF;
                temp = (temp + a) & 0xFFFFFFFF;
                temp_1 = (z + sum) & 0xFFFFFFFF;
                temp = (temp ^ temp_1) & 0xFFFFFFFF;
                temp_1 = (z >> 5) & 0xFFFFFFFF;
                temp_1 = (temp_1 + b) & 0xFFFFFFFF;
                temp = (temp ^ temp_1) & 0xFFFFFFFF;
                temp = (temp + y) & 0xFFFFFFFF;
                y = temp & 0xFFFFFFFF;*/
                y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
                /*temp = (y << 4) & 0xFFFFFFFF;
                temp = (temp + c) & 0xFFFFFFFF;
                temp_1 = (y + sum) & 0xFFFFFFFF;
                temp = (temp ^ temp_1) & 0xFFFFFFFF;
                temp_1 = (y >> 5) & 0xFFFFFFFF;
                temp_1 = (temp_1 + d) & 0xFFFFFFFF;
                temp = (temp ^ temp_1) & 0xFFFFFFFF;
                temp = (z + temp) & 0xFFFFFFFF;
                z = temp & 0xFFFFFFFF;*/
                z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
                n = n - 1;
            }
            for (n = 0; n <= 3; n++)
            {
                outb[n] = System.Convert.ToByte((y >> (n * 8)) & 255);
                outb[n + 4] = System.Convert.ToByte((z >> (n * 8)) & 255);
            }
        }
        public void DeCode(byte[] inb, byte[] outb, string Key)//TEA算法解密 程序:增强算法
        {
            UInt32 cnDelta, y, z, a, b, c, d, temp_2;
            UInt32[] buf = new UInt32[16];
            int n, i, nlen;
            UInt32 sum;
            //UInt32 temp, temp_1;
            string temp_string;

            cnDelta = 2654435769;
            sum = 0xC6EF3720;
            nlen = Key.Length;
            i = 0;
            for (n = 1; n <= nlen; n = n + 2)
            {
                temp_string = Key.Substring(n - 1, 2);
                buf = HexToInt(temp_string);
                i = i + 1;
            }
            a = 0; b = 0; c = 0; d = 0;
            for (n = 0; n <= 3; n++)
            {
                a = (buf[n] << (n * 8)) | a;
                b = (buf[n + 4] << (n * 8)) | b;
                c = (buf[n + 4 + 4] << (n * 8)) | c;
                d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
            }

            y = 0;
            z = 0;
            for (n = 0; n <= 3; n++)
            {
                temp_2 = inb[n];
                y = (temp_2 << (n * 8)) | y;
                temp_2 = inb[n + 4];
                z = (temp_2 << (n * 8)) | z;
            }

            n = 32;
            while (n-- > 0)
            {
                z -= ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d);
                y -= ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b);
                sum -= cnDelta;
            }
            for (n = 0; n <= 3; n++)
            {
                outb[n] = System.Convert.ToByte((y >> (n * 8)) & 255);
                outb[n + 4] = System.Convert.ToByte((z >> (n * 8)) & 255);
            }
        }

        public string StrEnc(string InString, string Key)//使用增强算法,加密字符串 通过程序直接加密,不通过狗
        {
            byte[] b, outb;
            byte[] temp = new byte[8], outtemp = new byte[8];
            int n, i, nlen, outlen;
            string outstring;

            nlen = lstrlenA(InString) + 1;
            if (nlen < 8)
                outlen = 8;
            else
                outlen = nlen;
            b = new byte[outlen];
            outb = new byte[outlen];
            CopyStringToByte(b, InString, nlen);
            b.CopyTo(outb, 0);
            for (n = 0; n <= outlen - 8; n = n + 8)
            {
                for (i = 0; i < 8; i++) temp = b[i + n];
                EnCode(temp, outtemp, Key);//TEA算法加密
                for (i = 0; i < 8; i++) outb[i + n] = outtemp;
            }
            outstring = "";
            for (n = 0; n <= outlen - 1; n++)
            {
                outstring = outstring + outb[n].ToString("X2");
            }
            return outstring;
        }
        public string StrDec(string InString, string Key) //使用增强算法,解密字符串 通过程序直接解密,不通过狗
        {
            byte[] b, outb;
            byte[] temp = new byte[8], outtemp = new byte[8];
            int n, i, nlen, outlen;
            string temp_string;
            StringBuilder c_str;

            nlen = InString.Length;
            if (nlen < 16) outlen = 16;
            outlen = nlen / 2;
            b = new byte[outlen];
            outb = new byte[outlen];
            i = 0;
            for (n = 1; n <= nlen; n = n + 2)
            {
                temp_string = InString.Substring(n - 1, 2);
                b = System.Convert.ToByte(HexToInt(temp_string));
                i = i + 1;
            }
            b.CopyTo(outb, 0);
            for (n = 0; n <= outlen - 8; n = n + 8)
            {
                for (i = 0; i < 8; i++) temp = b[i + n];
                DeCode(temp, outtemp, Key);//TEA算法解密
                for (i = 0; i < 8; i++) outb[i + n] = outtemp;
            }
            c_str = new StringBuilder("", outlen);
            CopyByteToString(c_str, outb, outlen);
            return c_str.ToString();
        }


详细源代码见附件!
YT88 官方下载 http://www.dgyzt.com/share_show.php?id=96
如果知道 明文 密文 可以根据TEA算法来推算出正确的 TEA算法密钥 吗?

觉得好的  请+热心, +吾爱币

SoftKeyYT88.txt

92.01 KB, 下载次数: 253, 下载积分: 吾爱币 -1 CB

YT88 c#开发

免费评分

参与人数 7吾爱币 +2 热心值 +7 收起 理由
CSTNJY + 1 + 1 是需要用vs转为dll使用吗???
chinasuns + 1 + 1 我很赞同!
orachard + 1 热心回复!
majl8131 + 1 谢谢@Thanks!
expasy + 1 已经处理,感谢您对吾爱破解论坛的支持!
mz135135 + 1 我很赞同!
Sound + 1 鼓励转贴优秀软件安全工具和文档!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| teety 发表于 2016-1-14 20:23
fghtiger 发表于 2015-12-27 10:55
下点官方手册,就能破了吗。

不是的,还得看软件作者怎么验证! 不知道算法密钥 是不能复制一模一样的狗的,但是可以根据程序验证狗的代码 提供符合条件的数据或者自己重新 写空狗来满足程序简单的验证
 楼主| teety 发表于 2016-7-1 16:34
13407720031 发表于 2016-4-26 20:43
问下这个代码该怎么使用呢?小白一个请赐教。

提供加密解密的函数,只要有密钥就能加解密
Sound 发表于 2015-12-27 05:15
感谢. 先留着备份,加密狗很久没玩过了 也许用的上.
tissot 发表于 2015-12-27 08:20
感谢分享
fghtiger 发表于 2015-12-27 10:55
下点官方手册,就能破了吗。
majl8131 发表于 2015-12-28 10:59
感谢分享...学习一下...
LOVE_TT 发表于 2016-1-15 15:03
Sound 发表于 2015-12-27 05:15
感谢. 先留着备份,加密狗很久没玩过了 也许用的上.

大神 啊 大神啊 大神啊 大神啊 大神啊
13407720031 发表于 2016-4-26 20:43
问下这个代码该怎么使用呢?小白一个请赐教。
rjsj 发表于 2017-9-18 20:52
感谢楼主分享这么好的内容,谢谢!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-5 10:58

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表