`
liuzhifeixff
  • 浏览: 2859 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

Java 2012QQ空间最新加密方式

阅读更多
QQ空间在5月31日抛弃了旧时的加密方式,使用了新的加密方式,下面就是java版的 2012QQ空间加密核心代码.

C# 版本地址: http://blog.csdn.net/xiaolajiao958/article/details/7621750

代码需要优化的,大家自己优化.呵呵.

欢迎提供更好的建议.

    public static final String HEXSTRING = "0123456789ABCDEF";
    
    public static String md5(String originalText) throws Exception {
        byte buf[] = originalText.getBytes("ISO-8859-1");
        StringBuffer hexString = new StringBuffer();
        String result = "";
        String digit = "";

        try {
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(buf);

            byte[] digest = algorithm.digest();

            for (int i = 0; i < digest.length; i++) {
                digit = Integer.toHexString(0xFF & digest[i]);

                if (digit.length() == 1) {
                    digit = "0" + digit;
                }

                hexString.append(digit);
            }

            result = hexString.toString();
        } catch (Exception ex) {
            result = "";
        }

        return result.toUpperCase();
    }

    public static String hexchar2bin(String md5str) throws UnsupportedEncodingException 
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(md5str.length() / 2);

        for (int i = 0; i < md5str.length(); i = i + 2)
        {
            baos.write((HEXSTRING.indexOf(md5str.charAt(i)) << 4 |
                    HEXSTRING.indexOf(md5str.charAt(i + 1))));
        }
        
        return new String(baos.toByteArray(), "ISO-8859-1");
    }
    
    /**
     * 
     * @param qq http://check.ptlogin2.qq.com/check?uin={0}&appid=15000101&r={1} 返回的第三个值
     * @param password QQ密码
     * @param verifycode 验证码
     * @return 加密后的密码
     * @throws UnsupportedEncodingException
     * @throws Exception
     */
    public static String GetPassword(String qq,String password, String verifycode) throws Exception{
        
        String P = hexchar2bin(md5(password));
        String U = md5(P + hexchar2bin(qq.replace("\\x", "").toUpperCase()));
        String V = md5(U + verifycode.toUpperCase());
        
        return V;
    }
1
2
分享到:
评论
5 楼 lhf1990729 2012-12-31  
果然是cookie的缘故,现在登录成功!tks/
4 楼 lhf1990729 2012-12-28  
这是第一次登陆的时候。我用fd抓包的内容。直接放进去了.
3 楼 lhf1990729 2012-12-28  

try {
URL serverUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) serverUrl
.openConnection();
conn.setRequestMethod("GET");
conn.addRequestProperty("Accept", "*/*");
conn.addRequestProperty("Accept-Language", "zh-cn");
conn.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; YYGameAll_1.2.167057.92; Windows NT 5.1; Trident/4.0; GTB7.3; QQDownload 718; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");
conn.addRequestProperty("Accept-Encoding", "gzip, deflate");
conn.addRequestProperty("Connection", "Keep-Alive");
conn.addRequestProperty("Cookie", "pgv_info=pgvReferrer=&ssid=s9173889104; ptisp=ctc; pgv_pvid=4366046720; ptui_loginuin=457319664; pt2gguin=o0457319664; RK=qnh6IDjykm; uikey=1c52443b0a164ad8f144f6e2efca8dedb71e2e49d420cfe11d022be5bf7d14ec; chkuin=457319664; confirmuin=457319664; ptvfsession=5603687b36929b359c5fba3297d52c2c553443dc4a71c81db819084f404bf71b21d28c5d624071003e546997bc7db76b; ETK=; ptuserinfo=7762737463; ptcz=5e55df2f52db59aba85017e85758a2d1c2678b3552c75451656a4c94c187d244");

conn.connect();
if (conn.getHeaderFields().get("Set-Cookie") != null) {
for (String s : conn.getHeaderFields().get("Set-Cookie")) {
cookie += s;
}
}
InputStream ins = conn.getInputStream();

String charset = "UTF-8";
InputStreamReader inr = new InputStreamReader(ins, charset);
BufferedReader bfr = new BufferedReader(inr);

String line = "";
StringBuffer res = new StringBuffer();
do {
res.append(line);
line = bfr.readLine();
} while (line != null);
return res.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
2 楼 liuzhifeixff 2012-12-04  
lhf1990729 写道
1-checkurl:http://check.ptlogin2.qq.com/check?uin=457319664&appid=1003903&r=0.1140832570978344
1-returnurl:ptui_checkVC('0','!Z2P','\x00\x00\x00\x00\x1b\x42\x24\xf0');
2-CheckVER:http://ui.ptlogin2.qq.com/cgi-bin/ver
2-ReturnVER:ptuiV(201211050930);
3-firsturl:http://ptlogin2.qq.com/login?u=457319664&p=加密后的密码&verifycode=!Z2P&webqq_type=10&remember_uin=1&login2qq=0&aid=1003903&u1=http%3A%2F%2Fweb.qq.com%2Floginproxy.html%3Flogin2qq%3D0%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=2-17-7469&mibao_css=m_webqq&t=1&g=1
3-returnurl:ptuiCB('4','3','','0','登录失败,请重试。*', '457319664');

这是我的基本步骤。但是一直失败。。报这个错。大哥能帮我分析下吗...

保存cookie请求了吗
1 楼 lhf1990729 2012-11-12  
1-checkurl:http://check.ptlogin2.qq.com/check?uin=457319664&appid=1003903&r=0.1140832570978344
1-returnurl:ptui_checkVC('0','!Z2P','\x00\x00\x00\x00\x1b\x42\x24\xf0');
2-CheckVER:http://ui.ptlogin2.qq.com/cgi-bin/ver
2-ReturnVER:ptuiV(201211050930);
3-firsturl:http://ptlogin2.qq.com/login?u=457319664&p=加密后的密码&verifycode=!Z2P&webqq_type=10&remember_uin=1&login2qq=0&aid=1003903&u1=http%3A%2F%2Fweb.qq.com%2Floginproxy.html%3Flogin2qq%3D0%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=2-17-7469&mibao_css=m_webqq&t=1&g=1
3-returnurl:ptuiCB('4','3','','0','登录失败,请重试。*', '457319664');

这是我的基本步骤。但是一直失败。。报这个错。大哥能帮我分析下吗...

相关推荐

    最新java模拟登陆QQ空间【2017-12-22】有效

    最新Java模拟登陆QQ空间【2017-12-22】有效 代码在2017-12-22编写完成并测试通过! 功能: 1.获取QQ空间qzonetoken值 2.构造p参数加密方式getEncryption(QQ密码,QQ账号[16进制标识],验证码,false); 3.获取g_tk算法...

    JAVA上百实例源码以及开源项目源代码

     通过网络或磁盘等方式,把公钥编码传送给李四,李四接收到张三编码后的公钥,将其解码,李四用张三的公钥加密信息,并发送给李四,张三用自己的私钥解密从李四处收到的信息…… Java利用DES私钥对称加密代码实例 ...

    JAVA上百实例源码以及开源项目

     通过网络或磁盘等方式,把公钥编码传送给李四,李四接收到张三编码后的公钥,将其解码,李四用张三的公钥加密信息,并发送给李四,张三用自己的私钥解密从李四处收到的信息…… Java利用DES私钥对称加密代码实例 ...

    java开源包11

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包6

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包9

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包4

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包101

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包5

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包8

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包10

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包3

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包1

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    java开源包2

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    Java资源包01

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    JAVA 范例大全 光盘 资源

    实例139 模仿QQ空间的电子相册 409 实例140 会动的七彩文字 413 实例141 模仿3D渐层效果 416 实例142 模仿QQ空间的欢迎动画 418 实例143 百叶窗效果 420 实例144 闪电效果 425 实例145 模拟放大镜效果 430 ...

    java开源包7

    Java日历空间 JCalendarButton JCalendarButton是一个简单的java swing日历选择控件。它能够在日期输入框后面弹出一个日历。 网页搜索爬虫 BlueLeech BlueLeech是一个开源程序,它从指定的URL开始,搜索所有可用的...

    C#仿QQ空间个人站点(.NET+SQL)_WebZone

    10个[精品资源]Java学习资料合辑[一] http://download.csdn.net/album/detail/663 10个C#Socket编程代码示例 http://download.csdn.net/album/detail/631 6份GDI+程序设计资源整合[全零分] ...

    [Java参考文档].JDK_API 1.6

    java.awt.color 提供用于颜色空间的类。 java.awt.datatransfer 提供在应用程序之间和在应用程序内部传输数据的接口和类。 java.awt.dnd Drag 和 Drop 是一种直接操作动作,在许多图形用户界面系统中都会遇到它,它...

Global site tag (gtag.js) - Google Analytics