A preliminary study on Ajax implementation of collapse-domain access

Source: Internet
Author: User
Tags gmail password

This is supposed to be a security issue for JavaScript. General Server A is set to not allow other domains of machine B to perform AJAX calls on Server A resource reason, can give a simple example of security vulnerabilities:

Assuming Ajax can overwhelm domain access, then I can write Ajax on my own machine to request resources from Google's various web applications, such as using Firefox to study the address and parameters of Gmail's large number of AJAX requests during the login process. You can get the user cookie verification process and then write JS to cross the domain to obtain another user's cookie, so you can bypass the user's Gmail password and log into someone else's Gmail mailbox

So with Ajax cross-domain restrictions, is it really impossible to do Ajax-domain access?

Ajax collapse does not work, but we can relay implementation, that is, the so-called proxy

The principle is very simple, in their own JS and remote server A resources between the set up a own container

can be used in ASP, PHP, Java,. NET, and so on all the dynamic Web language can

Take ASP as an example (get the buddy list for a user of the is soon hot Web site, return the XML data format)

<%
p = "http://redekuai.com/api/user_friends_xml/funy"
Response.BinaryWrite ZQcnGet(p)
Response.Flush
Function ZQcnGet(url)
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
ZQcnGet = .ResponseBody
End With
Set Retrieval = Nothing
End Function
%>

This code is saved as a proxy.asp, and then put into IIS, this time you can find a machine to write JS, with Ajax request proxy.asp, finally equivalent to achieve the AJAX collapse domain access

PHP's sample code is simpler

Echo file_get_contents ("Http://redekuai.com/api/user_friends_xml/funy");

?>

Note: PHP version needs >= 4.3.0

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.