Commit Graph
46 Commits
Author SHA1 Message Date
Carlos Polop 1ea8107bf5 Fix bot PR auto-merge and linpeas exclude matching 2026-05-21 13:03:38 +02:00
GiveenandGitHub 115b7e60a7 MITRE ATT&CK Integration for LinPEAS and WinPEAS (#614)
* feat: MITRE ATT&CK integration for LinPEAS and WinPEAS

- Add -T T1234,T5678 flag to LinPEAS to filter checks by technique
- Add mitre=T1234,T5678 argument to WinPEAS for technique-based filtering
- Annotate every check title with MITRE technique ID(s) displayed in grey
- Add $_mitre_tag to Generated Global Variables in 0_variables_base.sh
- Add check_mitre_filter() shell function with prefix-match support
- Add MitreAttackIds property to ISystemCheck interface (C#)
- Update MainPrint/GreatPrint in Beaprint.cs to accept optional mitreIds
- Tag all 158 LinPEAS check modules with # Mitre: metadata
- Tag all 16 WinPEAS check classes with MitreAttackIds property
- Update linpeasModule.py to parse # Mitre: metadata field
- Update linpeasBaseBuilder.py to emit check_mitre_filter wrappers
- Add 3 MITRE argument parsing tests to ArgumentParsingTests.cs

* test: add MITRE filter coverage for LinPEAS builder and WinPEAS

LinPEAS (test_builder.py):
- test_mitre_flag_present_in_getopts: -T: must appear in getopts string
- test_mitre_flag_present_in_help_text: -T must appear in built help text
- test_mitre_filter_function_present: check_mitre_filter() must be in built script

WinPEAS (ArgumentParsingTests.cs):
- PassesMitreFilter_EmptyFilter_AllChecksPass: no filter -> all checks run
- PassesMitreFilter_ExactMatch_Passes: T1082 filter matches T1082 check
- PassesMitreFilter_NoMatch_Fails: T1082 filter rejects T1057 check
- PassesMitreFilter_PrefixMatch_Passes: T1552 filter matches T1552.001/T1552.005
- PassesMitreFilter_SubtechniqueDoesNotMatchDifferentBase_Fails: T1548 != T1552.001

* chore: ignore .github/instructions/ and untrack todos.instructions.md

* fix: complete and accurate MITRE ATT&CK mappings for LinPEAS and WinPEAS

gitignore:
- Add .github/instructions/ to .gitignore and untrack todos.instructions.md

LinPEAS — corrected mappings:
- 29_Interesting_environment_variables.sh: add missing T1552.007,T1082
- 3_USBCreator.sh: T1548 → T1548.003,T1068 (polkit bypass + CVE-class exploit)
- 9_Doas.sh: T1548 → T1548.003 (doas is a sudo/sudo-caching equivalent)
- 10_Pkexec.sh: T1548 → T1548.003,T1548.004,T1068 per-section specificity
- 2_Process_cred_in_memory.sh: T1003,T1055 → T1003.007 (Proc Filesystem, drop wrong T1055)
- 11_Superusers.sh: T1087.001,T1548 → T1087.001 (discovery only, no elevation abuse)
- 14/15/16 writable files: T1574 → T1574.009,T1574.010 (specific sub-techniques)

WinPEAS — corrected mappings:
- SystemInfo: class expanded to full technique union; WSUS T1195→T1072,T1068;
  KrbRelayUp T1558→T1187,T1558; Object Manager T1548→T1068;
  Named Pipes T1559.001→T1559; Low-priv pipes T1559.001→T1134.001,T1559
- EventsInfo: class expanded with T1078.003,T1552.001,T1059.001,T1082
- UserInfo: class expanded; Token privileges T1134→T1134.001
- ProcessInfo: Leaked Handlers T1134.003→T1134.001 (token impersonation, not make-token)
- ServicesInfo: class adds T1574.011,T1068
- ApplicationsInfo: class adds T1010,T1014
- NetworkInfo: class adds T1018,T1090
- ActiveDirectoryInfo: T1484→T1484.001; class adds T1003
- WindowsCreds: class sub-techniques T1552→T1552.001,T1552.002, T1555→T1555.003,T1555.004;
  SSClient T1059→T1552.001 (wrong technique entirely)
- FilesInfo: class expanded with T1552.002,T1552.004,T1552.006,T1564.001,T1574.001,
  T1059.004,T1114.001,T1218,T1649; Cloud Credentials T1552.005→T1552.001
- SoapClientInfo: T1059,T1071→T1559,T1071.001 (IPC/Web protocol, not scripting)

* fix: add missing T1613 and T1562.001 to SystemInfo class-level MitreAttackIds; label AD object enumeration with T1087.002 and T1018

* fix: correct linpeas mitre filter matching logic

* fix: MITRE code bugs — pass-through for untagged checks, remove dead OR in section gate

- PassesMitreFilter (Checks.cs): when MitreAttackIds is null or empty and a filter
  is active, return true (pass-through) instead of false.  Previously any future
  ISystemCheck added without MITRE IDs would be silently excluded by an active filter.
- linpeasBaseBuilder.py: remove redundant '|| [ -z "$MITRE_FILTER" ]' from the
  generated section-level gate.  check_mitre_filter already returns 0 immediately
  when MITRE_FILTER is empty, so the OR branch was unreachable and inconsistent with
  the check-level gate which uses the same function without the extra guard.
- ArgumentParsingTests.cs: add PassesMitreFilter_NullMitreAttackIds_PassesThrough
  and PassesMitreFilter_EmptyMitreAttackIds_PassesThrough regression tests.

* fix(mitre): 4 bugs — dead arg parser, wait logic, subprocess forks, cleanup race

Checks.cs: max-regex-file-size used string.Equals which requires exact match,
so 'max-regex-file-size=500000' could never match and MaxRegexFileSize was stuck
at 1000000 forever. Fixed to arg.StartsWith.

Checks.cs RunChecks: wait compared loop index i against
_systemCheckSelectedKeysHashSet.Count, which is 0 when all checks run (so
i < -1 is always false) and semantically wrong when a key subset is selected.
Replaced with a pre-count of checks that pass both filters and a running counter.

0_variables_base.sh check_mitre_filter: replaced two $(echo ... | tr ...)
subprocess forks per call with pure parameter-expansion while-loops. Zero
process forks, POSIX-compliant, ~632 fork()s saved per full filtered run.
Declares _mitre_tags_left and _mitre_filters_left in Generated Global Variables.

linpeas_builder.py: os.remove of the shared temp file raised FileNotFoundError
when multiple sequential builder invocations ran (the second saw the file
already deleted by the first). Wrapped in try/except FileNotFoundError.

Tests: Added PassesMitreFilter_SubtechniqueFilter_DoesNotMatchParentOnlyTag
and MaxRegexFileSize_ArgParsed_Correctly regression tests (16 total).

* ci: add manual build-artifacts workflow (winPEAS.exe + linpeas.sh)

* fix(linpeas): getopts silent mode — clear error when -T given without argument

Switch getopts to silent mode (leading ':') so the shell does not emit its
own terse 'No arg for -T option' message. Add explicit :) case that prints
  ERROR: -T requires an argument (e.g. -T T1082,T1552)
and then dumps the help text before exiting 1. Add *) case for unrecognised
flags with the same pattern. Behaviour for all valid flags is unchanged.

* chore: untrack build-artifacts workflow, add to .gitignore
2026-03-08 01:26:40 +01:00
Carlos Polop 98e5e7c3f2 f 2026-02-24 21:31:15 +01:00
Carlos Polop 381bf74ebd test: intentional master break in linpeas builder for chack validation 2026-02-14 01:03:28 +01:00
Carlos Polop 1473fedcbf Fix linPEAS module section path matching 2026-01-21 15:21:50 +01:00
SirBroccoliandGitHub d707317278 Auto-merge PR #567 (Codex) 2026-01-20 17:23:33 +00:00
Carlos Polop 1d4b748cbc Fix builder GTFOBins parsing and protections metadata 2026-01-16 18:07:04 +01:00
Carlos Polop 69371f825e Fix GTFOBins list fetch for linpeas builder 2026-01-16 18:01:40 +01:00
SirBroccoliandGitHub 4061cef7e8 Merge pull request #476 from peass-ng/codex/fix-url-reference-in-linpeasbuilder.py
Fix url variable reference in linpeasBuilder
2025-06-25 01:59:43 +02:00
SirBroccoliandGitHub cde725dacc Merge pull request #477 from peass-ng/codex/update-docstring-and-fix-typo
Fix docstring and comment in linpeasBuilder
2025-06-25 01:57:58 +02:00
Aarav Juneja 9b37fd4ef4 Fix exclude modules on linPEASS 2025-06-24 13:05:10 -07:00
SirBroccoli 4af321d138 Fix docstring and comment typo 2025-06-06 00:01:29 +02:00
SirBroccoli 4e556fd594 Fix variable reference when parsing URLs 2025-06-06 00:01:17 +02:00
carlospolop 1e7a90d29f cursor rewrite + network checks 2025-05-24 08:29:47 +02:00
carlospolop 9820c18697 Cursor improvements parts 1 and 2 2025-05-19 06:36:35 +02:00
Carlos Polop 2a71da4bb2 another linpeas fix 2024-12-05 17:49:44 +01:00
Carlos Polop 1e1a8a7c86 fix linpeas 2024-12-05 12:00:27 +01:00
Carlos Polop 186e659080 fix builder 2024-12-05 01:24:35 +01:00
Carlos Polop 7a9ea40cbb Less false possitives applied to small names 2024-09-24 11:49:57 +02:00
Carlos Polop 0ed01d58d3 Big linpeas update 2024-08-27 23:56:21 +02:00
Nicolas GRELLETY 509e164d6f 🐛 fix linPEAS build
Update search regex due to API change
2023-07-23 00:49:04 +02:00
carlospolop 4a0b8fb065 improvements 2023-04-13 22:02:50 +02:00
carlospolop 19a2ed5f5a linpeas improvements 2023-04-13 06:00:26 +02:00
carlospolop 8b444ba674 10k update 2022-09-01 20:08:01 +02:00
carlospolop 999fcff035 linpeas update 2022-07-30 12:14:53 +02:00
carlospolop 6d70913b28 regexes 2021-12-19 18:03:02 -05:00
carlospolop dc8fd3a6b1 search regexes 2021-12-19 17:56:21 -05:00
carlospolop d30c6ca63a search regexes 2021-12-19 17:54:29 -05:00
carlospolop c731f6ebe6 fix 2021-12-19 13:17:45 -05:00
carlospolop 6c39d33b7b linpeas fixes 2021-12-19 12:47:50 -05:00
carlospolop 35cfa99ad4 more checks 2021-12-19 10:41:39 -05:00
carlospolop 87fe48a900 more_checks 2021-12-19 08:31:53 -05:00
carlospolop 4d67bbc32d fix 2021-12-18 16:58:56 -05:00
carlospolop b5bb7242c9 separated linpeas 2021-12-18 14:48:01 -05:00
Carlos Polop 1ac6bc1432 imprv 2021-10-21 09:25:40 -04:00
Carlos Polop bb8e09df71 fixes 2021-09-13 06:54:55 -04:00
Carlos Polop c36a2b05d2 improve containers 2021-09-07 19:03:51 -04:00
Carlos.Martin a90bb41704 linpeas 2021-08-27 14:34:04 +01:00
Carlos.Martin 14ebbdb3e2 linpeas 2021-08-08 17:20:45 +01:00
Carlos.Martin 87c433524c linpeas su brute fix 2021-08-03 11:11:31 +01:00
Carlos.Martin a2a9a82b50 linpeas 2021-07-26 14:27:57 +01:00
Carlos Polop ea5d9415b1 linpeas 2021-07-13 11:44:43 +02:00
Carlos Polop 3a367d2112 linpeas-ng 2021-07-11 18:51:48 +02:00
Carlos Polop 4d7cc5d461 linpeas 2021-06-21 00:26:11 +02:00
Carlos Polop 4b40537ea4 finish 2021-06-17 23:13:11 +02:00
Carlos.Martin c8b2634d3c update 2021-06-17 19:29:28 +01:00