BSH
text/plain
Magic Bytes
Offset: 0
54 68 69 73 20 69 73 20 54 65 58 2C
BeanShell (BSH) is a lightweight scripting language for the Java platform created by Pat Niemeyer to enable the dynamic execution of standard Java syntax. Developers utilize this format for application extension, interactive testing, and rapid prototyping within Java-based environments to bypass traditional compilation cycles. Although now largely considered a legacy technology, it remains functional for JVM scripting; however, users should exercise caution as scripts execute code directly within the Java Virtual Machine.
Validation Code
How to validate .bsh files in Python
Python
def is_bsh(file_path: str) -> bool:
"""Check if file is a valid BSH by magic bytes."""
signature = bytes([0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x54, 0x65, 0x58, 0x2C])
with open(file_path, "rb") as f:
return f.read(12) == signature
How to validate .bsh files in Node.js
Node.js
function isBSH(buffer: Buffer): boolean {
const signature = Buffer.from([0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x54, 0x65, 0x58, 0x2C]);
return buffer.subarray(0, 12).equals(signature);
}
Go
func IsBSH(data []byte) bool {
signature := []byte{0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x54, 0x65, 0x58, 0x2C}
if len(data) < 12 {
return false
}
return bytes.Equal(data[:12], signature)
}
API Endpoint
GET
/api/v1/bsh
curl https://filesignature.org/api/v1/bsh