You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PowerShell 5.1 UTF-16LE output not recognized by rdump as a valid input for RecordStreamReader #138
Whilst I understand most of us don't use PowerShell when executing (advanced) Dissect commands in correspondence with rdump, it is currently not (by default) possible to use any records originating from a PowerShell 5.1 process (stdin or as a file) as an input for rdump.
Unfortunately, PowerShell (version 5.1, by default installed on all Windows machines) outputs data in UTF-16LE. This is not visible in the command prompt but provides issues when piping records to rdump or using records you just stored as a file. The UTF-16LE data as an input is not recognized and dealt with accordingly by the RecordStreamReader class.
Just a side note and if your experiencing the same issue, cmd.exe and PowerShell version 6 and 7 by default do output data in UTF-8 and therefore do not experience this issue.
I've tested this a bit on Windows 10 (PowerShell 5.1), and it looks that the output is UTF-16-LE, but still mangled for some bytes. So decoding it using UTF-16-LE will not get back the original raw bytes.
Examples dumped using the examples/records.json.
I'm using -w - to force writing a RecordStream and > to simulate the pipe:
# Using windows cmd.exe:
C:\Users\user>rdump records.json -w - > cmd-redirect.records
# Using powershell 5.1:
PS C:\Users\user> rdump records.json -w - > ps-redirect.records
Activity
yunzheng commentedon Sep 24, 2024
I've tested this a bit on Windows 10 (PowerShell 5.1), and it looks that the output is UTF-16-LE, but still mangled for some bytes. So decoding it using UTF-16-LE will not get back the original raw bytes.
Examples dumped using the
examples/records.json.I'm using
-w -to force writing a RecordStream and>to simulate the pipe:HexDumps:
The
ps-redirect.recordshas a BOM marker, but even stripping that and decoding the data usingutf-16-lewill not get back the original raw header:You can see there are some
\radded in by PowerShell and the0xc4is just weirdly encoded. I don't see a way to get back the original raw bytes.We can add some basic detection and raise a warning.