Disguised code for cross-origin form submission

Source: Internet
Author: User

If you can get the internal page information of iframe at the beginning, if you cannot get it, doesn't it mean that the form has been submitted ~
We found that Baidu's bidding information in the lower right corner is determined by this method. For details, refer.

Copy codeThe Code is as follows:
<Head> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"> <Body style = "background: # a7a7a7;">
<Iframe id = "testiframe" name = "testiframe"> </iframe>
<Form method = "post" action = "http://www.test.com/testaction.php" target = "testiframe" name = "testform">
<Input type = "text" name = "dddd"> <input type = "submit" value = "ddd" name = "submitbtn"/>
Document. testform. onsubmit = function (){
Document. testform. submitbtn. disabled = true;
SubmitMonitor ();

Function submitMonitor (){
Try {
Var hash = document. getElementById ('testiframe'). contentWindow. location. hash;
SetTimeout (submitMonitor, 100 );
} Catch (e ){
Document. getElementById ('testiframe'). src = "about: blank ";
Document. testform. submitbtn. disabled = false;

Note that the following code is cross-origin, not under a domain name
Testaction. php
Copy codeThe Code is as follows:
<? Php
Sleep (5 );
Echo $ _ POST ['dddd'];

This disadvantage is obvious. If it is a 404,403,500 error, it will also be mistaken for a successful submission.
Therefore, please note: This method is a research method, which is used by NLP.
This section is Baidu's judgment code.
Copy codeThe Code is as follows:
Var sfMessTimes;
Function sfMessSubmitMonitor (){
Try {
Var hash = sf_mess_lib.getElement (SF_MESS_FRAME_ID). contentWindow. location. hash;
SfMessTimes ++;
If (sfMessTimes> 50 ){
Alert (sf_mess_msg.fail );
Sf_mess_lib.getElement (SF_MESS_SUBMIT_ID). disabled = false;
For (var I = 0, l = sf_mess_cols.length; I <l; I ++ ){
Document. getElementById (SF_MESS_PREFIX + sf_mess_cols [I]. idname). disabled = false;
} Else {
SetTimeout (sfMessSubmitMonitor, 100 );
} Catch (e ){
Sf_mess_lib.getElement (SF_MESS_FRAME_ID). src = "about: blank ";
Alert (sf_mess_msg.success );
Sf_mess_lib.getElement (SF_MESS_SUBMIT_ID). disabled = false;
For (var I = 0, l = sf_mess_cols.length; I <l; I ++ ){
Var inputCfg = sf_mess_cols [I];
Var inputEl = document. getElementById (SF_MESS_PREFIX + inputCfg. idname );
InputEl. disabled = false;
InputEl. value = filtInnertip (inputCfg. innertip );

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.