Watch your door.-Client data-Modify Referer in Java

Source: Internet
Author: User

1. Brief description

Referer, origin is used to indicate that the browser indicates to the Web server where it is coming from.
But as far as it is concerned, it is not entirely safe.

To write an example, you can arbitrarily modify the HTTP information in the header of Referer, origin

2. Preparation:

Using httpClient4.0 to achieve the specific

3, Java Modify the HTTP information header Referer, Origin source code

The code is so simple that it modifies the HTTP header's Referer, origin.

JSP for the companion example in: http://blog.csdn.net/ffm83/article/details/44095025

The source code is as follows:

/*** Modify the Referer property with httpclient emulation for web security examples only. *  * @authorAuth*/ Public classEasymodifyheader { Public Static voidMain (string[] args)throwsException {closeablehttpclient httpclient=Httpclients.createdefault (); Try{String URL= "http://www.wuranyubao.cn/wryb_rdcity.php"; HttpPost HttpPost=Newhttppost (URL); //setting anti-outer chain header informationHttppost.setheader ("origin", "http://www.wuranyubao.cn"); Httppost.setheader ("Referer", "Http://www.wuranyubao.cn/wryb_prev.php?movie=no"); //Creating HttpPost ObjectsList<namevaluepair> params=NewArraylist<namevaluepair>(); //Create an Namevaluepair array to store the parameters to be transferredParams.add (NewBasicnamevaluepair ("Rdcity", "shandong,jinan,20151121")); Httppost.setentity (Newurlencodedformentity (params,http.            Utf_8)); Closeablehttpresponse Response=Httpclient.execute (HttpPost); Try{httpentity entity=response.getentity (); //Print target Web site output contentSystem.out.println (entityutils.tostring (entity));            Entityutils.consume (entity); } finally{response.close (); }        } finally{httpclient.close (); }    }}

This article transferred from: http://www.2cto.com/Article/201503/380951.html

Jar Package Download: http://download.csdn.net/detail/y515789/8470829

Watch your door.-Client data-Modify Referer in Java

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.