zoukankan      html  css  js  c++  java
  • [重回VB6]简单的QQWeb网游辅助工具开发之旅1、序言,另类的QQ登陆方法

             VB6在90年代时很流行,随着时代的变迁,VB.Net\C#的出现,VB6开始慢慢被淡忘。由于VB6本身有他致命的缺点,导致份额日渐下降。但是他的优点也是非常明显的。通过本系列文章,记录我这几天开发一个QQ小游戏辅助工具的历程,让大家了解和重温VB6。

            当然,在本次代码中,由于时间限制,我不能将代码写得完美。或许有些不规范和容错能力不强,请大家见谅。当然这个辅助工具也不是我第一次的作品。之前还有几个。本次开发也是总结之前的经验作为一个经验之谈。

              首先我们谈一下VB6在常规情况下的优缺点。

    优点

    IDE精简
    生成程序较为绿色
    代码可操作能力较强,属于面向过程编程
    支持的文档和示例较多

               当然他的缺点也是多线程,不支持64位等等。每一个语言都有他自己的优缺点,我们只需要适当运用,就可以在不同程序和需求中找到自己合适的,快速的语言进行开发自己的项目。

                好了,我们现在开始进行我们第一步的开发。就是准备工作。首先本次我们只需要两个必备软件。

                1、VB6精装版(http://download.csdn.net/source/888517

                 2、HttpWatch Professional Edition(http://www.crsky.com/soft/3455.html

                安装完毕后,我们就要开始进入编程第一步。

           首先我们要进行Web游戏操作,第一步是登陆。首先我们需要了解一个概念。网页状态是如何确定的(session、Cookies)。我在之前看不少博文,很多人在登陆时遇到不少阻拦,因为VB6的MD5加密方式是基于字符串,而腾讯的MD5_3加密方式是基于字节。所以要运算出验证码、获取验证码图片,相对于个新手来说是一个非常用难度的操作,腾讯还会不定时更新登陆的。以下我教大家如何简易绕过这个登陆,并且做到一个不用输入账号密码的效果。

         我们首先观察一个地方

    image

           我们能否借花敬佛,让腾讯帮我们完成这个登陆过程呢?其实是可以的。

    首先我贴出一个JS代码,看看大家明白我想干什么。

        document.getElementById('main').getElementsByTagName('div')[0].style.zIndex = 99999;
        document.getElementById('main').getElementsByTagName('div')[0].style.position='fixed';
        document.getElementById('main').getElementsByTagName('div')[0].style.left = 0;
        document.getElementById('main').getElementsByTagName('div')[0].style.top = 0;
        document.getElementById('main').getElementsByTagName('div')[0].style.margin = 0;

           我让这个登陆框的位置移动到左上角,因为好像ie6不支持fixed属性,我也没时间在不同ie版本测试。不过大概原理都是这样子呢。

    image

            在VB6创建一个窗体,在工具栏中引用以下组件。

    image

           第一个是IE的窗口,而第二个是以后会用到的信息显示的组件(listview)。

           将IEFrame随意改个名字叫"W” ,然后我们双击窗体,获取其Load事件。

    Private Sub Form_Load()
    W.Navigate "http://pengyou.qq.com/index.html"
    W.Width = 0
    W.Left = -100
    End Sub
    
    让窗体打开时首先读入校友的首页。在没完全读取前我们先将他隐藏。不让用户看到。 接下来,我们选择IEFrame中的DocumentComplete事件,让其在加载完毕后,帮我做点事。
    If url = "http://pengyou.qq.com/index.html" Then
        W.Document.parentWindow.execScript ("document.getElementById('main').getElementsByTagName('div')[0].style.zIndex = 99999;")
        W.Document.parentWindow.execScript ("document.getElementById('main').getElementsByTagName('div')[0].style.position='fixed';")
        W.Document.parentWindow.execScript ("document.getElementById('main').getElementsByTagName('div')[0].style.left = 0;")
        W.Document.parentWindow.execScript ("document.getElementById('main').getElementsByTagName('div')[0].style.top = 0;")
        W.Document.parentWindow.execScript ("document.getElementById('main').getElementsByTagName('div')[0].style.margin = 0;")
        W.Width = 6015
        W.Left = 0
    End If

    image

           好啦,我们看到一个可以自动登陆的效果了。那么我们如何获取登陆后的信息呢?我们继续在DocumentComplete事件中写入以下代码

    If InStr(1, url, "http://home.pengyou.qq.com/index.php") > 0 Then
    W.Width = 0
    W.Left = -100
        Web_Mod.SetCookieString (W.Document.cookie)
        Main.Caption = Main.Caption & " - " & Public_Mod.decodeURI(Web_Mod.Cookies("name"))
    End If
    

        代码意思是如果进入了首页,就表示登陆完成啦~我们就获取网页的cookie,将其登陆后的事情全部交给程序去处理。看样子浏览器的事情已经告一段落,我们也成功完美地登陆了。里面使用了2个函数,第一个是我自己编写的管理Cookies模块,和一个decode解码函数,现在你们可以先新建一个Web_Mod的模块,将代码放入去,以下是Cookie函数,在Web_Mod模块中

    Public Cookies As Object
    Public openid As String
    Public openkey As String
    Public Sub SetCookieString(s As String)
        Set Cookies = CreateObject("Scripting.Dictionary")
        tmp = Split(s, ";")
        For i = 0 To UBound(tmp)
        If UBound(Split(tmp(i), "=")) > 0 Then
            Cookies.Add Trim(Split(tmp(i), "=")(0)), Trim(Split(tmp(i), "=")(1))
            Else
            Cookies.Add Trim(Split(tmp(i), "=")(0)), ""
        End If
        Next
    End Sub
    Public Sub AddCookie(key As String, item As String)
        If Cookies Is Nothing Then
            If Cookies.Exists(key) = True Then
                Cookies(key) = item
            Else
                Cookies.Add key, item
            End If
        End If
    End Sub
    Public Sub RemoveCookie(key As String)
        If Not (Cookies Is Nothing) Then
            If Cookies.Exists(key) = True Then
                Cookies.Remove (key)
            End If
        End If
    End Sub
    
    Public Function GetCookieString() As String
        Dim cookie As String
        
        If Not (Cookies Is Nothing) Then
            arrKeys = Cookies.keys
            arrItems = Cookies.Items
            For i = 0 To Cookies.Count - 1
                cookie = cookie & arrKeys(i) & "=" & arrItems(i) & "; "
            Next
        End If
        GetCookieString = cookie
    End Function
    

    以下是关于文字的转换函数,在自建的Public_Mod模块中。

    Public Function decodeURI(txt)
        Dim o As Object
        Set o = CreateObject("MSScriptControl.ScriptControl")
        o.Language = "Jscript"
        decodeURI = o.Eval("decodeURI('" & txt & "')")
        
    End Function
    Public Function decode(txt)
        Dim o As Object
        Set o = CreateObject("MSScriptControl.ScriptControl")
        o.Language = "Jscript"
        decode = o.Eval("'" & txt & "'")
        
    End Function
    
    
              这样一次帮IE穿马甲,很容易穿过了腾讯登陆页面。连页面UI都不需要我们做,验证码等也与我们无关。哈哈~当然也可以将代码写得更加严密,因为还会有登陆密码错误的情况,我还没考虑进去。不过这个应该算是那么多辅助工具最人性化的登陆方式了吧。好,今天先写到这里。下次是关于HttpWatch Professional Edition截包,和破解QQ校友的摩天大楼的思维。
  • 相关阅读:
    326周日去找书
    新视野大学英语-Book1
    预编译头文件来自编译器的早期版本,或者预编译头为 C++ 而在 C 中使用它(或相反)
    自定义GRUB主题
    Linux安装CMake
    Linux编译安装Apache
    @Scheduled注解
    熵权可拓物元模型
    Linux更新Python3.8
    Linux下更新GCC
  • 原文地址:https://www.cnblogs.com/pika/p/1867672.html
Copyright © 2011-2022 走看看