Handassembled java bytecode

Nikolaus Gradwohl2009-03-03T04:25:00+00:00

motivated by my hand written x86 machinecode, i decided that i had to take it to the next level.

i worte some handassembled java bytecode. run the file below as

./dump.sh > HelloAsm 

and run the programm with

java HelloAsm

dump.sh:

echo -en "\xca\xfe\xba\xbe" # java magic number
echo -en "\x00\x00\x00\x2e" # java version

echo -en "\x00\x16" # size of the constant pool + 1

echo -en "\x07\x00\x02" # class
echo -en "\x01\x00\x08HelloAsm" # class name
echo -en "\x07\x00\x04" #class
echo -en "\x01\x00\x10java/lang/Object" # class name
echo -en "\x01\x00\x04main" # methdo name
echo -en "\x01\x00\x16([Ljava/lang/String;)V" # <- method signature
echo -en "\x01\x00\x04Code"
echo -en "\x01\x00\x0bHello World"
echo -en "\x08\x00\x08" # string constant
echo -en "\x09\x00\x0b\x00\x0d" # method reference
echo -en "\x07\x00\x0c" # class
echo -en "\x01\x00\x10java/lang/System"
echo -en "\x0c\x00\x0e\x00\x0f" # name and type
echo -en "\x01\x00\x03out"
echo -en "\x01\x00\x15Ljava/io/PrintStream;"
echo -en "\x0a\x00\x11\x00\x13" # method reference
echo -en "\x07\x00\x12" #class
echo -en "\x01\x00\x13java/io/PrintStream" #class name
echo -en "\x0c\x00\x14\x00\x15" # name and reference
echo -en "\x01\x00\x07println"
echo -en "\x01\x00\x15(Ljava/lang/String;)V"


echo -en "\x00\x21" # attributes
echo -en "\x00\x01" # class
echo -en "\x00\x03" # superclass
echo -en "\x00\x00" # interface count
echo -en "\x00\x00" # field counnt

echo -en "\x00\x01" # method count

echo -en "\x00\x09" # public static
echo -en "\x00\x05" # method name
echo -en "\x00\x06" # signature index
echo -en "\x00\x01" # attribute count

echo -en "\x00\x07" # code attribut
echo -en "\x00\x00\x00\x15" # code length
echo -en "\x00\x02" # stack size
echo -en "\x00\x01" # local vars count
echo -en "\x00\x00\x00\x09" # code size
echo -en "\xb2\x00\x0a\x12\x09\xb6\x00\x10\xb1" # <- code
echo -en "\x00\x00" # exceptions
echo -en "\x00\x00" # attrib

echo -en "\x00\x00" # attrib count
Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

Machine language Hello-World in 120 bytes
SFZ to Multisample converter
File Upload in Servlet 3.0
OutOfIdeasException
Deploying Processing apps using WebStart

Trackbacks

Comments

Leave a response

Leave a comment