【网络安全】John the Ripper 散列密码,PDF密码

John the Ripper

1. John the Ripper 散列密码

假设我们已经获取到一个数据泄露中包含的散列密码文件 hash1.txt,并需要还原原始密码。步骤如下:

  1. 识别散列类型 通过 hash-id.py 工具,我们确认 hash1.txt 的散列类型是 SHA-256。

    user@machine:~/AOC2024$ cat hash1.txt
    d956a72c83a895cb767bb5be8dba791395021dcece002b689cf3b5bf5aaa20ac
    user@machine:~/AOC2024$ python hash-id.py
    #########################################################################
    #########################################################################
    # __ __ __ ______ _____ #
    # /\ /\ \ /\ \ /__ \ /\ _ \ # # \ \ \_\ \ __ ____ \ \ \___ \/_/\ \/ \ \ \/\ \ # # \ \ _ \ /'__\ / ,__\ \ \ _ \ \ \ \ \ \ \ \ \ # # \ \ \ \ \/\ \_\ \_/\__, \ \ \ \ \ \ _\ _ \ \ _\ \ #
    # \ _\ _\ ___ _/_/ \ _\ _\ /_\ \ _/ #
    # /
    //
    /////// //// /__/ // v1.2 #
    # By Zion3R #
    # www.Blackploit.com #
    # Root@Blackploit.com #
    #########################################################################

    HASH: d956a72c83a895cb767bb5be8dba791395021dcece002b689cf3b5bf5aaa20ac

    Possible Hashs:
    [+] SHA-256
    [+] Haval-256

    Least Possible Hashs:
    [+] GOST R 34.11-94
    [+] RipeMD-256
    [+] SNEFRU-256
    [+] SHA-256(HMAC)
    [+] Haval-256(HMAC)
    [+] RipeMD-256(HMAC)
    [+] SNEFRU-256(HMAC)
    [+] SHA-256(md5(pass)) [+] SHA-256(sha1(pass))

    HASH: ^C

    Bye!

  2. 初次尝试破解 使用 John the Ripper 和常见密码字典 rockyou.txt 进行尝试:

bash 复制代码
john --format=raw-sha256 --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt
user@machine:~/AOC2024$ john --format=raw-sha256 --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt 
Using default input encoding: UTF-8
Loaded 1 password hash (Raw-SHA256 [SHA256 256/256 AVX2 8x])
Warning: poor OpenMP scalability for this hash type, consider --fork=2
Will run 2 OpenMP threads
Note: Passwords longer than 18 [worst case UTF-8] to 55 [ASCII] rejected
Press 'q' or Ctrl-C to abort, 'h' for help, almost any other key for status
0g 0:00:00:03 DONE (2024-11-03 09:49) 0g/s 4765Kp/s 4765Kc/s 4765KC/s (4510458faruk)..*7¡Vamos!
Session completed.

如果直接破解失败,可能是因为目标密码进行了变形处理。

  1. 添加规则提升破解能力

使用规则 --rules=wordlist,John the Ripper 会对字典中的密码进行常见变形,如替换字符(例如 a -> @)、追加数字等:

bash 复制代码
john --format=raw-sha256 --rules=wordlist --wordlist=/usr/share/wordlists/rockyou.txt hash1.txt

若成功,结果可以通过以下命令查看:

bash 复制代码
john --format=raw-sha256 --show hash1.txt

2. PDF 密码保护

当面对一个密码保护的 PDF 文件时,我们需要将其转化为 John the Ripper 可识别的散列格式,然后尝试破解。

生成 PDF 散列 利用 pdf2john.pl 工具生成 PDF 的散列值:

bash 复制代码
pdf2john.pl private.pdf > pdf.hash

尝试标准字典破解 使用 RockYou 字典结合规则:

bash 复制代码
john --rules=wordlist --wordlist=/usr/share/wordlists/rockyou.txt pdf.hash

自定义字典破解 如果常用字典失败,可根据目标的背景信息(如偏好、宠物名等)创建自定义字典:

bash 复制代码
echo -e "Fluffy\nFluffyCat\nMayor\nMalware\nMayorMalware" > wordlist.txt
john --rules=single --wordlist=wordlist.txt pdf.hash
相关推荐
涛ing5 小时前
32. C 语言 安全函数( _s 尾缀)
linux·c语言·c++·vscode·算法·安全·vim
学问小小谢5 小时前
第26节课:内容安全策略(CSP)—构建安全网页的防御盾
运维·服务器·前端·网络·学习·安全
云空10 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
doubt。10 小时前
8.攻防世界Web_php_wrong_nginx_config
网络·安全·web安全·网络安全
没有名字的小羊11 小时前
Cyber Security 101-Build Your Cyber Security Career-Security Principles(安全原则)
运维·网络·安全
大秦王多鱼13 小时前
Kafka SASL/PLAIN介绍
分布式·安全·kafka
大有数据可视化14 小时前
汽车中控屏HMI界面,安全和便捷是设计的两大准则。
安全·汽车·hmi设计·车载屏幕
aaaweiaaaaaa14 小时前
php的使用及 phpstorm环境部署
android·web安全·网络安全·php·storm
泪不是Web妳而流19 小时前
BurpSuite抓包与HTTP基础
网络·经验分享·网络协议·安全·http·网络安全·学习方法