Home > Backend Development > PHP Tutorial > Summary of methods for forging ip and url source information in php, url source_PHP tutorial

Summary of methods for forging ip and url source information in php, url source_PHP tutorial

WBOY
Release: 2016-07-13 10:13:20
Original
908 people have browsed it

A summary of how php forges ip and url source information, url source

php forged origin

The first type: php_curl

How to activate:

1. Find php.ini, modify extension=php_curl.dll and remove the semicolon in front;

2. Copy php_curl.dll, php5ts.dll, libeay32.dll, ssleay32.dll to the windows/system32 directory and then restart the php service;
3. Create the test.php test file and insert the following code:

Copy code The code is as follows:

$ch = curl_init(); //Initialization
curl_setopt($ch, CURLOPT_URL, http://www.example.com/search.asp?page=3&typeid=film title&keyword=Jianguo Daye); //The page you want to visit
curl_setopt($ch, CURLOPT_REFERER, http://www.example.com/); //Fake source page
curl_setopt($chtml,CURLOPT_RETURNTRANSFER,1); //Whether to display the content
curl_exec($ch); //Execute
curl_close($ch); //Return to close
?>

Second type: fsockopen

Copy code The code is as follows:

$host = "www.example.com"; //The domain name you want to visit
$target = "/test.asp"; //The address of the page you want to visit
$referer = "http://www.example.com/"; //Fake source page
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if(!$fp){
echo "$errstr($errno)
n";
}else{
$out = "
GET $target HTTP/1.1
Host: $host
Referer: $referer
Connection: Closernrn";
fwrite($fp, $out);
while(!feof($fp)){
echo fgets($fp, 1024);
}
fclose($fp);
}
?>

PHP curl crawls the website
-------------------------------------------------- -----------------------------------------------

Copy code The code is as follows:

//Initialize a cURL object
$curl = curl_init();
//Set the URL you need to crawl
curl_setopt($curl, CURLOPT_URL, 'http://cocre.com');
//Set header
curl_setopt($curl, CURLOPT_HEADER, 1);
//Set cURL parameters to require the results to be saved in a string or output to the screen.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Run cURL to request the web page
$data = curl_exec($curl);
// Close URL request
curl_close($curl);
// Display the obtained data
var_dump($data);

================================================== =================================================
The curl_setopt() function will set options for a CURL session. The option parameter is the setting you want, and value is the value given by this option.
The values ​​of the following options will be used as long integers (specified in the option parameter):
*CURLOPT_INFILESIZE: When you upload a file to a remote site, this option tells PHP the size of the file you are uploading.
*CURLOPT_VERBOSE: If you want CURL to report every unexpected event, set this option to a non-zero value.
*CURLOPT_HEADER: If you want to include a header in the output, set this option to a non-zero value.
*CURLOPT_NOPROGRESS: If you do not want PHP to display a progress bar for CURL transfers, set this option to a non-zero value.
Note: PHP automatically sets this option to a non-zero value, you should only change this option for debugging purposes.
*CURLOPT_NOBODY: If you do not want to include the body part in the output, set this option to a non-zero value.
*CURLOPT_FAILONERROR: If you want PHP not to display an error (HTTP code return greater than or equal to 300) when an error occurs, set this option to a non-zero value. The default behavior is to return a normal page and ignore the code.
*CURLOPT_UPLOAD: If you want PHP to prepare for uploading, set this option to a non-zero value.
*CURLOPT_POST: If you want PHP to do a regular HTTP POST, set this option to a non-zero value. This POST is of the ordinary application/x-www-from-urlencoded type, mostly used by HTML forms.
*CURLOPT_FTPLISTONLY: Set this option to a non-zero value and PHP will list the directory names for FTP.
*CURLOPT_FTPAPPEND: Set this option to a non-zero value and PHP will apply the remote file instead of overwriting it.
*CURLOPT_NETRC: Set this option to a non-zero value and PHP will look in your ~./netrc file for the username and password of the remote site you want to connect to.
*CURLOPT_FOLLOWLOCATION: Set this option to a non-zero header (like "Location: ") and the server will send it as part of the HTTP header (note that this is recursive, PHP will send a header like "Location: ") .
*CURLOPT_PUT: Set this option to a non-zero value to upload a file using HTTP. To upload this file the CURLOPT_INFILE and CURLOPT_INFILESIZE options must be set.
*CURLOPT_MUTE: Set this option to a non-zero value and PHP will be completely silent for the CURL function.
*CURLOPT_TIMEOUT: Set a long integer as the maximum number of seconds.
*CURLOPT_LOW_SPEED_LIMIT: Set a long integer to control how many bytes are transmitted.
*CURLOPT_LOW_SPEED_TIME: Set a long integer to control how many seconds to transmit the number of bytes specified by CURLOPT_LOW_SPEED_LIMIT.
*CURLOPT_RESUME_FROM: Pass a long parameter containing the byte offset address (the start form you want to transfer to).
*CURLOPT_SSLVERSION: Pass a long parameter containing the SSL version. By default PHP will be determined by its own efforts, in more security you have to set it manually.
*CURLOPT_TIMECONDITION: Pass a long parameter to specify how to handle the CURLOPT_TIMEVALUE parameter. You can set this parameter to TIMECOND_IFMODSINCE or TIMECOND_ISUNMODSINCE. This is only for HTTP.
*CURLOPT_TIMEVALUE: Pass a number of seconds from 1970-1-1 to the present. This time will be used as the specified value by the CURLOPT_TIMEVALUE option, or by the default TIMECOND_IFMODSINCE.
The values ​​of the following options will be treated as strings:
*CURLOPT_URL: This is the URL address you want to retrieve using PHP. You can also set this option during initialization with the curl_init() function.
*CURLOPT_USERPWD: Pass a string in the form [username]:[password] for verification.
*CURLOPT_PROXYUSERPWD: Pass a string in the format [username]:[password] to connect to the HTTP proxy.
*CURLOPT_RANGE: Pass a range you want to specify. It should be in "X-Y" format, with X or Y being excluded. HTTP transfers also support several intervals, separated by commas (X-Y,N-M).
*CURLOPT_POSTFIELDS: Pass a string containing all data as an HTTP "POST" operation.
*CURLOPT_REFERER: A string containing a "referer" header in the HTTP request.
*CURLOPT_USERAGENT: A string containing a "user-agent" header in the HTTP request.
*CURLOPT_FTPPORT: Pass an IP address containing the IP address used by the ftp "POST" command. This POST instruction tells the remote server to connect to the IP address we specified. This string can be an IP address, a host name, a network interface name (under UNIX), or '-' (use the system default IP address).
*CURLOPT_COOKIE: Pass a header containing an HTTP cookie to the connection.
*CURLOPT_SSLCERT: Pass a string containing the certificate in PEM format.
*CURLOPT_SSLCERTPASSWD: Pass a password containing the necessary password to use the CURLOPT_SSLCERT certificate.
*CURLOPT_COOKIEFILE: Pass a string containing the name of the file containing cookie data. This cookie file can be in Netscape format, or it can be a stack of HTTP-style headers stored in the file.
*CURLOPT_CUSTOMREQUEST: When making an HTTP request, pass a character to be used by GET or HEAD. Pass a string to be used instead of GET or HEAD when doing an HTTP request. This is useful for doing or another, more obscure, HTTP request.
Note: Do not do this before confirming that your server supports the command.
The following options require a file description (obtained using the fopen() function):
*CURLOPT_FILE: This file will be the output file you place and transmit. The default is STDOUT.
*CURLOPT_INFILE: This file is the input file you sent.
*CURLOPT_WRITEHEADER: This file contains the header portion of your output.
*CURLOPT_STDERR: This file has errors written instead of stderr.

Transmitting data
-------------------------------------------------- --------------------------------------------------

Copy code The code is as follows:

$phoneNumber = '13912345678';
$message = 'This message was generated by curl and php';
$curlPost = 'pNUMBER=' . urlencode($phoneNumber) . '&MESSAGE=' .
urlencode($message) . '&SUBMIT=Send';
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/sendSMS.php');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec();
curl_close($ch);
?>

================================================== ============================================
About proxy server
-------------------------------------------------- ------------------------------------------

Copy code The code is as follows:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
$data = curl_exec();curl_close($ch);
?>

================================================== ===============================================
About SSL and Cookies

Regarding SSL, which is the HTTPS protocol, you only need to change http:// in the CURLOPT_URL connection to https://. Of course, there is also a parameter called CURLOPT_SSL_VERIFYHOST that can be set to verify the site.
Regarding Cookies, you need to understand the following three parameters:
CURLOPT_COOKIE, sets a cookie during the in-person session
CURLOPT_COOKIEJAR, save a cookie when the session ends
CURLOPT_COOKIEFILE, cookie file.

HTTP Server Authentication
-------------------------------------------------- -------------------------------------------------- ----------------------------------
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, '[username]:[password]')
$data = curl_exec();
curl_close($ch);
?>
================================================== ===================================

http get implementation

Copy code The code is as follows:

$ch = curl_init( http://www.webjx.com/ );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);
$fh = fopen( out.html , 'w');
fwrite($fh, $output);
fclose($fh);

http post implementation

Copy code The code is as follows:

//extract data from the post
extract($_POST);
//set POST variables
$url = 'http://www.webjx.com/get-post.php';
$fields = array(
'lname'=>urlencode($last_name),
'fname'=>urlencode($first_name),
'title'=>urlencode($title),
'company'=>urlencode($institution),
'age'=>urlencode($age),
'email'=>urlencode($email),
'phone'=>urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string ,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);

复制代码 代码如下:

set_time_limit(0);
@date_default_timezone_set('Asia/Shanghai');
function curlrequest($url,$postfield,$proxy=""){
$proxy=trim($proxy);
$user_agent ="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$ch = curl_init(); // 初始化CURL句柄
if(!empty($proxy)){
curl_setopt ($ch, CURLOPT_PROXY, $proxy);//设置代理服务器
}
curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
//curl_setopt($ch, CURLOPT_FAILONERROR, 1); // 启用时显示HTTP状态码,默认行为是忽略编号小于等于400的HTTP信息
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);//启用时会将服务器服务器返回的“Location:”放在header中递归的返回给服务器
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);// 设为TRUE把curl_exec()结果转化为字串,而不是直接输出
curl_setopt($ch, CURLOPT_POST, 1);//启用POST提交
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield); //设置POST提交的字符串
//curl_setopt($ch, CURLOPT_PORT, 80); //设置端口
curl_setopt($ch, CURLOPT_TIMEOUT, 25); // 超时时间
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);//HTTP请求User-Agent:头
//curl_setopt($ch,CURLOPT_HEADER,1);//设为TRUE在输出中包含头信息
//$fp = fopen("example_homepage.txt", "w");//输出文件
//curl_setopt($ch, CURLOPT_FILE, $fp);//设置输出文件的位置,值是一个资源类型,默认为STDOUT (浏览器)。
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'Accept-Language: zh-cn',
'Connection: Keep-Alive',
'Cache-Control: no-cache'
));//设置HTTP头信息
$document = curl_exec($ch); //执行预定义的CURL
$info=curl_getinfo($ch); //得到返回信息的特性
//print_r($info);
if($info[http_code]=="405"){
echo "bad proxy {$proxy}n"; //代理出错
exit;
}
//curl_close($ch);
return $document;
}
//请求URL
$url="http://example.cn/getInfo.php";
//POST提交数据,可用HTTPWATCH查看
$postfield="userName=test&year=2008&passWord=123456&Submit=�ύ";
//代理服务器
$proxy = '';
//请求
$str=curlrequest($url,$postfield,$proxy);
//输出结果
echo $str;

