Psloglist (Sysinternals) disclaimer is shown in the console

Just starting out? Need help? Post your questions and find answers here.
flux
New User
New User
Posts: 6
Joined: Mon May 09, 2016 11:24 am

Psloglist (Sysinternals) disclaimer is shown in the console

Post by flux »

Hi Forum,
I am currently working on a program wrapping around some windows tools. The only point that is not working as intended is the integration of psloglist output.
The expected behavior is that the output of the command psloglist.exe -n 10 SYSTEM should be written in a file COMPLETELY, but instead, the payload (the logs) are written into the textfile and the disclaimer is displayed in the console like this:

PsLoglist v2.71 - local and remote event log viewer
Copyright (C) 2000-2009 Mark Russinovich
Sysinternals - http://www.sysinternals.com


The code-snippet responsible for running psloglist:

Code: Select all

Psloglist = RunProgram(PSLOGLISTEXE$, ParametersPsloglist_1$, "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
  Output$ + "[+] Getting SYSTEM logs: " + Chr(13) + Chr(13)
  If Psloglist
    While ProgramRunning(Psloglist)
      If AvailableProgramOutput(Psloglist)
        Output$ + ReadProgramString(Psloglist) + Chr(13)
      EndIf
    Wend
    Output$ + Chr(13) + Chr(13)
  EndIf
  CloseProgram(Psloglist)
  LogMessages(Output$)  
  


And the logging procedure:

Code: Select all

LogFileName$ = LogPrefix$ + "_" + FormatDate("%yyyy%mm%dd", Date())
  LogDir$ = BaseDir$ + LogPrefix$ + "_log\"
  
  Log = OpenFile(#PB_Any, LogDir$ + LogFileName$)
  Seperator$ = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + Chr(13) + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"  + Chr(13)
  
  If Log
    FileSeek(Log, Lof(Log))
    WriteStringN(Log, Seperator$)
    WriteStringN(Log, FormatDate("[+] %yyyy.%mm.%dd (%hh:%ii:%ss) ", Date()) + Chr(13) + Message.s)
    CloseFile(Log)
    ProcedureReturn 2
  Else
    CreateDirectory(LogDir$)
    CreateLog = CreateFile(#PB_Any, LogDir$ + LogFileName$)    
    CloseFile(CreateLog)
    ProcedureReturn 1
  EndIf 
  ProcedureReturn 0  

Any idea where this strange behavior is coming from?

Best regards!
flux
infratec
Always Here
Always Here
Posts: 7625
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Psloglist (Sysinternals) disclaimer is shown in the cons

Post by infratec »

Hi,

maybe the disclaimer is written to stderr and not to stdout.
Try to read in ReadProgramError() too.

Bernd
flux
New User
New User
Posts: 6
Joined: Mon May 09, 2016 11:24 am

Re: Psloglist (Sysinternals) disclaimer is shown in the cons

Post by flux »

infratec wrote:Hi,

maybe the disclaimer is written to stderr and not to stdout.
Try to read in ReadProgramError() too.

Bernd

Hey Bernd,
thx for the tip, it solved the problem!
flux
Post Reply