Match Files to Packages in Debian-Based Operating Systems
dpkg-query is the Debian package database tool. It answers three questions that come up constantly during reconnaissance and forensics:
# List all installed packages
dpkg-query -l
# List every file installed by a specific package
dpkg-query -L $PACKAGE_NAME
# Find which package owns a specific file on disk
dpkg-query -S $FULL_PATH_TO_FILEWhy this matters
- Recon: On a foothold,
dpkg-query -lreveals installed software (databases, web servers, dev tools) without making network noise. - Forensics: Finding an unexpected binary in
/tmpor/dev/shm?dpkg-query -S /tmp/suspicioustells you whether it came from a package or was dropped. - Package integrity: Compare
dpkg-query -Loutput againstdebsumsorrpm -Vaequivalents to spot tampered files.
Related
- bash-wildcard-abuse — another Debian/Linux post-exploitation concern
- suid-shell-executable — SUID binaries are often identified via package queries