linux 下root 密碼破解(二)
——————說一下grub的密碼和安全模式
我們都知道root的密碼是儲存在/etc/shadow下的,而/etc/passwd 則是使用者資訊檔案,密碼呢由于是MD5加密我們不能看到明文,但是進入單使用者模式後,我們可以通過修改使用者資訊檔案,是管理者密碼失效,關于root超級使用者的密碼的破解前文已經有較為詳細的描述,
我們知道 破解系統密碼是要進入單使用者模式的,這個我們可以通過給grub加密來進行阻止,加入grub的密碼你不知道,那麼我們可以通過進入安全模式來進行破解,安全模式是要CD光牒啟動的,這個是可以通過BIOS密碼來進行限制,那BIOS密碼,我們怎麼辦?扣電池呗!
grub的密碼在安裝系統的時候是可以進行設定的,假如說裝系統的時候我們沒有設定,以後也是可以手工添加的,
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610632GB2C.jpg"></a>
我的核心版本
實驗環境 VMware 5.5.3 + redhat Enterprise linux5 AS
今天就講點小東西,說一下grub的加密,和忘記grub密碼後進入安全模式的解救方法
[root@localhost ~]# grub-md5-crypt
Password:
Retype password:
$1$PYWt0/$bMNd.aRO.sGeUeERbjDb91
[root@localhost ~]#
這裡的 grub-md5-crypt是指用MD5加密算法生成一個配置檔案,後面呢你輸入兩次密碼,生成的這一大串字元就是你密碼加密後的字元,複制這段字元到
[root@localhost ~]# vi /etc/grub.conf
這就是grub的配置檔案
打開配置檔案
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610634TZAz.jpg"></a>
password --md5 $1$PYWt0/$bMNd.aRO.sGeUeERbjDb91
加入這段
複制這段密鑰到檔案中,注意密鑰的位置
儲存退出
[root@localhost ~]# reboot
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610636ayBb.jpg"></a>
出現啟動界面後按任意鍵
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610638LUtI.jpg"></a>
這裡呢會發現沒有以前按e的選項 不同的是 有個按p并輸入密碼,
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_12416106417Ox2.jpg"></a>
這裡按p 并輸入密碼
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_12416106445Sq9.jpg"></a>
選e
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610647xT9j.jpg"></a>
這個界面出來之後,大家都很熟悉了吧,後面的破解步驟,不在此多說
假如 grub的密碼
你也忘了怎麼辦?介紹一下安全模式
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610649uEaA.jpg"></a>
選擇 管盤啟動
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610651cHqY.jpg"></a>
這裡我們選擇 F2
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610653gn0z.jpg"></a>
輸入 linux rescue 回車
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610656TSf2.jpg"></a>
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610659JxFz.jpg"></a>
啟動過程
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610661Y48Q.jpg"></a>
類似于 安裝過程 這裡選擇語言
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610663NYbQ.jpg"></a>
選擇鍵盤
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610664VE5X.jpg"></a>
選擇網卡 這裡有沒有都無所謂 NO吧
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610666gr3c.jpg"></a>
救援環境會試圖搜尋所安裝的紅帽linux
并将之挂載到/mnt/sysimage 目錄下,然後您便可以按照系統需求進行更改,您若想執行這一步驟,請選擇,繼續,按鈕,您也可以選擇隻讀,将檔案系統挂載成隻讀模式而不是讀寫模式,
如果由于某種願意,這一步驟失敗,您可以選擇跳過按鈕,該步驟就會被跳過,您會直接進入指令狀态,
繼續,隻讀,跳過
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610668Bc6t.jpg"></a>
ok 即可 這時可還沒有進入安全模式呢
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610670V9DZ.jpg"></a>
這裡呢 輸入兩條指令
cd /mnt/sysimage
chroot . /bin/bash
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610671TcjQ.jpg"></a>
這時我們可以ls一下看看,已經進入了安全模式,這時可以幹你任何想幹的事情
比如我們
vi /etc/passwd
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610673awwc.jpg"></a>
你可以在這裡修改管理者密碼
也可以
vi /etc/grub.conf
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610675gVOD.jpg"></a>
你可以依照你的意願删除或者注釋掉剛才加的這句話
<a href="http://yuzeying.blog.51cto.com/attachment/200905/6/644976_1241610678LVjm.jpg"></a>
重新開機後你會發現 已經沒有了p的選項,
這個隻是虛拟機裡做的測設,有的時候可能因為虛拟機版本的問題有影響。
本文轉自 yuzeying1 51CTO部落格,原文連結:http://blog.51cto.com/yuzeying/155710