Automatic Code write operations, more powerful!

Source: Internet
Author: User

I didn't write a blog during this time. I thought a lot of things outside of technology, and sometimes I felt that it was good to stop thinking about my life.

In our daily life, we solve many problems by using the computer system. The webpage provides such a processing interface, and some operations on this interface can be executed through code, in this way, we can submit all this process to the computer for processing. This article describes how to use a sign-in system.

If we have a sign-in system, we need to log on to the system every day and click the sign-in button to record the daily attendance. Of course, the process of automation is just an example, in real life, if you are discovered by the leaders, it will be awesome...

System Interface

Logon:

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51WF6-0.png "/>

After logging on, you will jump to the refresh page:

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51S120-1.png "/>

Click the effect after refreshing:

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51V517-2.png "/>

If we want to refresh the code, we need to log on and refresh the code. Here we come up with two solutions:

  • Analyze the HTML code of the Login. aspx page and add a JS script to the original HTML code to fill in the username and password and submit it to the server.
  • Use Fiddler to analyze the data content of each request, and use the HttpRequest-related class library in. Net to simulate this login request.

Method 1: Obtain the HTML of the page to be automatically operated and make some changes.

 

 

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51TA5-3.png "/>

At the end of the HTML page, we entered the user name and password using the script and clicked the logon button. Here is the key. How can we execute the tampered HTML, we only need to use the code to read and parse the HTML file, and then retrieve the Index. the HTML code of the aspx page can be parsed in the same way.

Method 2: when sending a login request, we use Fiddler to intercept the communication data.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51U263-4.png "/>

Note that you must add a. After the address localhost to be intercepted and analyzed by Fiddler. After we click Login

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51SG9-5.png "/>

Let's see what data is passed.

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51QY8-6.png "/>

After a slight analysis, we can see that the _ VIEWSTATE string is returned. We know that the changes to the ASPX page are sent back and forth to the server for analysis through this hidden control, then we only need to use code to simulate this request:

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51Rc8-7.png "/>

This code is a pumping method. You can specify a URL to send data requests. Let's try it.

 

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51R606-8.png "/>

After breakpoint debugging, we intercepted the value returned by the server.

 

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1I51U095-9.png "/>

This indicates that after the server receives the login request, it passes verification and wants the client to return the HTML code of Index. aspx.

I am only here to offer some suggestions. If you have any better solutions, please contact us.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.