Magic

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Describe what is magic in programming/computing terms. Add references.)
 
(One intermediate revision by one user not shown)
Line 3: Line 3:
 
|subcat=Elements of File Formats
 
|subcat=Elements of File Formats
 
}}
 
}}
I'm sure there are all sorts of almanacs with custom notation that [https://harrypotter.fandom.com/wiki/Magic talk about magic], but this page exists to talk about (and link to/from elsewhere on the wiki where needed) the convention of using the first few bytes of a file to notate/detect the reported format, "as is by magic" (actually by table lookups).
+
I'm sure there are all sorts of almanacs with custom notation that [https://harrypotter.fandom.com/wiki/Magic talk about magic], but this page exists to talk about (and link to/from elsewhere on the wiki where needed) the convention of (typically) using the first few bytes of a file to notate/detect the reported format, "as is by magic" (actually by table lookups).
 +
 
 +
[[wikipedia:Magic number (programming)|Magic]] is a string of unique hexadecimal pattern(s) to look for, used in [[File command|<code>file</code>]] as, "relatively quick-running heuristics to determine file type, it can report misleading information. The command can be fooled, for example, by including a magic number in the content even if the rest of the content does not match what the magic number indicates. The command report cannot be taken as completely trustworthy."<ref>[[wikipedia:File_(command)]]</ref> This method, however, is beneficial in somewhat quickly ascertaining whether a or an (extension-less) file is human-readable, or machine code, as opposed to using utilities such as <code>cat</code> to show the contents of a binary file to terminal, can ruin it due to the use of [[wikipedia:Control character|control characters]].<ref>[https://unix.stackexchange.com/a/119485 Why (and how) did using cat on binary files mess up the terminal? - Unix & Linux Stack Exchange]</ref>
 +
 
 +
It is also used as a [[wikipedia:Library (computing)|library]] containing a database of [[wikipedia:Magic number (programming)|magic numbers]] that can be used, for instance [https://github.com/ReFirmLabs/binwalk binwalk] to, "identify, and optionally extract, files and data that have been embedded inside of other files"<ref>[https://github.com/ReFirmLabs/binwalk?tab=readme-ov-file#what-does-it-do What does it do? - binwalk - GitHub]</ref>, based on libmagic signatures.
 +
 
 +
== References ==
 +
<references/>
 +
 
 +
[[Category:File Format Identification]]

Latest revision as of 12:56, 15 August 2025

File Format
Name Magic
Ontology

I'm sure there are all sorts of almanacs with custom notation that talk about magic, but this page exists to talk about (and link to/from elsewhere on the wiki where needed) the convention of (typically) using the first few bytes of a file to notate/detect the reported format, "as is by magic" (actually by table lookups).

Magic is a string of unique hexadecimal pattern(s) to look for, used in file as, "relatively quick-running heuristics to determine file type, it can report misleading information. The command can be fooled, for example, by including a magic number in the content even if the rest of the content does not match what the magic number indicates. The command report cannot be taken as completely trustworthy."[1] This method, however, is beneficial in somewhat quickly ascertaining whether a or an (extension-less) file is human-readable, or machine code, as opposed to using utilities such as cat to show the contents of a binary file to terminal, can ruin it due to the use of control characters.[2]

It is also used as a library containing a database of magic numbers that can be used, for instance binwalk to, "identify, and optionally extract, files and data that have been embedded inside of other files"[3], based on libmagic signatures.

[edit] References

  1. wikipedia:File_(command)
  2. Why (and how) did using cat on binary files mess up the terminal? - Unix & Linux Stack Exchange
  3. What does it do? - binwalk - GitHub
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox