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
A while ago I started porting this project to python asyncio. The result can be found here I've found a bug in my port that is also present in this project.
In this part of the code you can see that a new Defragmenter is constructed for every WSMV message link to file:
The reason that this project probably hasn't caught the issue is because PSRP messages usually contain a start and an end fragment when retrieving lists of Powershell objects. In my project I convert my results into json and then only because I request a large chunk of data the fragments span over multiple WSMV messages. Usually you get lots of Objects with a few Fragments. However if you convert to json you can produce one Object which spans multiple fragments.
Let me make it more concrete. This is my code that does part of the defragmenting:
As you can see I log the object_id, fragment_id and whether or not it's an end and/or start fragment.
For example if you start the following request: Get-WmiObject Win32_Product every WSMV message contains a start and end fragment.
WSMV message
Stream
Fragment O:1 F:0 S:True: E:True
Fragment O:2 F:0 S:True: E:True
WSMV message
Stream
Fragment O:3 F:0 S:True: E:True
WSMV message
Stream
Fragment O:4 F:0 S:True: E:True
Fragment O:5 F:0 S:True: E:True
Fragment O:6 F:0 S:True: E:True
Fragment O:7 F:0 S:True: E:True
Fragment O:8 F:0 S:True: E:True
-- part left out for readability
Fragment O:1243 F:0 S:True: E:True
Fragment O:1244 F:0 S:True: E:True
But if you do this: Get-WmiObject Win32_Product | ConvertTo-Json -Compress you get one big result object containing multiple fragments:
WSMV message
Stream
Fragment O:1 F:0 S:True: E:True
Fragment O:2 F:0 S:True: E:True
WSMV message
Stream
Fragment O:3 F:0 S:True: E:True
WSMV message
Stream
Fragment O:4 F:0 S:True: E:False
Fragment O:4 F:1 S:False: E:False
Fragment O:4 F:2 S:False: E:False
Fragment O:4 F:3 S:False: E:False
WSMV message
Stream
Fragment O:4 F:4 S:False: E:False
-- at this point aiowinrm crashes because it initialises the bytes buffer when it sees a start fragment
Because this library also initialises a defragmenter for every WSMV message it essentially misses output data:
Hi
A while ago I started porting this project to python asyncio. The result can be found here I've found a bug in my port that is also present in this project.
In this part of the code you can see that a new
Defragmenter
is constructed for every WSMV message link to file:The reason that this project probably hasn't caught the issue is because PSRP messages usually contain a start and an end fragment when retrieving lists of Powershell objects. In my project I convert my results into json and then only because I request a large chunk of data the fragments span over multiple WSMV messages. Usually you get lots of Objects with a few Fragments. However if you convert to json you can produce one Object which spans multiple fragments.
Let me make it more concrete. This is my code that does part of the defragmenting:
As you can see I log the object_id, fragment_id and whether or not it's an end and/or start fragment.
For example if you start the following request:
Get-WmiObject Win32_Product
every WSMV message contains a start and end fragment.But if you do this:
Get-WmiObject Win32_Product | ConvertTo-Json -Compress
you get one big result object containing multiple fragments:Because this library also initialises a defragmenter for every WSMV message it essentially misses output data:
As you can see the fragment data is only decoded at the end. But if the end is not within the current WSMV message it's never decoded
The text was updated successfully, but these errors were encountered: