Compare commits

..

2 Commits

Author SHA1 Message Date
codex-action
85903a49d4 Fix CI failures for PR #579 2026-01-31 12:26:04 +00:00
HackTricks PEASS Autoimprover
3060228d5b autoimprover: simplify linpeas checks 2026-01-31 04:07:38 +00:00
6 changed files with 15 additions and 22 deletions

View File

@@ -28,7 +28,6 @@ jobs:
- name: Resolve PR context
id: gate
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
pr_number="${{ github.event.workflow_run.pull_requests[0].number }}"

View File

@@ -90,7 +90,7 @@ jobs:
run: |
gh api -X POST -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${PR_NUMBER}/labels \
-f labels[]=codex-fix-attempted
-f labels='["codex-fix-attempted"]'
- name: Checkout PR head
uses: actions/checkout@v5

View File

@@ -17,7 +17,7 @@
# Functions Used: print_2title, print_list, echo_not_found
# Global Variables: $SEARCH_IN_FOLDER, $Wfolders, $SED_RED, $SED_RED_YELLOW, $NC
# Initial Functions:
# Generated Global Variables: $WRITABLESYSTEMDPATH, $line, $service, $file, $version, $user, $caps, $path, $path_line, $service_file, $exec_line, $exec_value, $cmd, $cmd_path
# Generated Global Variables: $WRITABLESYSTEMDPATH, $line, $service, $file, $version, $user, $caps, $path, $path_line, $service_file, $exec_line, $cmd
# Fat linpeas: 0
# Small linpeas: 1
@@ -116,20 +116,18 @@ if ! [ "$SEARCH_IN_FOLDER" ]; then
# Check ExecStart paths
grep -E "ExecStart|ExecStartPre|ExecStartPost" "$service_file" 2>/dev/null |
while read -r exec_line; do
# Extract command from the right side of Exec*=, not from argv
exec_value="${exec_line#*=}"
exec_value=$(echo "$exec_value" | sed 's/^[[:space:]]*//')
cmd=$(echo "$exec_value" | awk '{print $1}' | tr -d '"')
# Strip systemd command prefixes (-, @, :, +, !) before path checks
cmd_path=$(echo "$cmd" | sed -E 's/^[-@:+!]+//')
# Extract the first word after ExecStart* as the command
cmd=$(echo "$exec_line" | awk '{print $2}' | tr -d '"')
# Extract the rest as arguments
args=$(echo "$exec_line" | awk '{$1=$2=""; print $0}' | tr -d '"')
# Only check the command path, not arguments
if [ -n "$cmd_path" ] && [ -w "$cmd_path" ]; then
echo "$service: $cmd_path (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g"
if [ -n "$cmd" ] && [ -w "$cmd" ]; then
echo "$service: $cmd (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g"
fi
# Check for relative paths only in the command, not arguments
if [ -n "$cmd_path" ] && [ "${cmd_path#/}" = "$cmd_path" ] && [ "${cmd_path#\$}" = "$cmd_path" ]; then
echo "$service: Uses relative path '$cmd_path' (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g"
if [ -n "$cmd" ] && [ "${cmd#/}" = "$cmd" ] && ! echo "$cmd" | grep -qE '^-|^--'; then
echo "$service: Uses relative path '$cmd' (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g"
fi
done
fi
@@ -155,4 +153,4 @@ if ! [ "$SEARCH_IN_FOLDER" ]; then
fi
echo ""
fi
fi

View File

@@ -524,7 +524,7 @@ namespace winPEAS.Checks
{
Beaprint.MainPrint("Looking for documents --limit 100--");
List<string> docFiles = InterestingFiles.InterestingFiles.ListUsersDocs();
Beaprint.ListPrint(MyUtils.GetLimitedRange(docFiles, 100));
Beaprint.ListPrint(docFiles.GetRange(0, docFiles.Count <= 100 ? docFiles.Count : 100));
}
catch (Exception ex)
{
@@ -546,7 +546,7 @@ namespace winPEAS.Checks
if (recFiles.Count != 0)
{
foreach (Dictionary<string, string> recF in MyUtils.GetLimitedRange(recFiles, 70))
foreach (Dictionary<string, string> recF in recFiles.GetRange(0, recFiles.Count <= 70 ? recFiles.Count : 70))
{
Beaprint.AnsiPrint(" " + recF["Target"] + "(" + recF["Accessed"] + ")", colorF);
}

View File

@@ -348,7 +348,8 @@ namespace winPEAS.Checks
Beaprint.MainPrint("DNS cached --limit 70--");
Beaprint.GrayPrint(string.Format(" {0,-38}{1,-38}{2}", "Entry", "Name", "Data"));
List<Dictionary<string, string>> DNScache = NetworkInfoHelper.GetDNSCache();
foreach (Dictionary<string, string> entry in MyUtils.GetLimitedRange(DNScache, 70))
foreach (Dictionary<string, string> entry in DNScache.GetRange(0,
DNScache.Count <= 70 ? DNScache.Count : 70))
{
Console.WriteLine($" {entry["Entry"],-38}{entry["Name"],-38}{entry["Data"]}");
}

View File

@@ -21,11 +21,6 @@ namespace winPEAS.Helpers
""); //To get the default object you need to use an empty string
}
public static List<T> GetLimitedRange<T>(List<T> items, int limit)
{
return items.GetRange(0, Math.Min(items.Count, limit));
}
////////////////////////////////////
/////// MISC - Files & Paths ///////
////////////////////////////////////