PPK
application/octet-stream
Magic Bytes
Offset: 0
50 75 54 54 59 2D 55 73 65 72 2D 4B 65 79 2D 46 69 6C 65 2D 32 3A
PuTTY Private Key (PPK) is a file format developed by Simon Tatham for storing SSH private keys within the PuTTY ecosystem. It is primarily utilized for authenticating secure remote login sessions via SSH clients like PuTTY, WinSCP, and FileZilla on Windows systems. While the format itself is secure and supports passphrase encryption, users should exercise caution when sharing these files, as they grant authorized access to remote servers if compromised.
Validation Code
How to validate .ppk files in Python
Python
def is_ppk(file_path: str) -> bool:
"""Check if file is a valid PPK by magic bytes."""
signature = bytes([0x50, 0x75, 0x54, 0x54, 0x59, 0x2D, 0x55, 0x73, 0x65, 0x72, 0x2D, 0x4B, 0x65, 0x79, 0x2D, 0x46, 0x69, 0x6C, 0x65, 0x2D, 0x32, 0x3A])
with open(file_path, "rb") as f:
return f.read(22) == signature
How to validate .ppk files in Node.js
Node.js
function isPPK(buffer: Buffer): boolean {
const signature = Buffer.from([0x50, 0x75, 0x54, 0x54, 0x59, 0x2D, 0x55, 0x73, 0x65, 0x72, 0x2D, 0x4B, 0x65, 0x79, 0x2D, 0x46, 0x69, 0x6C, 0x65, 0x2D, 0x32, 0x3A]);
return buffer.subarray(0, 22).equals(signature);
}
Go
func IsPPK(data []byte) bool {
signature := []byte{0x50, 0x75, 0x54, 0x54, 0x59, 0x2D, 0x55, 0x73, 0x65, 0x72, 0x2D, 0x4B, 0x65, 0x79, 0x2D, 0x46, 0x69, 0x6C, 0x65, 0x2D, 0x32, 0x3A}
if len(data) < 22 {
return false
}
return bytes.Equal(data[:22], signature)
}
API Endpoint
GET
/api/v1/ppk
curl https://filesignature.org/api/v1/ppk