{"id":19430240,"url":"https://github.com/8dcc/bin-graph","last_synced_at":"2025-04-06T01:09:49.392Z","repository":{"id":249317503,"uuid":"831053130","full_name":"8dcc/bin-graph","owner":"8dcc","description":"Visualize binary files","archived":false,"fork":false,"pushed_at":"2025-04-05T09:53:11.000Z","size":291,"stargazers_count":129,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T10:30:04.657Z","etag":null,"topics":["binary-analysis","c","libpng","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/8dcc.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-19T14:50:07.000Z","updated_at":"2025-04-05T09:53:14.000Z","dependencies_parsed_at":"2024-07-20T02:23:52.909Z","dependency_job_id":"936a1104-084f-49e5-8ca2-a43e4b764351","html_url":"https://github.com/8dcc/bin-graph","commit_stats":null,"previous_names":["8dcc/bin-graph"],"tags_count":0,"template":false,"template_full_name":"8dcc/c-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8dcc%2Fbin-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8dcc%2Fbin-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8dcc%2Fbin-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8dcc%2Fbin-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/8dcc","download_url":"https://codeload.github.com/8dcc/bin-graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419861,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-analysis","c","libpng","reverse-engineering"],"created_at":"2024-11-10T14:24:05.859Z","updated_at":"2025-04-06T01:09:49.375Z","avatar_url":"https://github.com/8dcc.png","language":"C","readme":"#+title: Binary graph\n#+options: toc:nil\n#+startup: showeverything\n#+author: 8dcc\n\nThis program provides a simple way of visualizing the different regions of a\nbinary file.\n\nThese are some references that inspired this project:\n\n- [[https://github.com/xoreaxeaxeax][Christopher Domas]] - The future of RE Dynamic Binary Visualization ([[https://www.youtube.com/watch?v=4bM3Gut1hIk][YouTube]]).\n- Sergey Bratus and Greg Conti - Voyage of the reverser ([[https://www.youtube.com/watch?v=T3qqeP4TdPA][YouTube]]).\n- [[https://corte.si][Aldo Cortesi]] - [[https://corte.si/posts/visualisation/binvis/][Visualizing binaries with space-filling curves]].\n- Aldo Cortesi - [[https://corte.si/posts/visualisation/entropy/][Visualizing entropy in binary files]].\n\nIf you are interested on more professional approaches, check out the following\nlinks:\n\n- The [[https://binvis.io][binvis.io]] online tool by Aldo Cortesi.\n- The [[https://github.com/mewbak/binary_viewer][mewbak/binary_viewer]] repository, which also includes some other links.\n- The [[https://github.com/wapiflapi/veles][wapiflapi/veles]] repository, which is no longer maintained.\n\n* Building\n\nThe program depends on =libpng= for exporting the image. Install it from your\npackage manager.\n\n#+begin_src bash\n# Arch-based distros\npacman -S libpng\n\n# Gentoo\nemerge media-libs/libpng\n#+end_src\n\nOnce all the dependencies are installed, compile the program.\n\n#+begin_src bash\ngit clone https://github.com/8dcc/bin-graph\ncd bin-graph\nmake\n#+end_src\n\nIf you want to install it on your system, run the following command.\n\n#+begin_src bash\nsudo make install\n#+end_src\n\n* Usage and modes\n\nThere are various different graph modes that determine how the input binary is\nrepresented in the output image. The full mode list with their descriptions can\nbe found with the program's =help= command.\n\n#+begin_src bash\nbin-graph --help\n# Usage:\n#   ./bin-graph [OPTION...] INPUT OUTPUT.png\n#\n# ...\n#+end_src\n\nThis project also includes a [[file:bin-graph-section.sh][bin-graph-section.sh]] script. It uses =readelf= and\n=grep= to find the offset and size of the specified region, and uses that as the\n=--offset-*= arguments for =bin-graph=. Additional options after the section name\nwill be passed to =bin-graph=.\n\n#+begin_src bash\n./bin-graph-section.sh SECTION [OPTION...] INPUT OUTPUT.png\n# ...\n#+end_src\n\n* Overview of the code\n\nI tried to make each part of the program as modular and independent as possible,\nfor more maintainability and for easier expansion.\n\nThis is the basic process for generating an image from a binary.\n\n1. The arguments are parsed, and the necessary global variables in [[file:src/args.c][args.c]] are\n   overwritten. These will be used from all the sources.\n2. The data is read from the input file as a byte array, using the =read_file=\n   function, defined in [[file:src/read_file.c][read_file.c]].\n3. The array of bytes is converted into an =Image= structure, which is just an\n   array of RGB =Color= structures, along with its dimensions. The program mode\n   (which might have been overwritten with the =--mode= parameter) determines what\n   =image_*= function is used. These =image_*= functions are defined in [[file:src/image.c][image.c]]. For\n   more information on the available modes, see [[*Usage and modes][Usage and modes]].\n4. The =Image= structure is converted into a PNG file with the =image2png= function,\n   defined in [[file:src/image.c][image.c]].\n\n* Screenshots\n\n#+begin_src bash\n./bin-graph --mode grayscale bin-graph examples/grayscale.png\n#+end_src\n\n[[file:examples/grayscale.png]]\n\n#+begin_src bash\n./bin-graph --mode ascii bin-graph examples/ascii.png\n#+end_src\n\n[[file:examples/ascii.png]]\n\n#+begin_src bash\n./bin-graph --mode entropy --transform-squares 16 bin-graph examples/entropy-squared.png\n#+end_src\n\n[[file:examples/entropy-squared.png]]\n\n#+begin_src bash\n# Only the .text section of the ELF file\n./bin-graph-section.sh .text --mode histogram bin-graph examples/histogram.png\n#+end_src\n\n[[file:examples/histogram.png]]\n\n#+begin_src bash\n# Only the .rodata section of the ELF file\n./bin-graph-section.sh .rodata --mode bigrams bin-graph examples/rodata-bigrams.png\n#+end_src\n\n[[file:examples/rodata-bigrams.png]]\n\n#+begin_src bash\n./bin-graph --mode dotplot --zoom 1 --offset-start 5000 --offset-end 5500 input.wav examples/dotplot.png\n#+end_src\n\n[[file:examples/dotplot.png]]\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8dcc%2Fbin-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F8dcc%2Fbin-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8dcc%2Fbin-graph/lists"}