复制代码 代码如下:

function request_by_socket($remote_server,$remote_path,$post_string,$port = 80,$timeout = 30){
$socket = fsockopen($remote_server,$port,$errno,$errstr,$timeout);
if (!$socket) die("$errstr($errno)");
fwrite($socket,"POST $remote_path HTTP/1.0rn");
fwrite($socket,"User-Agent: Socket Examplern");
fwrite($socket,"HOST: $remote_serverrn");
fwrite($socket,"Content-type: application/x-www-form-urlencodedrn");
fwrite($socket,"Content-length: ".strlen($post_string)+8."rn");
fwrite($socket,"Accept:*
function request_by_curl($remote_server,$post_string){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$remote_server);
curl_setopt($ch,CURLOPT_POSTFIELDS,'mypost='.$post_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_USERAGENT,"Jimmy's CURL Example beta");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function request_by_other($remote_server,$post_string){
$context = array(
'http'=>array(
'method'=>'POST',
'header'=>'Content-type: application/x-www-form-urlencoded'."rn".
'User-Agent : Jimmy's POST Example beta'."rn".
'Content-length: '.strlen($post_string)+8,
'content'=>'mypost='.$post_string)
);
$stream_context = stream_context_create($context);
$data = file_get_contents($remote_server,FALSE,$stream_context);
return $data;
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/917025.htmlTechArticlephp 伪造ip以及url来路信息方法汇总,url来路 php 来路伪造 第一种:php_curl 开启方法: 1、找到php.ini, 修改extension=php_curl.dll 把前面的分号去掉...
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template