Skip to content
DevMeme
3727 of 7590
CLI Post #4066 · source on Telegram

The Ascended Path of Binary File Editing

Description

This is a multi-panel 'expanding brain' meme, illustrating a progression of methods for editing binary files, from simple to esoteric. Each panel on the left shows a command or tool, while the right shows a corresponding image of an increasingly enlightened or powerful being. It starts with user-friendly GUI tools like '010Editor (paid license)' and 'HxD32.exe'. It then moves to using standard command-line tools in clever ways, such as converting a binary to hex in 'vim', or dumping hex to a text file to edit with 'nano' and then converting it back. The complexity escalates to a convoluted pipeline using 'xxd', 'sed', and back again. The final, most 'enlightened' stage shows the simplest and most direct command: `echo -ne "\x4d\x5a" > file.bin`, which directly writes the magic bytes for an executable file. The humor lies in the irony that the most complex-looking solutions are often not the most elegant, and true mastery is in the simplest, most direct command, a journey of discovery familiar to many senior engineers

Comments

32
Anonymous ★ Top Pick The junior dev uses a GUI hex editor. The mid-level dev builds a 5-stage pipeline with sed and awk. The senior dev just uses echo. The principal engineer has a co-worker who knows how to do it
  1. Anonymous ★ Top Pick

    The junior dev uses a GUI hex editor. The mid-level dev builds a 5-stage pipeline with sed and awk. The senior dev just uses echo. The principal engineer has a co-worker who knows how to do it

  2. Anonymous

    Real dev zen is realising your entire hex editor can fit in an echo pipe and still pass the company’s ‘no new dependencies’ mandate

  3. Anonymous

    The same engineer who writes a 47-step sed pipeline to change one byte is now architecting your microservices mesh with 200 dependencies to serve a contact form

  4. Anonymous

    Patching 74 to 75 with sed - turning JZ into JNZ via regex is how license checks die and how seniors prove they never actually needed the debugger

  5. Anonymous

    The real galaxy brain move is spending 3 hours crafting the perfect sed one-liner to patch a single byte instead of just opening the file in a GUI hex editor and clicking once. But hey, at least you can put that pipeline in your dotfiles and pretend you'll need it again someday - right next to that awk script you wrote in 2019 that you're absolutely certain will be useful 'eventually.'

  6. Anonymous

    Real senior move: treat binary patching as text processing - xxd -g1 | sed 's/74 cb/75 cb/' | xxd -r - and save the license budget; enlightenment is remembering echo -ne "\x4d\x5a" can be a perfectly acceptable recovery plan

  7. Anonymous

    Hx32.exe for mortals; echo -ne '\xDå' for those who've transcended the GUI

  8. Anonymous

    Peak senior move: turn hex edits into a reproducible xxd | sed | xxd -r target, commit it to git, and let CI review the bytes

  9. ẞonny 4y

    I understand 0 from that

    1. @lord_nani 4y

      Same

    2. @lord_nani 4y

      Seems like converting text files to binary

  10. @nkormakov 4y

    4th is so familiar

  11. @lord_nani 4y

    Is meme about different ways of editing/saving as binary files?

  12. ẞonny 4y

    I laughed at paid license but I didn't understood the purpose. I'm just the men you gonna call when you don't know how to press that simple button. 🥲

  13. @dmitry_polshakov 4y

    This is different ways to edit binary file. But the last one not edit file, but fully replace its content. IDK is it by purpose or not

  14. @RiedleroD 4y

    Things I don't know here: - 010Editor - HxD32.exe - xxd - the meaning of "\x4d\x5a" so yeah I get this meme 👍

  15. @Santiaga 4y

    Paid hex editor Free hex editor vim in hex editor mode Binary<->hex encode decode program with GUI editor for bytes replacements Binary<->hex encode decode program with stream editor for bytes replacements Output entire patched file byte by byte with echo hex encoded strings (incomplete solution)

    1. @CcxCZ 4y

      I wouldn't call Nano GUI editor. It's terminal equivalent of notepad.exe, something as dumb that the controls fit on the bottom line of the screen. (Of course it wouldn't be software if it didn't bloat to the point of now having a syntax highlighting engine. It's editing capabilities are still as sharp as a spoon though.)

      1. @Santiaga 4y

        TUI, if you like. The point was it's interactive editor, not stream.

        1. @CcxCZ 4y

          Yeah. A CLI editor such as sam or ed would actually make sense here though for non-interactive use. As would dd invocations with precise byte offsets. But it would be less galaxy brain approach.

          1. @Santiaga 4y

            In addition, sed will make too many incorrect replacements on such a short pattern. dd is the more efficient way if you know the exact offset.

            1. @CcxCZ 4y

              Yeah, it kind of reminded me of CRISPR. AKA why we don't allow genetic editing of human embryos. You have no clue what places the edits might end up affecting.

  16. @CcxCZ 4y

    xxd is a tool that ships with Vim that allows you to encode and decode hexadecimal formats. The -r flag is "reverse", that is it converts hexadecimal representation of a file back to normal. https://linux.die.net/man/1/xxd It's rather simplistic. If you need actual binary patch format there is plenty to choose from. Even the Intel .HEX format can be used as one.

  17. @ZgGPuo8dZef58K6hxxGVj3Z2 4y

    What is :%!xxd ?

    1. dev_meme 4y

      launch external executable, xxd

      1. @ZgGPuo8dZef58K6hxxGVj3Z2 4y

        Yuuki and @CcxCZ thanks! On what platforms does this work?

        1. dev_meme 4y

          i think every platform which supports vim and xxd

        2. @CcxCZ 4y

          Any capable of running Vim

          1. @CcxCZ 4y

            xxd is part of Vim technically. But you may need to tweak executable path which IIRC is optional step during install on Windows.

        3. @CcxCZ 4y

          It's even in drop-down menu in gvim, unless they changed that in last decade. It's a pretty standard feature.

          1. @CcxCZ 4y

            https://cdn.arstechnica.net/wp-content/uploads/archive/vim0509/gvim_ars.png

    2. @CcxCZ 4y

      : run ex command % select all of the file ! filter through external executable, writing to it's standard input and reading from it's standard output xxd hexdump, explained in comments above

Use J and K for navigation