{"id":18151274,"url":"https://github.com/msantos/hexlog","last_synced_at":"2025-06-24T18:35:42.313Z","repository":{"id":136621423,"uuid":"299014340","full_name":"msantos/hexlog","owner":"msantos","description":"Hexdump stdin and/or stdout to stderr","archived":false,"fork":false,"pushed_at":"2024-12-06T14:00:38.000Z","size":107,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T23:31:53.323Z","etag":null,"topics":["capsicum","exec","fork","hexdump","pledge","seccomp","setrlimit","stdio"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msantos.png","metadata":{"files":{"readme":"README.md","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":"2020-09-27T11:12:24.000Z","updated_at":"2024-12-06T14:00:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"695453db-0e0d-46c3-af1f-bce976f65189","html_url":"https://github.com/msantos/hexlog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/msantos/hexlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fhexlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fhexlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fhexlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fhexlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msantos","download_url":"https://codeload.github.com/msantos/hexlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msantos%2Fhexlog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261734644,"owners_count":23201866,"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":["capsicum","exec","fork","hexdump","pledge","seccomp","setrlimit","stdio"],"created_at":"2024-11-02T01:07:10.799Z","updated_at":"2025-06-24T18:35:42.287Z","avatar_url":"https://github.com/msantos.png","language":"C","readme":"# SYNOPSIS\n\nhexlog [r]**in**|[r]**out**|[r]**inout**|**none** *cmd* *...*\n\n# DESCRIPTION\n\nhexlog: hexdump stdin and/or stdout to stderr\n\nhexlog streams a hexdump (or optionally the raw bytes) of the standard\nI/O of a subprocess to standard error. Hexdumps can be enabled or disabled\nby sending a signal (see *SIGNALS*).\n\nThe hexdump code originates from:\n\nhttps://gist.github.com/ccbrown/9722406\n\n# EXAMPLES\n\n```\n$ echo abc | hexlog inout cat -n\n     1  abc\n61 62 63 0A                                       |abc.| (0)\n20 20 20 20 20 31 09 61  62 63 0A                 |     1.abc.| (1)\n\n$ (echo test | HEXLOG_FD_STDIN=4 HEXLOG_FD_STDOUT=5 hexlog inout cat) 4\u003estdin 5\u003estdout\n\n$ echo abc | hexlog rinout cat -n\n     1  abc\nabc\n     1  abc\n\n```\n\n# Build\n\n```\nmake\n\n# selecting process restrictions\nRESTRICT_PROCESS=seccomp make\n\n#### using musl\nRESTRICT_PROCESS=rlimit ./musl-make\n\n## linux seccomp sandbox: requires kernel headers\n\n# clone the kernel headers somewhere\nexport MUSL_INCLUDE=/tmp\ngit clone https://github.com/sabotage-linux/kernel-headers.git $MUSL_INCLUDE/kernel-headers\n\n# then compile\nMUSL_INCLUDE=/tmp ./musl-make clean all\n```\n\n# OPTIONS\n\nNone.\n\n# ARGUMENTS\n\nnone\n: do not dump stdio\n\nin\n: dump stdin\n\nout\n: dump stdout\n\ninout\n: dump stdin/stdout\n\nPrefacing a stream with 'r' will dump the raw bytes: rnone, rin,\nrout, rinout.\n\n# ENVIRONMENT VARIABLES\n\nHEXLOG_LABEL_STDIN=\" (0)\"\n: Label attached to hexdump of the stdin stream.\n\nHEXLOG_LABEL_STDOUT=\" (1)\"\n: Label attached to hexdump of the stdout stream.\n\nHEXLOG_FD_STDIN=\"2\"\n: File descriptor to write dump of the stdin stream.\n\nHEXLOG_FD_STDOUT=\"2\"\n: File descriptor to write dump of the stdout stream.\n\nHEXLOG_TIMEOUT=\"0\"\n: Dump any buffered data after HEXLOG_TIMEOUT seconds of inactivity\n(0 to disable)\n\n# SIGNALS\n\nSIGUSR1\n: stdin: activate or deactivate hexdump based on the initial settings\n\nSIGUSR2\n: stdout: activate or deactivate hexdump based on the initial settings\n\nSIGHUP\n: reset hexdump stdio to initial value\n\nSIGALRM\n: dump any buffered data\n\n# ALTERNATIVES\n\n## bash\n\nThe general problem is duplicating stdout to stderr which can be handled\nusing `tee(1)` and bash's process substitution:\n\n```\ntee \u003e(cat 1\u003e\u00262) | command | tee \u003e(cat 1\u003e\u00262)\n```\n\nThis pipeline forks 6 processes including bash. To hexdump:\n\n```\ntee \u003e(stdbuf -oL hexdump -C 1\u003e\u00262) | command | tee \u003e(stdbuf -oL hexdump -C 1\u003e\u00262)\n```\n\nA real version would use a format string and include the direction\n(stdin vs stdout).\n\nAnd to wrap it in a script:\n\n```\n#!/bin/bash\n\nset -o errexit\nset -o nounset\nset -o pipefail\n\ntee \u003e(stdbuf -oL hexdump -C 1\u003e\u00262) | $@ | tee \u003e(stdbuf -oL hexdump -C 1\u003e\u00262)\n```\n\nFor example:\n\n```\n./hexlog nc -l -k 9090\n```\n\nNote: hexdump doesn't exit and flush the buffer when stdin is closed. It\nwill wait for the next full write.\n\n## socat\n\n```\nsocat -xv - EXEC:\"command arg1\",pty\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Fhexlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsantos%2Fhexlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsantos%2Fhexlog/lists"}