zoukankan      html  css  js  c++  java
  • PHP Socket编程 之 使用fsockopen伪造IP

    php fsockopen用于打开一个网络连接或者一个Unix套接字连接,本文章向大家介绍一个关于fsockopen的使用案例(使用fsockopen伪造IP),通过这个案例,相信大家对fsockopen函数有更多的认识,需要的朋友可以参考一下。

    如何使用fsockopen来伪造IP呢,其实与fsockopen伪造来路的思路和代码差不多,具体实现请看下面源码:

    $host = "127.0.0.1"; //你要访问的域名
    $ip = '127.0.0.1';
    $target = "/test2.php"; //你要访问的页面地址
    $referer = "http://www.manongjc.com/"; //伪造来路页面
    //$fp = fsockopen($host, 80, $errno, $errstr, 30);
    $fp = fsockopen($ip, 80, $errno, $errstr, 5);
    if(!$fp)
    {
        echo "$errstr($errno)<br>
    ";
    }
    else
    {
        $end = "
    ";
        $out = "GET $target HTTP/1.1$end";
        $out .= "Host: $ip$end";
        $out .= "Referer: $referer$end";
        $out .= "Client-IP: 121.199.24.143
    "; 
        $out .= "X-Forwarded-For: 121.199.24.143
    "; //主要是这里来构造IP 
        $out .= "Connection: Close$end";
        $out .= "$end";
        fwrite($fp, $out);
        while(!feof($fp))
        {
            echo fgets($fp, 1024);
        }
        fclose($fp);
    }
  • 相关阅读:
    开发技术--Numpy模块
    开发技术-IPython介绍
    开发--Deepin系统安装
    开发--CentOS-7安装及配置
    开发技术--设计模式
    English--音标重难点
    English--音标拼读
    English--辅音
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
  • 原文地址:https://www.cnblogs.com/7qin/p/13298628.html
Copyright © 2011-2022 走看看