Skip to content

Commit beff985

Browse files
carlospolopHackTricks PEASS Autoimprover
andauthored
Auto-merge PR #661 (trusted generated PR)
Co-authored-by: HackTricks PEASS Autoimprover <peass-autoimprover@hacktricks.xyz>
1 parent b449b0e commit beff985

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

linPEAS/builder/linpeas_parts/functions/check_external_hostname.sh

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Title: LinPeasBase - check_external_hostname
22
# ID: check_external_hostname
33
# Author: Carlos Polop
4-
# Last Update: 23-05-2025
4+
# Last Update: 30-06-2026
55
# Description: This will check the public IP and hostname in known malicious lists and leaks to find any relevant information about the host.
66
# License: GNU GPL
77
# Version: 1.0
@@ -48,30 +48,31 @@ linpeas_os_package_ecosystem(){
4848
esac
4949
}
5050

51+
linpeas_tabbed_packages_to_json_lines(){
52+
awk -F '\t' -v manager="$1" -v ecosystem="$2" '
53+
function esc(s) { gsub(/\\/,"\\\\",s); gsub(/"/,"\\\"",s); gsub(/\r/," ",s); return s }
54+
$1 != "" && $2 != "" {
55+
key=$1 "|" $2
56+
if (seen[key]++) next
57+
printf "{\"name\":\"%s\",\"version\":\"%s\",\"ecosystem\":\"%s\",\"manager\":\"%s\"}\n", esc($1), esc($2), esc(ecosystem), manager
58+
}'
59+
}
60+
5161
linpeas_print_package_json_lines(){
5262
_ecosystem="$(linpeas_os_package_ecosystem)"
5363

5464
if command -v dpkg-query >/dev/null 2>&1; then
55-
dpkg-query -W -f='${source:Package}\t${source:Version}\t${binary:Package}\t${Version}\n' 2>/dev/null | awk -F '\t' -v ecosystem="$_ecosystem" '
56-
function esc(s) { gsub(/\\/,"\\\\",s); gsub(/"/,"\\\"",s); gsub(/\r/," ",s); return s }
65+
dpkg-query -W -f='${source:Package}\t${source:Version}\t${binary:Package}\t${Version}\n' 2>/dev/null | awk -F '\t' '
5766
{
5867
name=$1; version=$2
5968
if (name == "" || name == "-") { name=$3; version=$4 }
6069
if (version == "" || version == "-") { version=$4 }
6170
sub(/^src:/, "", name)
6271
if (name == "" || version == "") next
63-
key=name "|" version
64-
if (seen[key]++) next
65-
printf "{\"name\":\"%s\",\"version\":\"%s\",\"ecosystem\":\"%s\",\"manager\":\"dpkg\"}\n", esc(name), esc(version), esc(ecosystem)
66-
}'
72+
printf "%s\t%s\n", name, version
73+
}' | linpeas_tabbed_packages_to_json_lines "dpkg" "$_ecosystem"
6774
elif command -v rpm >/dev/null 2>&1; then
68-
rpm -qa --qf '%{NAME}\t%{VERSION}-%{RELEASE}\n' 2>/dev/null | awk -F '\t' -v ecosystem="$_ecosystem" '
69-
function esc(s) { gsub(/\\/,"\\\\",s); gsub(/"/,"\\\"",s); gsub(/\r/," ",s); return s }
70-
$1 != "" && $2 != "" {
71-
key=$1 "|" $2
72-
if (seen[key]++) next
73-
printf "{\"name\":\"%s\",\"version\":\"%s\",\"ecosystem\":\"%s\",\"manager\":\"rpm\"}\n", esc($1), esc($2), esc(ecosystem)
74-
}'
75+
rpm -qa --qf '%{NAME}\t%{VERSION}-%{RELEASE}\n' 2>/dev/null | linpeas_tabbed_packages_to_json_lines "rpm" "$_ecosystem"
7576
elif command -v apk >/dev/null 2>&1; then
7677
apk info 2>/dev/null | while IFS= read -r _pkg_name; do
7778
[ "$_pkg_name" ] || continue
@@ -82,13 +83,7 @@ linpeas_print_package_json_lines(){
8283
"$(linpeas_json_escape "$_pkg_name")" "$(linpeas_json_escape "$_pkg_version")" "$(linpeas_json_escape "$_ecosystem")"
8384
done
8485
elif command -v pacman >/dev/null 2>&1; then
85-
pacman -Q 2>/dev/null | awk -v ecosystem="$_ecosystem" '
86-
function esc(s) { gsub(/\\/,"\\\\",s); gsub(/"/,"\\\"",s); gsub(/\r/," ",s); return s }
87-
$1 != "" && $2 != "" {
88-
key=$1 "|" $2
89-
if (seen[key]++) next
90-
printf "{\"name\":\"%s\",\"version\":\"%s\",\"ecosystem\":\"%s\",\"manager\":\"pacman\"}\n", esc($1), esc($2), esc(ecosystem)
91-
}'
86+
pacman -Q 2>/dev/null | linpeas_tabbed_packages_to_json_lines "pacman" "$_ecosystem"
9287
fi
9388
}
9489

0 commit comments

Comments
 (0)