repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
tarx.mdMarkdown203 lines13.4 KiBsource raw download

tarx — tar without the flag archaeology#

One grammar for the five things tar is actually used for: pack, unpack, list, ship over ssh, clone a tree. Compression, gpg and a live progress bar come free. Quick card: tarx-cheat. Raw pipeline: tarx -n ….

Pack#

Which format for which data#

The one decision that actually changes the outcome. Everything below is about what the bytes already are, not how big they are.

Already compressed — use -tar and skip the CPU entirely#

Recompressing compressed bytes typically buys 1% or less, and often makes the file slightly larger (compressed data looks random, and every codec adds framing).

Archive types — what it writes, what it recognises#

The flag decides the format; -o only decides the name. Name one thing and compress another and tarx warns you, because a .tar.xz full of zstd is a file whose name lies.

Flag Writes Tool used
-xz name.tar.xz xz
-gz name.tar.gz pigz, or gzip if pigz is absent
-zst name.tar.zst zstd
-bz2 name.tar.bz2 bzip2
-tar name.tar nothing — no compressor in the pipe
--encrypt / --symmetric appends .gpg gpg
--armor appends .asc instead gpg

Recognised automatically when extracting or listing — no flag needed:

Format Suffixes understood
xz .tar.xz .txz .tar.lzma
gzip .tar.gz .tgz
zstd .tar.zst .tzst
bzip2 .tar.bz2 .tbz2 .tbz
none .tar
encrypted .gpg .pgp .asc on top of any of the above

Odd or missing suffix? Force it with --format xz — the aliases gzip, zstd, bzip2, lzma, tar, none, raw all resolve.

What survives inside the archive#

Levels#

Every codec's full range, with peak memory measured on this machine (300 MB input, one thread) — the number that decides whether -9e -T0 is clever or a swap storm.

Level Dictionary / block Peak RAM Note
-xz0 256 KB 4 MB fastest xz
-xz3 4 MB 24 MB
-xz6 8 MB 78 MB xz's default
-xz9 64 MB 611 MB
-xz9e 64 MB 611 MB same dictionary, more CPU
-zst3 — 36 MB zstd's default
-zst19 — 212 MB the sweet spot
-zst22 — 1,008 MB --ultra added for you, for ~0.1%
-gz9 32 KB 2 MB gzip is always cheap
-bz29 900 KB 9 MB 9 is bzip2's default

Choosing between them#

Measured — Apple M1 Max, 10 cores, macOS 26.5#

Not folklore; run on this machine. of orig is the compressed size as a percentage of the input.

Text — 2.7 MB of dictionary words + shell config (natural prose and code)

codec of orig compress decompress
-tar 100.0% 0.01s 0.01s
-gz9 29.8% 0.30s (pigz 0.07s) 0.01s
-zst3 33.5% 0.03s 0.01s
-zst19 26.2% 0.64s 0.01s
-xz6 25.3% 0.63s 0.04s
-xz9e 25.2% 0.85s 0.04s
-bz2 33.6% 0.15s 0.06s

xz wins by 1 percentage point over -zst19. bzip2 loses to gzip outright.

Already compressed — 284 MB tar of 400 real png/jpg files

codec of orig compress decompress
-tar 100.0% 0.21s 0.30s
-zst3 99.2% 0.12s 0.11s
-zst19 99.1% 11.9s 0.09s
-zst22 99.1% 65.3s 0.40s
-xz9e 99.1% 94.4s 0.54s
-bz2 99.6% 23.0s 11.4s

94 seconds of ten cores to save 0.9%. This is the whole argument for -tar on media.

Random — 20 MB from /dev/urandom (stands in for encrypted data)

codec of orig
-tar 100.0%
-gz9 100.03% — larger than the input
-zst19 100.00%
-xz9e 100.01%
-bz2 100.4% — larger than the input

Every codec adds framing it cannot earn back. Compressing ciphertext is strictly a loss.

Unpack & inspect#

Encrypt#

Passphrases — typed in the terminal, masked#

When it asks, and when it cannot#

Over ssh — nothing lands on disk in between#

Housekeeping#

Why it does not just call tar -cJf#

Stdlib Python only — scp ~/tarx vm:~/.local/bin/ and it works. Sections: tarx-cheat pack|unpack|crypt|ssh|raw. Full flags: tarx -h.