Home > Backend Development > PHP Tutorial > PHP simple thief program

PHP simple thief program

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:02:18
Original
2054 people have browsed it

Thief program: Catch the data (pictures, web pages and other files) on the remote website to the local, and then display it after processing
Regular expressions: Used for pattern segmentation, matching, and search of strings and replacement operations.

Related functions:

int ereg(string $pattern, string $string[, array &$regs] )

If the parameter is omitted and the returned array is found, the return value is True otherwise it returns False

Correspondingly, eregi() is not case-sensitive.

string file_get_contents(string $filename[, bool $use_include_path= false[,resource $context[,int $offset= 0[,int $maxlen]]]] )

Read the entire file, such as:

Use this function to obtain web page information

It is the basis of the thief program.

For example:

$url=file_get_contents("http://www.ubuntu.org.cn/index_kylin");

echo $url;

?>
PHP 简单的小偷程序

But for another website:

$url=file_get_contents("http://www.alangzhong.com/index.html");

echo $url;

?>

I found that many background images are invisible.


PHP 简单的小偷程序

Looking at the source code of the web page, we found that this is

src="/upload/201503/b123ec26-bb8f-43be-b5ad-cdf45153d053. png"/>

The address of the image uses a relative path, and we do not have such a file locally, so of course it cannot be displayed.

Use a regular expression to select the image, and then replace the relative path with the remote address:

The timeout problem of the following code has not been resolved.


<?php
//ini_set(&#39;max_execution_time&#39;, &#39;0&#39;);   //三者都没用啊,一直超时
//@ini_set(&#39;default_socket_timeout&#39;, 20000);
//set_time_limit(2); 
$url=file_get_contents("http://www.alangzhong.com/index.html");
//echo $url;
$fp = @fopen($url, "r") or die("超时");  //为什么不断超时
$contents = file_get_contents($url);
eregi("<img width=\"116\" height=\"98\" src=\"/upload/201503/b123ec26-bb8f-43be-b5ad-cdf45153d053.png\"/>",$contents,$rg);
//  远程地址替换相对路径
$rg[1]=str_replace("src=\"../upload/","src=\"http://www.alangzhong.com/index.html/upload/",$rg[1]);

echo $rg[1];
?>
Copy after login


The above introduces the simple thief program in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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