[轉載]Linux密碼破解

來源:互聯網
上載者:User

root許可權登入後獲得/etc/shadow檔案之後文本開啟

shadow 檔案:

在linux系統中, /etc/shadow 檔案存放著使用者的密碼雜湊值。

shadow中存放的密碼密文格式如下:

$id$salt$encrypted

其中id是指使用的雜湊演算法:

可取如下值:

    ID  | Method

--------------------------

     1   | MD5

    2a  | Blowfish (not in mainline glibc; added in some

          | Linux distributions)

     5   | SHA-256 (since glibc 2.7)

     6   | SHA-512 (since glibc 2.7)

salt:是使用上面hash演算法對密碼進行hash的一個幹擾值。

encrypted:

這個值即 密碼的hash, 但不是直接的hash("passwd"),而是hash("passwd+salt")後,再經過編碼。

實際應用:

1. 在有shadow檔案的前提下暴力破解(也只能暴力破解)使用者密碼

2. 實現自己的passwd命令。某種情境下是很有用的(在雲端運算中,可以方便的為使用同一模板的linux虛擬機器產生不同密碼)

樣本:

該程式使用linux 系統中的crypt函數產生可替換shadow中密碼域中的密碼hash。

#define _XOPEN_SOURCE

#include <stdio.h>

#include <unistd.h>

//crypt 使用方式參見man crypt

//exemple:

//./bin password $6$ffffffff

int main(int argc, char *argv[])

{

    if(argc!=3)

        return -1;

    char *buf = crypt((const char *)argv[1], (const char *)argv[2]);

    printf("salt: %s, crypt: %s\n", argv[2], buf);

    return 0;

}

編譯方法:gcc a.c -lcrypt -o passwd

使用: ./passwd 123 \$6\$abcdefgh

會輸出:

salt: $6$abcdefgh, crypt: $6$abcdefgh$sNmFESeRuFG3asLlnZJwXSxrybA0XIDpk90fLJ9Cmzn6iJiSdKoKIKr5oVHlvQoAubV22YLUGcTVztOLfZM9g0

使用$6$abcdefgh$sNmFESeRuFG3asLlnZJwXSxrybA0XIDpk90fLJ9Cmzn6iJiSdKoKIKr5oVHlvQoAubV22YLUGcTVztOLfZM9g0 替換shadow 檔案中你要修改的使用者中的密碼域,密碼便自動修改成了123。

shadow檔案的格式:

具體可參考這裡:http://www.tldp.org/HOWTO/Shadow-Password-HOWTO.html

crypt 使用方法:

參見: man crypt

原文出處http://hi.baidu.com/gzlick/item/fdedea7b45517a2c5d1789e0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.