
bashacks is a GPL-licensed collection of bash helper functions that condense common low-level tasks — hashing, hex conversion, MIME-based file discovery — into short one-liners for authorized analysts and programmers.
| Tool | merces/bashacks — a set of bash functions that shorten multi-step command-line tasks into single one-liners |
| Category | Shell utility library / productivity functions |
| Primary Use | Speeding up routine analyst chores such as checksum calculation (bh_hashes), hex conversion (bh_str2hex), and MIME-based file discovery (bh_findmime) from the terminal |
| Safe Use | Intended for programmers, security analysts, and power users performing local, authorized work such as file triage, malware analysis in isolated labs, and general scripting on systems they own or administer |
| Telemetry Note | Pure local shell functions with no network beaconing except optional calls like bh_myip querying an external IP service via curl/wget; defenders reviewing the sourced bashacks.sh file can read every function since all logic is plain bash gluing standard UNIX tools |
bashacks occupies a deceptively simple niche in the security tooling landscape: rather than introducing any new capability, it wraps decades-old UNIX utilities into short, composable bash functions. The author is explicit about this in the README, stating there is nothing really new in the project — every function is written using existing software found on UNIX-like systems. The value proposition is ergonomics: tasks that would normally require a pipeline of several commands collapse into a single invocation prefixed with bh_. For analysts who live in a terminal during authorized engagements or lab triage, that reduction in keystrokes and cognitive overhead is the entire product, and at roughly 211 stars on GitHub it has clearly resonated with an audience that appreciates minimalism over framework-heavy alternatives.
The architecture is about as transparent as tooling gets. A make invocation concatenates the individual function files into a single bashacks.sh, which you then source into your shell. Because everything is plain bash, there is no compiled binary to audit, no opaque daemon, and no dependency on anything beyond standard system packages: bash >= 4, bc, binutils, coreutils, curl, file, grep, hexdump, html2text, perl, sed, wget, xxd, and zip. This dependency list itself reads like a map of the tool's functional surface — arithmetic via bc, binary inspection via binutils and xxd, web fetches via curl and wget — and it means any defender or reviewer can trace exactly what each function does by reading a few lines of shell.
Discovery of the function set follows standard bash completion conventions: after sourcing, typing bh_ and pressing Tab enumerates the available functions. This is a small but telling design choice, because it signals the author expects users to treat the library as an organic extension of the shell rather than a separate program with its own CLI grammar and subcommands. The README also shows how to make the load persistent by appending a source line to ~/.bash_profile, which is the typical deployment pattern for a personal toolkit carried across assessment workstations and analysis VMs.
The documented examples cluster around quick-reference computations. bh_epoch returns the current time in Epoch format, useful when correlating shell activity with log timestamps. bh_charcalc f + 4 performs alphabetical arithmetic, shifting a character forward by an offset — a niche trick that occasionally surfaces in CTF-style puzzles and encoding exercises. bh_myip reports your external IP address, one of the few functions that touches the network at all, doing so through the bundled curl/wget dependencies. Each of these replaces what would otherwise be a date +%s, an printf/tr contortion, or a browser visit respectively.
Where bashacks earns its malware-analysis topic tag is in the file-triage functions. bh_hashes computes common checksums for one or more files in a single pass, and the README demonstrates it across /bin/ip*, emitting what appears to be MD5, SHA-1, and SHA-256 digests side by side. That triple-hash output is exactly what analysts paste into threat-intelligence lookup workflows or record in chain-of-custody notes during lab examination of suspicious binaries, all without remembering three separate md5sum/sha1sum/sha256sum invocations.
The companion function bh_findmime is arguably more interesting from a hunting perspective: it locates files by MIME type while ignoring file extensions. The example bh_findmime -elf /bin surfaces ELF executables regardless of what they are named, which is precisely the behavior you want when triaging a directory where a payload may be masquerading under a benign extension. Piping its output into xargs shasum, as the README shows with a -pe filter over a Downloads folder, turns it into a compact inventory pipeline: find all PE files, hash them, and you have an artifact manifest ready for further review in an authorized lab context.
String and encoding helpers round out the documented set. bh_str2hex converts a string to hexadecimal in three output formats: space-separated bytes by default, escaped \xNN sequences with -x, and C-style array initialization with -c. Anyone who has written shellcode-adjacent C, built binary format parsers, or prepared byte patterns for a debugger knows how tedious these conversions are by hand, and having all three canonical formats one flag apart is a genuine quality-of-life improvement. The README also mentions bh_strxor in the known-issues section, an XOR-based string transform, which is equally relevant to encoding puzzles and simple obfuscation analysis.
Those known issues are worth reading closely because they reveal the project's maturity and its author's honesty. String escaping is the first: because bash interprets special characters, arguments containing $, quotes, or backslashes must be escaped or double-quoted before functions like bh_strxor process them correctly. This is inherent to shell scripting rather than a bug in bashacks, but it is the kind of edge case that will bite an analyst mid-task if unanticipated, so the documented workaround of wrapping input in double quotes with escaped metacharacters is worth internalizing early.
The second documented limitation is Zsh compatibility. Many functions rely on bash word splitting, which Zsh disables by default, so setopt sh_word_split is required to make the library behave under that shell. This is a common friction point for porting bash tooling to Zsh environments, and the fact that the author documents the fix rather than ignoring the issue suggests a maintainer who expects real-world usage across heterogeneous setups. It also serves as a caution: if your daily driver is Zsh with a heavily customized configuration, verify the functions you depend on behave identically after the option change.
Documentation exists at bashacks.readthedocs.io, though the author candidly admits it is outdated and invites pull requests. For a reviewer, that admission cuts both ways: it is a transparency plus, but it also means the README inside the repository is the authoritative reference, and the Tab-completion enumeration is the practical discovery mechanism for the functions beyond the documented examples. The README closes with the note that there is much more to explore, implying the function surface extends well past the showcased utilities, and that basic error handling returns 1 when arguments are missing — a convention that makes the functions scripting-friendly for callers that check exit codes.
Licensed under GPL-3.0 and written entirely in Shell, bashacks fits naturally into an authorized workflow: a lab VM or assessment workstation where the analyst wants local, auditable helpers with zero exotic dependencies. Its telemetry footprint is effectively nil by design — the functions run locally and only reach the network when explicitly asked, such as the external IP lookup. From a defensive-review standpoint, the entire codebase being readable bash means a security team can audit it in minutes before deployment, a property that cannot be said for most tooling in this space, and one that makes it a low-risk addition to a professional's shell configuration.
merces/bashacks.Educational analysis for authorized security professionals. Use only in controlled, authorized environments.
Related coverage
0 comentários:
Post a Comment
Note: Only a member of this blog may post a comment.