Commit Graph

5 Commits

Author SHA1 Message Date
chack-agent
ece82f945d Fix CI-master failures for run #22804086303 2026-03-07 18:22:19 +00:00
Giveen
c9055a7688 winPEAS: Fix network scanning (arg parsing, race condition, port scanner, auto-mode crash) (#612)
* Fix thread count override and add -z flag to set thread count

* Enforce THREADS >= 1 after detection; validate -z range; clarify help text

* Strip colours from -z warning; add regression tests for -z getopts/help

* Tighten getopts regression test: match 'while getopts' line with regex

* Fix WinPEAS network host discovery and port scanner bugs

- Fix auto-mode NullReferenceException: change plain 'if' to 'else if'
  for IPAddressNetmask/IPAddressList branches in NetworkScanner.Scan(),
  so the auto path no longer falls through and calls AddRange(null)
- Fix HostsAlive race condition in NetPinger: replace List<string> with
  ConcurrentBag<string> so concurrent async ping callbacks don't corrupt
  the collection
- Fix unbound parallelism: cap outer host loop at MaxDegreeOfParallelism=5
  and inner port loop at 50; create a PortScanner per host to remove
  shared-state concerns
- Fix port scan output bypassing Beaprint: replace raw Console.WriteLine
  with Beaprint.GoodPrint so open-port results are colour-highlighted and
  respect -nocolor
- Move network scan into NetworkInfo.PrintInfo(): add PrintNetworkScan()
  method, wire it into the check list when IsNetworkScan is true, remove
  the detached scan block from RunChecks(), expose NetworkScanOptions and
  PortScannerPorts as public, and remove the now-unused using directive

* Add compiled binaries (x86/x64/Release), Directory.Build.targets Linux shim, fix Vault enum/struct casing

* Fix -network/-ports arg parsing to accept space-separated values

* Remove Directory.Build.targets from tracking; add to .gitignore

* Dispose Ping per-attempt in NetPinger to prevent handle leaks on large sweeps

* Fix TcpClient/WaitHandle leaks in PortScanner: use using block, close wait handle, remove stale AsyncCallback+TcpPortState

* Force-select networkinfo check when -network is set with a subset of checks

* Remove unused System.Threading.Tasks import from PortScanner

* Add tests for space-separated -network/-ports arg normalisation

* Remove Thread.Sleep(1) and unused System.Threading import from PortScanner

* Replace BeginConnect/WaitOne APM with ConnectAsync+Wait(timeout) in PortScanner

* Cap concurrent pings at 50 with SemaphoreSlim in NetPinger to prevent resource exhaustion on large ranges

* Isolate per-IP ping exceptions so a single bad target can't abort the sweep; surface errors in debug mode

* Observe timed-out ConnectAsync task via ContinueWith to prevent UnobservedTaskException

* Broaden ParseOnly reset to cover all arg-parsing-mutable Checks fields to prevent test cross-talk

* Add MainPrint/LinkPrint header to PrintNetworkScan; remove misplaced GreatPrint from NetworkScanner.Scan()

* Add dedicated 'networkscan' system check to avoid running all NetworkInfo sub-checks when -network is passed with a subset

* Delete linpeas_test.sh

* Delete winPEAS/winPEASexe/binaries/Release/winPEAS.exe

* Delete winPEAS/winPEASexe/binaries/x64/Release/winPEAS.exe

* Delete winPEAS/winPEASexe/binaries/x86/Release/winPEAS.exe

---------

Co-authored-by: SirBroccoli <carlospolop@gmail.com>
2026-03-07 14:12:16 +01:00
Carlos Polop
f8f4250b81 Add stronger winPEAS/linPEAS tests 2026-01-21 15:14:08 +01:00
Carlos Polop
b591f3d524 Fix winPEAS argument parsing tests 2026-01-21 10:57:32 +01:00
Carlos Polop
83580fcd8a Re-enable winPEAS tests and add linPEAS builder checks 2026-01-21 01:15:38 +01:00