2012-05-02 13:23:57 +02:00
|
|
|
|
2012-03-31 20:24:03 +02:00
|
|
|
#------------------------------------------------------------------------------
|
2013-12-06 12:04:52 +01:00
|
|
|
# $File: cafebabe,v 1.14 2013/02/27 16:59:59 christos Exp $
|
2012-03-31 20:24:03 +02:00
|
|
|
# Cafe Babes unite!
|
|
|
|
#
|
2013-12-06 12:04:52 +01:00
|
|
|
# Since Java bytecode and Mach-O universal binaries have the same magic number,
|
|
|
|
# the test must be performed in the same "magic" sequence to get both right.
|
|
|
|
# The long at offset 4 in a Mach-O universal binary tells the number of
|
|
|
|
# architectures; the short at offset 4 in a Java bytecode file is the JVM minor
|
|
|
|
# version and the short at offset 6 is the JVM major version. Since there are only
|
2012-03-31 20:24:03 +02:00
|
|
|
# only 18 labeled Mach-O architectures at current, and the first released
|
|
|
|
# Java class format was version 43.0, we can safely choose any number
|
|
|
|
# between 18 and 39 to test the number of architectures against
|
|
|
|
# (and use as a hack). Let's not use 18, because the Mach-O people
|
|
|
|
# might add another one or two as time goes by...
|
|
|
|
#
|
2013-12-06 12:04:52 +01:00
|
|
|
### JAVA START ###
|
2012-03-31 20:24:03 +02:00
|
|
|
0 belong 0xcafebabe
|
|
|
|
!:mime application/x-java-applet
|
|
|
|
>4 belong >30 compiled Java class data,
|
|
|
|
>>6 beshort x version %d.
|
|
|
|
>>4 beshort x \b%d
|
|
|
|
# Which is which?
|
|
|
|
#>>4 belong 0x032d (Java 1.0)
|
|
|
|
#>>4 belong 0x032d (Java 1.1)
|
|
|
|
>>4 belong 0x002e (Java 1.2)
|
|
|
|
>>4 belong 0x002f (Java 1.3)
|
|
|
|
>>4 belong 0x0030 (Java 1.4)
|
|
|
|
>>4 belong 0x0031 (Java 1.5)
|
|
|
|
>>4 belong 0x0032 (Java 1.6)
|
|
|
|
|
2013-12-06 12:04:52 +01:00
|
|
|
0 belong 0xcafed00d JAR compressed with pack200,
|
|
|
|
>5 byte x version %d.
|
|
|
|
>4 byte x \b%d
|
|
|
|
!:mime application/x-java-pack200
|
2012-03-31 20:24:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
0 belong 0xcafed00d JAR compressed with pack200,
|
2013-12-06 12:04:52 +01:00
|
|
|
>5 byte x version %d.
|
|
|
|
>4 byte x \b%d
|
2012-03-31 20:24:03 +02:00
|
|
|
!:mime application/x-java-pack200
|
2013-12-06 12:04:52 +01:00
|
|
|
|
|
|
|
### JAVA END ###
|
|
|
|
### MACH-O START ###
|
|
|
|
|
|
|
|
0 name mach-o \b [
|
|
|
|
>0 use mach-o-cpu \b
|
|
|
|
>&(8.L) indirect \b:
|
|
|
|
>0 belong x \b]
|
|
|
|
|
|
|
|
0 belong 0xcafebabe
|
|
|
|
>4 belong 1 Mach-O universal binary with 1 architecture:
|
|
|
|
>>8 use mach-o \b
|
|
|
|
>4 belong >1
|
|
|
|
>>4 belong <20 Mach-O universal binary with %ld architectures:
|
|
|
|
>>>8 use mach-o \b
|
|
|
|
>>>28 use mach-o \b
|
|
|
|
>>4 belong >2
|
|
|
|
>>>48 use mach-o \b
|
|
|
|
>>4 belong >3
|
|
|
|
>>>68 use mach-o \b
|
|
|
|
|
|
|
|
### MACH-O END ###
|