Java bytecode file
application/java-vm
Magic Bytes
Offset: 0
CA FE BA BE
Java bytecode files are binary formats developed by Sun Microsystems and maintained by Oracle Corporation to store compiled instructions. They function as the fundamental unit of deployment for the Java Virtual Machine, enabling platform-independent execution of software across various operating systems and hardware architectures. Although the JVM utilizes a secure sandbox model, bytecode is susceptible to decompilation, which may reveal original source code logic to unauthorized parties.
Validation Code
How to validate .class files in Python
Python
def is_class(file_path: str) -> bool:
"""Check if file is a valid CLASS by magic bytes."""
signature = bytes([0xCA, 0xFE, 0xBA, 0xBE])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .class files in Node.js
Node.js
function isCLASS(buffer: Buffer): boolean {
const signature = Buffer.from([0xCA, 0xFE, 0xBA, 0xBE]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsCLASS(data []byte) bool {
signature := []byte{0xCA, 0xFE, 0xBA, 0xBE}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/class
curl https://filesignature.org/api/v1/class