Topic: "MAgic Bytes" (page 1 of 1)

1
Author Post
Grivier
groupmastergroupmastergroupmastergroupmastergroupmaster
hello people,
i need help,i came accross this term: "magic bytes"
and can't get enough info about it...doesw anyone knows something about it
or has any good info
all info will be apreciated
ty in advance

Grivier
private message
unstable
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Hmm... It's been a long time since I heard a mortal utter those words. Dare I tell you the story of the magic bytes? Hmm... OK, I shall. But be carefull, for he might be listening!

Dark times fell upon the land of Cyberia the day Amadeus Zwiebelkopf was born. The great White Hats felt a tremble in the backbones of Cyberia when his mother gave birth to her mortal son. It is said that at the moment he was conceived, the entire earth shook.
Soon, he learnt to harness the unholy knowledge of the Black Hats. Legend has it that he was so 1337, he could manipulate bytes through sheer mindpower. Years and years went by whilst the powers of the vile Amadeus grew and grew until they were unmatched by any mortal. Even the mighty unix servers finally succumbed to the powers of the evil Amadeus.
The Elder Council of the White Hats was completely flabbergasted. Never before had they seen a Black Hat this powerful. In time, Amadeus managed to oblitterate the entire Council with his evil ping of death.
It was a time of great dispair for the inhabitants of Cyberia, until finally one day a mortal dared to challenge his powers. Busy with all his evil deeds of evilness, he had failed to notice the heroic White Hat boy that was becoming quite powerfull. The final battle was a legendary cyberbattle. Every mortal soul in Cyberia held his breath as the two rivals faced each other in this mighty showdown. In the end, the young White Hat boy managed to nuke his ass with a well timed ping flood.
Rumour has it that just before this final blow, the evil Amadeus cast his soul onto the net. His soul now drifts around the internet from server to server in the form of what became known as his 'magic bytes'. Never did he become as powerfull again as he was before, but his presence can still be felt on occasion.


This is a picture of the evil Amadeus Zwiebelkopf


Actually, magic bytes usually reference to a unique combination of bytes in a file, often at the beginning, which identify the file/section/whatever. I've also seen people use the term 'magic bytes' for a bytesequence that is used as a key or seed in encryption schemes.

Edit: btw, your signature stinks
Edited by unstable on 01.10.2006 08:51:56
private message EMail
unknown user
often the magic bytes aren't only used to make a file easy recogniseable, but also to determen byte order.

for example if you open any .class file of any bloody java app

the first bytes will be either
0xCAFEBABE

or

0xBEBAFECA

this allows java to see recognise the byteorder. little or big endian ... because guess what it isn't standard across platform.

You probably think that you would save every number by writing the most significant bit first, say is you want to store 0x12345678
you could expect that the first memory location would be occupied by 0x12. Well most lightly this is not how your computer does this.It will actually store 0x78 first.

There are some lameass explanations that this way numbers can grow to arbitrary size. (because you don't give a fixed 2^32 weight to the first bit). But really that's just a fancy explanation to cover up the fact that in the early days they didn't succeed in standardizing that. causing a rediculous amount of trouble later on. >way to go<
EMail
unime
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Last time I checked, the Java class file spec insisted that all multi-byte numbers be stored in big-endian format (most significant byte first). That way the magic number will always be CA FE BA BE (BE BA FE CA being obviously inferior), and applications do not need to guess the endianity of a .class file.
private message EMail
unknown user

endian is nothing related to file storage, it is a memory organisation.

"if you open" implied if you read the data into memory and look at it.

if your machine is little endian you will see the bytes with value 0xCAFEBABE
if your machine is big endian you will see the bytes as 0xBEBAFECA

EMail
sniperkid
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
apparently there is no such thing as "magic"....or so i read somewhere LOL.

private message Website
unime
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Endianity comes into play anytime multi-byte quantities are stored or transported in byte-oriented storage. This applies to RAM, disk, ethernet, and punched cards.

I am confused by Rhican's example because java class files should be read with routines that unmarshal the bytes, so the magic number is always 0xCAFEBABE. It is entirely possible to use this magic number to determine byte order, but typically better to determine this earlier (usually at compile time). Instead of using the magic number of an input file, which is outside the control of the program, it makes more sense to write a number (say 0x00000001) to memory and check the byte at the low address.

Anyway, sorry for the delay in responding. I've been busy with other things.

private message EMail

Topic: "MAgic Bytes" (page 1 of 1)

1