Phpcurl spoofs IP addresses and routes

Source: Internet
Author: User
Phpcurl spoofs IP addresses and routes

  1. $ Headers ['client-IP'] = '192. 103.229.40 ';
  2. $ Headers ['X-FORWARDED-FOR '] = '2017. 103.229.40 ';
  3. $ HeaderArr = array ();
  4. Foreach ($ headers as $ n => $ v ){
  5. $ HeaderArr [] = $ n. ':'. $ v;
  6. }
  7. Ob_start ();
  8. $ Ch = curl_init ();
  9. Curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/curl/server. php ");
  10. Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headerArr); // Construct an IP address
  11. Curl_setopt ($ ch, CURLOPT_REFERER, "http://bbs.it-home.org/"); // Construct a path
  12. Curl_setopt ($ ch, CURLOPT_HEADER, 1 );
  13. Curl_exec ($ ch );
  14. Curl_close ($ ch );
  15. $ Out = ob_get_contents ();
  16. Ob_clean ();
  17. Echo $ out;
  18. ?>

2. curl spoofs the IP address and comes to the server. php

  1. Function GetIP (){
  2. If (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"])
  3. $ Cip = $ _ SERVER ["HTTP_CLIENT_IP"];
  4. Else if (! Empty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"])
  5. $ Cip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];
  6. Else if (! Empty ($ _ SERVER ["REMOTE_ADDR"])
  7. $ Cip = $ _ SERVER ["REMOTE_ADDR"];
  8. Else
  9. $ Cip = "cannot be obtained! ";
  10. Return $ cip;
  11. }
  12. Echo"
    Access IP: ". GetIP ()."
    ";
  13. Echo"
    Access path: ". $ _ SERVER [" HTTP_REFERER "];
  14. ?>

Supplement: $ _ SERVER ['remote _ ADDR '] cannot be forged.

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.