From d587c058331c899aa1c959086662cedf8c85df59 Mon Sep 17 00:00:00 2001 From: Emmanouil Perselis Date: Thu, 21 Jan 2021 17:43:24 +0100 Subject: [PATCH] Update Program.cs I have added the option to write the output to a file when the parameter "log" is inserted. This is because I was not able to see the output when I was loading the exe with reflective PE injection in Powershell. --- winPEAS/winPEASexe/winPEAS/Program.cs | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/winPEAS/winPEASexe/winPEAS/Program.cs b/winPEAS/winPEASexe/winPEAS/Program.cs index fce782a..38ff1e3 100755 --- a/winPEAS/winPEASexe/winPEAS/Program.cs +++ b/winPEAS/winPEASexe/winPEAS/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Management; @@ -2278,6 +2278,21 @@ namespace winPEAS bool check_bi = false; bool check_if = false; bool wait = false; + FileStream ostrm; + StreamWriter writer; + TextWriter oldOut = Console.Out; + try + { + ostrm = new FileStream("./out.txt", FileMode.OpenOrCreate, FileAccess.Write); + writer = new StreamWriter(ostrm); + } + catch (Exception e) + { + Console.WriteLine("Cannot open out.txt for writing"); + Console.WriteLine(e.Message); + return; + } + foreach (string arg in args) { if (string.Equals(arg, "cmd", StringComparison.CurrentCultureIgnoreCase)) @@ -2289,6 +2304,12 @@ namespace winPEAS if (string.Equals(arg, "quiet", StringComparison.CurrentCultureIgnoreCase)) banner = false; + if (string.Equals(arg, "log", StringComparison.CurrentCultureIgnoreCase)) + Console.SetOut(writer); + + + + if (string.Equals(arg, "searchslow", StringComparison.CurrentCultureIgnoreCase)) search_fast = false; @@ -2435,8 +2456,10 @@ namespace winPEAS if (check_if || check_all) PrintInterestingFiles(); - + Console.SetOut(oldOut); + writer.Close(); + ostrm.Close(); /* * Keylogger? * Input prompt ==> Better in PS @@ -2447,5 +2470,3 @@ namespace winPEAS } } } - -