Dumping Network Traffic Sent/Received via Winsock In Time Travel Debugging Trace

Here are some commands can be used to dump the bytes being sent/received via Winsock send & recv APIs when viewing a time travel debugging trace. A similar approach can be expanded upon to capture more of the winsock APIs such as creation of the socket, etc. You can remove the !position cmd and use it for live WinDbg’ing instead if desired, although if there is a lot of calls to send/recv it will significantly slow application.

Note on receiving this dumps the entire buffer which may be larger than actual bytes received.

For 32-bit application

bp ws2_32!recv "!position;r $t0=poi(@esp+8);r $t1=poi(@esp+0Ch);bp /1 @$ra \".echo *** RECEIVE ***;db @$t0 L@$t1;g\";g"
bp ws2_32!send "!position;.echo *** SEND ***;db poi(@ep+8) L(poi(@esp+0Ch));g"



For 64-bit application

bp ws2_32!recv "!position;r $t0=@rdx;r $t1=@r8;bp /1 @$ra \".echo *** RECEIVE ***;db @$t0 L@$t1;g\";g"
bp ws2_32!send "!position;.echo *** SEND ***;db @rdx L(@r8);g"

If instead you just want to dump any ASCII (-sa) / Unicode (-su) strings that are being hit you can try

For 32-bit applications

bp ws2_32!recv "!position;r $t0=poi(@esp+8);r $t1=poi(@esp+0Ch);bp /1 @$ra \".echo *** RECEIVE ***;s -sa @$t0 L@$t1;s -su @$t0 L@$t1;g\";g"
bp ws2_32!send "!position;.echo *** SEND ***;s -sa poi(@esp+8) L(poi(@esp+0Ch));s -su poi(@esp+8) L(poi(@esp+0Ch));g"

For 64-bit applications

bp ws2_32!recv "!position;r $t0=@rdx;r $t1=@r8;bp /1 @$ra \".echo *** RECEIVE ***;s -sa @$t0 L@$t1;s -su @$t0 L@$t1;g\";g"
bp ws2_32!send "!position;.echo *** SEND ***;s -sa @rdx L(@r8);s -su @rdx L(@r8);g"

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment