VB automatically logs in to the network site detailed

xiaoxiao2021-03-06  59

The automatic login site has a key place to be the correct or not of the parameter name, because the parameter names received by each web server are not the same, if the parameter name is incorrect, it will be misunderstood Therefore, it is recommended to recommend a very useful tool "Visual Sniffer": it can intercept the TCP / IP / UDP / ICMP and other data packets transmitted through the network, and use this tool to easily get the relevant parameters sent to the server.

Take the 9CBS as an example. Now let's open "http://www.9cbs.net/member/mme/login.asp "9cbs" http://www.9cbs login page, enter the account number, do not log in, run the Visual Sniffer, point Let's "start intercept" this button, then return to the landing page, click "Login", wait a moment, after login success, click "Stop Interception" on Visual Sniffer, now you can find some IE to send some what. (It is recommended to turn off excess IE before doing these, because if other IE windows are also sending data, you will be unnecessary interference in Visual Sniffer.)

Note that there are many " " numbers on the left side of Visual Sniffer, which is the data that is intercepted, launched them one by one, then check the data on the right, if the first line does not have "post" such a character, Then quickly change a " ", which is the fastest way to send data to the 9CBS server (our login is "post" request, if you see "get", it is certainly not). Please see the actual picture:

First, let's send out the file header, there are a few not very important, so there is not much to say:

"Accept:" indicates the file format that can be received.

"Referr:" indicates the file address pointed to.

"Accept_language:" indicates the language accepted.

"Host:" indicates the host name.

The purple line portion in the figure is in the picture, which is the address sent by the POST. The red line is either all the servers need to receive parameters, four equal numbers indicate that the total four parameters are "&" connects. By the way, the cookie: aspsession you see ... long this is a session, which is sent by the server when IE and the server requests the connection, and now returned to it. You can check out elsewhere in Visual Sniffer, when it's getting. Due to the program, we use the control, do not need to consider the problem of cookie and session, because VB's INET, WebBrowser is packaged very well, the key is how to use it correctly.

"Login_name", "password" is the most important parameter name received when 9CBS is logged in; in addition, there is a "cookietime" to tell the local cookie's effective time, these three are parameters that must be sent when landing 9CBS . The account and password are the parameters required for the general landing site, but some servers receive more than three parameters. In addition to the account and password, we can use other parameters as a third parameter, and the "&" connection is used. In addition, it is more important to "Content-Type: Application / X-WWW-FORM-URLENCODED", tell the server to decode the way, if there is less, you can't do anything.

When logging in to other forums, email, and communities can get all important information about POST through Visual Sniffer, and this is also a method I recommend to everyone, especially when some parameters are not so easy to analyze from the HTML source file. Not only that, you can also use this method to intercept your own procedure, because it is also the HTTP protocol, Visual Sniffer is also able to intercept. This way you can compare the procedure and the IE is nothing to do with the IE to achieve the purpose of the error. Comments on this article

Yulimin (2004-06-03)

http://www.blunch.info/iehttpheaders.html

LVLVLVLYLYLY (2004-06-02)

TO ZHANGKING: That method is actually very bad ~ so he wrote this article ~

ZhangKing (2004-06-02)

Give a reference article ("Software Software DIY"): http://www.why100000.com/_zhan_zhang_zhuan_qu/my_articles/Web_Reb_Reg_Diy/web_reg_diy.htm

BANDRY (2004-06-02)

I will add 5460 automatic logins to the source code, haha

LVLVLVLYLYLY (2004-06-01)

Piggybank: Some things in the source code are not out. I think it is still a good point.

VB Automatically login network site detailed (2): INET control and webbrowser control use LVLVLVLYLYLY [original]

Keyword automatic landing

Somewhere

URL

account number

password

Other parameters

SOHU mailbox

http://login.sohu.com/chkpwd.php

Username

Password

Netease Pass

http://reg4.163.com/checkuser.jsp

Username

Password

9CBS Pass

http://www.9cbs.net/member/logon.asp

Login_name

Password

Cookietime = 0 &

X = 42 & y = 10

The parameters in the table are obtained in the previously described method, and will be used in the program.

First, the webbrowser is also directly POST data to the web server, I will give the code in the fourth part. Here first look at the effect of inet and webbrowser mutual cooperation.

Create a new project, tick "Microsoft Internet Transfer Controls 6.0", "Microsoft Internet Controls", add INET1, WebBrowser1, Text1, Text2, and Combo1 in the form, you can take WebBrowser1 appropriately, position control position Arrange (you can refer to the picture after running), below is the code:

DIM URL1 (2) AS STRING: DIM URL2 (2) AS STRING

DIM C1 (2) AS STRING: DIM C2 (2) AS STRING: DIM C3 (2) AS STRING

Private sub flow_load ()

TEXT1.TEXT = "" "

TEXT2.TEXT = ""

Text2.passwordchar = "*"

Combo1.additem "Sohu Mailbox", 0

Combo1.additem "Netease Pass", 1

Combo1.Additem "9CBS Pass", 2

Combo1.additem "Please select a landing", 3

Combo1.text = Combo1.List (3) URL1 (0) = "http://login.sohu.com/chkpwd.php": URL2 (0) = "http://www34.mail.sohu.com/control / Entry

URL1 (1) = "http://reg4.163.com/checkuser.jsp": URL2 (1) = "http://reg4.163.com/main.jsp?"

URL1 (2) = "http://www.9cbs.net/member/logon.asp": URL2 (2) = "http://www.9cbs.net/member/passport.asp"

C1 (0) = "UserName": C2 (0) = "Password": C3 (0) = ""

C1 (1) = "Username": C2 (1) = "Password": C3 (1) = ""

C1 (2) = "login_name": C2 (2) = "Password": C3 (2) = "Cookietime = 0 & x = 42 & y = 10"

End Sub

PRIVATE SUB FORM_RESIZE ()

IF me.windowstate <> 1 THEN

Webbrowser1.left = 10

WebBrowser1.width = me.width - 120

Webbrowser1.height = me.height - 800

END IF

End Sub

Private sub text2_keyup (keycode as integer, shift as integer)

IF keycode <> 13 THEN EXIT SUB

If Combo1.ListIndex = 3 Then Msgbox "Please select a landing": EXIT SUB

If Text1.Text = "" THEN MSGBOX "Please enter your username": EXIT SUB

If text2.text = "" "THEN MSGBOX" Please enter your password ": EXIT SUB

DIM STRFORMDATA AS STRING

StrformData = C1 (Combo1.ListIndex) "=" TEXT1.TEXT "&" C2 (Combo1.ListIndex) "=" Text2.Text "&" C3 (Combo1.ListIndex)

INET1.EXECUTE URL1 (Combo1.ListIndex), "Post", StrformData, "Content-Type: Application / X-WWW-FORM-URLENCODED"

DO Until inet1.stillexecuting = false 'Here you block the previous INET1, make sure you will take the page after the login is successful, you can cancel this DO.

Doevents

Loop

IF combo1.listindex = 1 THEN

WebBrowser1.navigate URL2 (Combo1.ListIndex) C1 (Combo1.ListIndex) "=" Text1.Textelse

WebBrowser1.naviGate URL2 (Combo1.ListIndex)

END IF

End Sub

You can pick a site that you have already registered to see the effect.

It can be seen that after the success is successful, Inet and WebBrowser can keep the same session dialogue! But when we clicked on a connection on the webbrowser displayed, the request could not succeed (please try it yourself, and arbitrarily click on a connection to the successful site, the population will be a " You don't log in "page). why?

Because we now click on the connection or use IE (operating system default browser) to open, and the IE request page is using the server new session, this new session is the session you used in WebBrowser. The identity ID is different, at least the server thinks so, it is another user without landing. So saying the SESSION's role is not for the entire client, and it can be well understood by the actual code. (You can use this, using code to implement more than two users on one computer, and even seamlessly speak on the same topic.)

So let's let the page continue to display in WebBrowser. Because it is clear, since WebBrowser and inet can keep the same session dialogue, WebBrowser and WebBrowser are naturally natural!

The code to be added is simple -

Private sub webbrowser1_newwindow2 (PPDISP As Object, Cancel As Boolean)

DIM FRM2 AS New Form2

frm2.webbrowser1.registerAsBrowser = true

Set ppdisp = frm2.webbrowser1.object

FRM2.SHOW

End Sub

Then add an FORM2 in the project, put a webbrowser1, adjust the location, and the following code is added to the Form2:

Private sub flow_load ()

Webbrowser1.silent = true

End Sub

PRIVATE SUB FORM_RESIZE ()

IF me.windowstate <> 1 THEN

Webbrowser1.left = 10

WebBrowser1.width = me.width - 120

Webbrowser1.height = me.height - 600

END IF

