加解密
openssl
openssl是一个强大的加密工具包,支持多种加密、解密、摘要、证书生成等操作,广泛用于安全测试、渗透测试和开发中。
摘要算法(hash)
echo -n "password123" | openssl dgst -md5
echo -n "password123" | openssl dgst -sha256
openssl dgst -sha1 file.txt
对称加解密
openssl enc -aes-256-cbc -salt -in plain.txt -out enc.txt
openssl enc -aes-256-cbc -d -in enc.txt -out plain.txt
-aes-256-cbc:使用 AES 256 CBC 模式;
-salt:增强安全性;
-k 或 -pass pass::指定密码。
非对称加密
生成 RSA 密钥对:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
加密 / 解密文件:
使用公钥加密
openssl rsautl -encrypt -inkey public.pem -pubin -in msg.txt -out enc.bin
使用私钥解密
openssl rsautl -decrypt -inkey private.pem -in enc.bin -out dec.txt
创建自建签名
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
算法识别
hash-identifier 可以帮助识别加密算法 (不一定准)
hashid -m "hashtxt" 更精确一些
hashcat
基本语法 hashcat -m [哈希类型] -a [攻击模式] [哈希文件] [字典文件]
-m,--hash-type 指定 hash 类型,后接 hash 编号,
hashcat --help | grep -A100 "Hash modes"
-a, --attack-mdoe 指定攻击模式 ,后接模式编号, 常用 0 字典攻击
--show 不执行破解,直接从历史记录中查看已破解的hash
John the Ripper
基本语法 john [选项] [hash 文件]
--format 指定hash类型
john --list=formats可以列出所有的hash类型
--wordlist= 后接字典路径
--show 查看已破解的hash密码