r/PowerShell • u/SirCryAlot13 • Dec 12 '25
Pktmon in PowerShell
Hey,
Created a little PowerShell wrapper module for the pktmonapi.dll (https://learn.microsoft.com/en-us/windows/win32/pktmon/pktmon-reference).
Module can be found on PSGallery: https://www.powershellgallery.com/packages/PSPktmon/0.5.1
Repo: https://github.com/Ekky-PS/PSPktmon
It's not well documented but should be pretty simple to use.
It also attempts to parse the packets but just the Ethernet Frame, IPV4 Frame and UDP/TCP/ICMP protocols. Could be things wrong here as I haven't spent a super long time on it.
Something to keep in mind is that it works with pointers and unhandled memory so if it crashes, sorry!
Created it when a colleague mentioned ICMP ping packets can contain a payload so I wanted to create a remote shell over ping for fun. Would for sure been easier/better to use Npcap. But wanted a native Windows solution.
But leaving it here for anyone that might find it a litte interesting or useful.
12
u/ron3090 Dec 12 '25
Oh, it’s a packet monitor. I thought for a moment that someone had written a TUI Pokemon clone. This is pretty cool too I guess.
4
u/LALLANAAAAAA Dec 12 '25
This looks interesting, thanks OP. Packet capture might be my favorite thing ever and windows native / powershell definitely has its use cases.
3
u/SikhGamer Dec 12 '25
I didn't know this was a thing in Windows!
I've been using https://www.netresec.com/?page=RawCap when needed (thankfully rarely).
1
u/RikiWardOG Dec 12 '25
lol I've never even heard of this tool before. didn't know people used anything other than wireshark and fiddler
1
u/sigil224 Dec 14 '25
There is an inbox executable that wraps this functionality - pktmon.exe, info here: https://learn.microsoft.com/en-us/windows-server/networking/technologies/pktmon/pktmon-syntax
1
u/[deleted] Dec 12 '25
[removed] — view removed comment