End Sub

Private Sub WebBrowser1_NewWindow2 (PPDISP As Object, Cancel As Boolean) 'Here, in order to avoid things that happen in Form1.

DIM FRM2 AS New Form2

frm2.webbrowser1.registerAsBrowser = true

Set ppdisp = frm2.webbrowser1.object

FRM2.SHOW

End Sub

Use inet to send login requests, webbrowser browsing the actual page, is indeed a very good idea, there should be no problem in the case where the landing site is relatively less. But this will make things more complicated. In addition to the unusual POST address (URL1), account parameters (C1), password parameters (C2), other parameters (C3), there must be a page address parameter (URL2) for webbrowser request browsing. Although only a parameter, it has added a lot of trouble (such as the request page of the NetEase mailbox, which is automatically generated according to the user's account name, not fixed). Only the fourth parameter can only be avoided using WebBrowser directly POST data. But the interface and function of the browser are a more troublesome problem (unless you are not too trouble, you will write one). Comments on this article

LVLVLVLYLYLY (2004-06-05)

Daluoboequalto: But it is not all right, but the sentence is honest, I am not very clear! But I can be sure is that it is not the program saved!

LVLVLVLYLYLY (2004-06-05)

Daluoboequalto: Yes, you are right! You can intercept once, what is going on, saving cookies, you can see clearly in "User-Agent:" ~

Daluoboequalto (2004-06-04)

Oh, my feelings are that your program keeps cookie, not an control inside.

For example, if you run this source program directly under VB, Navigate to a page that needs to be logged in, then logs in; stop running, run the program, will find that you don't need to log in.

AWJX (2004-06-03)

Is there a C #?

BANDRY (2004-06-02)

You can do it with VC.

VB Automatic Login Network Site Detailed (3): Internet Explorer Object LVLVLVLYLYLY [Original]

Keyword automatic landing

Somewhere

Using the Internet Explorer object allows the POST request to be generated in IE, so that the procedure is away from the work of the beautification interface. The program can even hide or exit, eliminating the troubles brought by WebBrowser, and of course the fourth parameter is not required.

Below us, we still use the login 9CBS as an example, give the actual code, you can replace the site you registered according to the parameters provided in the previous article:

Building a new project, "Reference" Internet Explorer object in the project, click "Browse", find ShDocvw.dll under the system folder (this file is IE comes with it), add Command1 in Form1, the following is the code -

DIM G_OIE AS INTERNETEXPLORERERERER

Private submmand1_click ()

DIM VPOST As Variant

Dim vheaders as variant

Set g_oie = new internetExplorer

g_oie.visible = TRUE

Redim Abyte (0) as Byte

CPOSTDATA = "Login_Name = Account & Password = Password & Cookietime = 0"

PackBytes Abyte (), CPostData

vpost = abyte

Vheaders = "Content-Type: Application / X-WWW-FORM-URLENCODED" CHR (10) CHR (13) g_oie.navigate "http://www.9cbs.net/member/logon.asp",,, Vpost, Vheaders

End Sub

Private sub packbytes (byteaRray () as Byte, byval postData as string

inewbytes = len (postdata) - 1

IF inewbytes <0 THEN EXIT SUB

Redim ByteArray (inewbytes)

For i = 0 to inewbytes

CH = MID (PostData, i 1, 1)

IF ch = space (1) THEN

CH = " "

END IF

BYTEARRAY (I) = ASC (CH)

NEXT

End Sub

(Please enter your own account and password trial run. The advantage of this method is obvious, you can transform the previous code according to this method.)

The PackBytes function converts the data out of POST into an ASCII array, and the value of Vheaders must end with " chr (10) chr (13)".

There is no good explanation of the code, and now I have entered the SHDOCVW.DLL "library", and the webbrowser and Internet Explorer, which are mentioned earlier are "classes" included in this library. You can open the object browser to see the relationship between them.

Comments on this article

Rockrabbit (2004-06-02)

When using the InternetExplorer object, it is wrong.

Set g_oie = new internetExplorer

At this time, an error:

Err.Description = "Class Does Not Support Automation or Does Not Support Expected Interface"

Err.Number = 430

Piggybank (2004-06-01)

There is a little difference with WebBrowser and InternetExplorer:

The latter will automatically load the BHO object. If the user is not careful, the results are "unpredictable"

WebBrowser controllability is better :)

转载请注明原文地址:https://www.9cbs.com/read-114092.html

New Post(0)