mirror of
https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite.git
synced 2025-12-11 03:09:01 +00:00
Compare commits
6 Commits
20250526-9
...
codex/find
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39066f6867 | ||
|
|
c3a93a57fe | ||
|
|
f62d9fc550 | ||
|
|
11e9b8dde6 | ||
|
|
b9a9ad5ddf | ||
|
|
88f08a405e |
@@ -26,7 +26,7 @@
|
|||||||
# License: GNU GPL
|
# License: GNU GPL
|
||||||
# Version: 1.0
|
# Version: 1.0
|
||||||
# Functions Used: echo_not_found, print_2title, print_info
|
# Functions Used: echo_not_found, print_2title, print_info
|
||||||
# Global Variables:
|
# Global Variables: $NoEnvVars, $EnvVarsRed
|
||||||
# Initial Functions:
|
# Initial Functions:
|
||||||
# Generated Global Variables:
|
# Generated Global Variables:
|
||||||
# Fat linpeas: 0
|
# Fat linpeas: 0
|
||||||
@@ -35,5 +35,5 @@
|
|||||||
|
|
||||||
print_2title "Environment"
|
print_2title "Environment"
|
||||||
print_info "Any private information inside environment variables?"
|
print_info "Any private information inside environment variables?"
|
||||||
(env || printenv || set) 2>/dev/null | grep -v "RELEVANT*|FIND*|^VERSION=|dbuslistG|mygroups|ldsoconfdG|pwd_inside_history|kernelDCW_Ubuntu_Precise|kernelDCW_Ubuntu_Trusty|kernelDCW_Ubuntu_Xenial|kernelDCW_Rhel|^sudovB=|^rootcommon=|^mounted=|^mountG=|^notmounted=|^mountpermsB=|^mountpermsG=|^kernelB=|^C=|^RED=|^GREEN=|^Y=|^B=|^NC=|TIMEOUT=|groupsB=|groupsVB=|knw_grps=|sidG|sidB=|sidVB=|sidVB2=|sudoB=|sudoG=|sudoVB=|timersG=|capsB=|notExtensions=|Wfolders=|writeB=|writeVB=|_usrs=|compiler=|LS_COLORS=|pathshG=|notBackup=|processesDump|processesB|commonrootdirs|USEFUL_SOFTWARE|PSTORAGE_" | sed -${E} "s,[pP][aA][sS][sS][wW]|[aA][pP][iI][kK][eE][yY]|[aA][pP][iI][_][kK][eE][yY]|KRB5CCNAME,${SED_RED},g" || echo_not_found "env || set"
|
(env || printenv || set) 2>/dev/null | grep -Eiv "$NoEnvVars" | sed -${E} "s,$EnvVarsRed,${SED_RED},g" || echo_not_found "env || set"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -6,21 +6,17 @@
|
|||||||
# License: GNU GPL
|
# License: GNU GPL
|
||||||
# Version: 1.0
|
# Version: 1.0
|
||||||
# Functions Used: print_2title
|
# Functions Used: print_2title
|
||||||
# Global Variables: $MACPEAS
|
# Global Variables: $MACPEAS, $NoEnvVars, $EnvVarsRed
|
||||||
# Initial Functions:
|
# Initial Functions:
|
||||||
# Generated Global Variables:
|
# Generated Global Variables:
|
||||||
# Fat linpeas: 0
|
# Fat linpeas: 0
|
||||||
# Small linpeas: 1
|
# Small linpeas: 1
|
||||||
|
|
||||||
if [ -z "$MACPEAS" ]; then
|
if [ -z "$MACPEAS" ]; then
|
||||||
print_2title "Searching possible sensitive environment variables inside of /proc/*/environ"
|
print_2title "Checking all env variables in /proc/*/environ removing duplicates and filtering out useless env vars"
|
||||||
for f in /proc/[0-9]*/environ; do
|
cat /proc/[0-9]*/environ 2>/dev/null | \
|
||||||
[ -r "$f" ] || continue
|
tr '\0' '\n' | \
|
||||||
tr '\0' '\n' < "$f" | \
|
grep -Eiv "$NoEnvVars" | \
|
||||||
grep -aEi "(token|password|secret|aws|azure|gcp|api|key|jwt|session|cookie|database|sql|mongo|postgres)" | \
|
sort -u | \
|
||||||
grep -avEi '(XDG_SESSION|DBUS_SESSION|systemd\/sessions)' | \
|
sed -${E} "s,$EnvVarsRed,${SED_RED},g"
|
||||||
while read -r g; do
|
|
||||||
echo "$f: $g"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
18
linPEAS/builder/linpeas_parts/variables/EnvVarsRed.sh
Normal file
18
linPEAS/builder/linpeas_parts/variables/EnvVarsRed.sh
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Title: Variables - EnvVarsRed
|
||||||
|
# ID: EnvVarsRed
|
||||||
|
# Author: Carlos Polop
|
||||||
|
# Last Update: 26-05-2025
|
||||||
|
# Description: Useless env vars
|
||||||
|
# License: GNU GPL
|
||||||
|
# Version: 1.0
|
||||||
|
# Functions Used:
|
||||||
|
# Global Variables:
|
||||||
|
# Initial Functions:
|
||||||
|
# Generated Global Variables: $EnvVarsRed
|
||||||
|
# Fat linpeas: 0
|
||||||
|
# Small linpeas: 1
|
||||||
|
|
||||||
|
|
||||||
|
EnvVarsRed="[pP][aA][sS][sS][wW]|[aA][pP][iI][kK][eE][yY]|[aA][pP][iI][_][kK][eE][yY]|KRB5CCNAME|[aA][pP][iI][_][kK][eE][yY]|[aA][wW][sS]|[aA][zZ][uU][rR][eE]|[gG][cC][pP]|[aA][pP][iI]|[sS][eE][cC][rR][eE][tT]|[sS][qQ][lL]|[dD][aA][tT][aA][bB][aA][sS][eE]|[tT][oO][kK][eE][nN]"
|
||||||
|
|
||||||
|
|
||||||
16
linPEAS/builder/linpeas_parts/variables/NoEnvVars.sh
Normal file
16
linPEAS/builder/linpeas_parts/variables/NoEnvVars.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Title: Variables - NoEnvVars
|
||||||
|
# ID: NoEnvVars
|
||||||
|
# Author: Carlos Polop
|
||||||
|
# Last Update: 26-05-2025
|
||||||
|
# Description: Useless env vars
|
||||||
|
# License: GNU GPL
|
||||||
|
# Version: 1.0
|
||||||
|
# Functions Used:
|
||||||
|
# Global Variables:
|
||||||
|
# Initial Functions:
|
||||||
|
# Generated Global Variables: $NoEnvVars
|
||||||
|
# Fat linpeas: 0
|
||||||
|
# Small linpeas: 1
|
||||||
|
|
||||||
|
|
||||||
|
NoEnvVars="LESS_TERMCAP|JOURNAL_STREAM|XDG_SESSION|DBUS_SESSION|systemd\/sessions|systemd_exec|MEMORY_PRESSURE_WATCH|RELEVANT*|FIND*|^VERSION=|dbuslistG|mygroups|ldsoconfdG|pwd_inside_history|kernelDCW_Ubuntu_Precise|kernelDCW_Ubuntu_Trusty|kernelDCW_Ubuntu_Xenial|kernelDCW_Rhel|^sudovB=|^rootcommon=|^mounted=|^mountG=|^notmounted=|^mountpermsB=|^mountpermsG=|^kernelB=|^C=|^RED=|^GREEN=|^Y=|^B=|^NC=|TIMEOUT=|groupsB=|groupsVB=|knw_grps=|sidG|sidB=|sidVB=|sidVB2=|sudoB=|sudoG=|sudoVB=|timersG=|capsB=|notExtensions=|Wfolders=|writeB=|writeVB=|_usrs=|compiler=|LS_COLORS=|pathshG=|notBackup=|processesDump|processesB|commonrootdirs|USEFUL_SOFTWARE|PSTORAGE_|^PATH=|^INVOCATION_ID=|^WATCHDOG_PID=|^LISTEN_PID="
|
||||||
@@ -106,8 +106,6 @@ def parse_line(line: str):
|
|||||||
|
|
||||||
global FINAL_JSON, C_SECTION, C_MAIN_SECTION, C_2_SECTION, C_3_SECTION
|
global FINAL_JSON, C_SECTION, C_MAIN_SECTION, C_2_SECTION, C_3_SECTION
|
||||||
|
|
||||||
if "Cron jobs" in line:
|
|
||||||
a=1
|
|
||||||
|
|
||||||
if is_section(line, TITLE1_PATTERN):
|
if is_section(line, TITLE1_PATTERN):
|
||||||
title = parse_title(line)
|
title = parse_title(line)
|
||||||
@@ -145,17 +143,26 @@ def parse_line(line: str):
|
|||||||
|
|
||||||
|
|
||||||
def parse_peass(outputpath: str, jsonpath: str = ""):
|
def parse_peass(outputpath: str, jsonpath: str = ""):
|
||||||
global OUTPUT_PATH, JSON_PATH
|
global OUTPUT_PATH, JSON_PATH, FINAL_JSON, C_SECTION, C_MAIN_SECTION, C_2_SECTION, C_3_SECTION
|
||||||
|
|
||||||
OUTPUT_PATH = outputpath
|
OUTPUT_PATH = outputpath
|
||||||
JSON_PATH = jsonpath
|
JSON_PATH = jsonpath
|
||||||
|
|
||||||
for line in open(OUTPUT_PATH, 'r', encoding="utf8").readlines():
|
# Reset globals to avoid data leaking between executions
|
||||||
line = line.strip()
|
FINAL_JSON = {}
|
||||||
if not line or not clean_colors(line): #Remove empty lines or lines just with colors hex
|
C_SECTION = FINAL_JSON
|
||||||
continue
|
C_MAIN_SECTION = FINAL_JSON
|
||||||
|
C_2_SECTION = FINAL_JSON
|
||||||
|
C_3_SECTION = FINAL_JSON
|
||||||
|
|
||||||
parse_line(line)
|
with open(OUTPUT_PATH, 'r', encoding="utf8") as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
# Remove empty lines or lines containing only color codes
|
||||||
|
if not line or not clean_colors(line):
|
||||||
|
continue
|
||||||
|
|
||||||
|
parse_line(line)
|
||||||
|
|
||||||
if JSON_PATH:
|
if JSON_PATH:
|
||||||
with open(JSON_PATH, "w") as f:
|
with open(JSON_PATH, "w") as f:
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace winPEAS.Helpers
|
|||||||
/---------------------------------------------------------------------------------\
|
/---------------------------------------------------------------------------------\
|
||||||
| {1}Do you like PEASS?{0} |
|
| {1}Do you like PEASS?{0} |
|
||||||
|---------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------|
|
||||||
| {3}Learn Cloud Hacking{0} : {2}training.hacktricks.xyz {0} |
|
| {3}Learn Cloud Hacking{0} : {2}training.hacktricks.xyz {0} |
|
||||||
| {3}Follow on Twitter{0} : {2}@hacktricks_live{0} |
|
| {3}Follow on Twitter{0} : {2}@hacktricks_live{0} |
|
||||||
| {3}Respect on HTB{0} : {2}SirBroccoli {0} |
|
| {3}Respect on HTB{0} : {2}SirBroccoli {0} |
|
||||||
|---------------------------------------------------------------------------------|
|
|---------------------------------------------------------------------------------|
|
||||||
|
|||||||
@@ -195,11 +195,11 @@ namespace winPEAS.Info.ProcessInfo
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
List<string> permsFile = PermissionsHelper.GetPermissionsFile(sFilePath, Checks.Checks.CurrentUserSiDs, PermissionType.WRITEABLE_OR_EQUIVALENT);
|
List<string> permsFile = PermissionsHelper.GetPermissionsFile(sFilePath, Checks.Checks.CurrentUserSiDs, PermissionType.WRITEABLE_OR_EQUIVALENT);
|
||||||
|
IdentityReference sid = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
System.Security.AccessControl.FileSecurity fs = System.IO.File.GetAccessControl(sFilePath);
|
System.Security.AccessControl.FileSecurity fs = System.IO.File.GetAccessControl(sFilePath);
|
||||||
IdentityReference sid = fs.GetOwner(typeof(SecurityIdentifier));
|
sid = fs.GetOwner(typeof(SecurityIdentifier));
|
||||||
string ownerName = sid.Translate(typeof(NTAccount)).ToString();
|
|
||||||
|
|
||||||
// If current user already have permissions over that file or the proc belongs to the owner of the file,
|
// If current user already have permissions over that file or the proc belongs to the owner of the file,
|
||||||
// handler not interesting to elevate privs
|
// handler not interesting to elevate privs
|
||||||
@@ -207,6 +207,8 @@ namespace winPEAS.Info.ProcessInfo
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
to_add["File Path"] = sFilePath;
|
to_add["File Path"] = sFilePath;
|
||||||
|
|
||||||
|
string ownerName = sid.Translate(typeof(NTAccount)).ToString();
|
||||||
to_add["File Owner"] = ownerName;
|
to_add["File Owner"] = ownerName;
|
||||||
}
|
}
|
||||||
catch (System.IO.FileNotFoundException)
|
catch (System.IO.FileNotFoundException)
|
||||||
@@ -218,7 +220,10 @@ namespace winPEAS.Info.ProcessInfo
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
catch (System.Security.Principal.IdentityNotMappedException)
|
||||||
|
{
|
||||||
|
to_add["File Owner"] = sid.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (typeName == "key")
|
else if (typeName == "key")
|
||||||
|
|||||||
Reference in New Issue
Block a user