IP列表特定的端口检查器脚本

时间:2016-02-28 11:41:58

标签: php bash unix unicode

我目前正在搜索一个代码/脚本,允许它检查特定端口是否打开,让我们说123.在ftp上找到一个公共脚本但我不知道如何以及在其中修改什么来适应我的需要。 (我认为这是一个邪恶的代码,我想以它为例)。

cat $1 | while read LN; do
SRV=`echo $LN | awk '{print $1}'`
php connect.php $SRV 123
done

文件connect.php

<?php

    function S_Server($_server, $_port, $_user, $_pass) {
    if ( "$_port" == "123" ) {
            print "[+]Found $_server\r\n";
            if(!($_OutFile = fopen("iplist", "a"))) ExitF ("Cannot open the log file");
            fputs($_OutFile, "$_server $_user $_pass\n");
            fclose($_OutFile);
    }

    }

    function ExitF($errmsg) {
    print "[-]" . $errmsg . "\r\n";
    exit(0);
    }

    function CrackSMTP($server, $port, $user, $pass) {
    $socket = fsockopen($server, $port, $errno, $errstr, 2);

    if (!$socket) ExitF ("SOCKET ERROR!");

    fclose($socket);

    S_Server ($server, $port, $user, $pass);

    exit(0);
    }

    if ($argv[4]) $_PASS = $argv[4];
    if (!($_PASS)) $_PASS = "";

    if (!($argv[3])) {
    ExitF ("Usage: $argv[0] <hostname> <port> <user> [password]");
    }

    else {
    CrackSMTP($argv[1], $argv[2], $argv[3], $argv[4]);
    }

    exit(0);
    ?>

1 个答案:

答案 0 :(得分:1)

试试这个:

  

的fsockopen(主机名,端口)

file.php:

<?php

if(fsockopen($argv[1], $argv[2]))
{
  print "I can see port $argv[2] from host $argv[1]";
}

示例:php file.php google.com 80

输出:

I can see port 443 from host google.com