Lesser known DOS netstat options
The netstat program is available on every OS I own. Several options are unique to operating systems. A post to a recent thread on the firewall-wizards mailing list reminded me of several options that can be useful in isolating spyware components.
netstat -o displays the process that "owns" a network connection. For example:
c:\netstat -on
Active Connections
Proto Local Address Foreign Address State PID
TCP 127.0.0.1:1025 127.0.0.1:1026 ESTABLISHED 1992
TCP 127.0.0.1:1026 127.0.0.1:1025 ESTABLISHED 1992
TCP 127.0.0.1:1340 127.0.0.1:1341 ESTABLISHED 5000
TCP 127.0.0.1:1341 127.0.0.1:1340 ESTABLISHED 5000
TCP 127.0.0.1:3522 127.0.0.1:43958 ESTABLISHED 4864
TCP 127.0.0.1:4940 127.0.0.1:4941 ESTABLISHED 5136
TCP 127.0.0.1:4941 127.0.0.1:4940 ESTABLISHED 5136
TCP 127.0.0.1:43958 127.0.0.1:3522 ESTABLISHED 3708
TCP 172.17.1.50:3501 66.93.106.226:7446 ESTABLISHED 3372
TCP 172.17.1.50:4061 172.17.0.7:3389 ESTABLISHED 2732
TCP 172.17.1.50:4224 4.79.142.202:80 ESTABLISHED 232
The first column identifies the protocol: TCP, UDP, ...
The next columns identify the host names and ports of the connection endpoints. Microsoft chooses to label these Local Address and Foreign Address, respectlvey. The next column displays the (TCP) connection state (LISTEN, ESTABLISHED, etc., see MSKB 137984 for complete details). The final column, PID, is the process identifier for the executable. Process are the programs executing in your PC's RAM and consuming CPU. All applications and Windows services and many forms of spyware run as processes. Spyware programs are basically processes you didn't choose to install.
netstat -b goes a step further than -o and identifies the executable program (and program components) that created a connection; for example,
Active Connections
Proto Local Address Foreign Address State PID
TCP spike:1025 localhost:1026 ESTABLISHED 1992
[controld.exe]
TCP spike:1026 localhost:1025 ESTABLISHED 1992
[controld.exe]
TCP spike:1340 localhost:1341 ESTABLISHED 5000
[thunderbird.exe]
TCP spike:1341 localhost:1340 ESTABLISHED 5000
[thunderbird.exe]
TCP spike:3522 localhost:43958 ESTABLISHED 4864
[ServUAdmin.exe]
TCP spike:4940 localhost:4941 ESTABLISHED 5136
[firefox.exe]
TCP spike:4941 localhost:4940 ESTABLISHED 5136
[firefox.exe]
TCP spike:43958 localhost:3522 ESTABLISHED 3708
[ServUDaemon.exe]
TCP spike:3501 dsl093-106-226.wdc2.dsl.speakeasy.net:7446 ESTABLISHED 3372
[Shinkuro.exe]
TCP spike:4061 hhi.corecom.com:3389 ESTABLISHED 2732
[mstsc.exe]
TCP spike:4170 bf-in-f99.google.com:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4196 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4198 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4199 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4200 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4201 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4207 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4208 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4226 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4227 209.221.47.167:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4228 209.221.47.168:http ESTABLISHED 5136
[firefox.exe]
TCP spike:4232 c17-b2b-itp-tags-lb.cnet.com:http ESTABLISHED 232
[GoogleDesktopIndex.exe]
TCP spike:10110 localhost:4241 TIME_WAIT 0
TCP spike:4234 c17-b2b-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4235 c18-btg-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4236 c18-news-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4237 c18-btg-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4238 c18-dw-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4240 c18-dw-xw-lb.cnet.com:http TIME_WAIT 0
TCP spike:4242 mail.hargray.com:pop3 TIME_WAIT 0
Note that in this example, I did not use the -n option, so netstat attempted to resolve the domain names for local and foreign addresses. All the information available via the -o option is present, but an additional output line identifies the name of the executable or executable component. Many of the processes in my example output are familiar applications. How do you distinguish a useful process from spyware? As I mention in my article, Identifying Spyware Processes on a Windows PC, many web sites provide lists and descriptions of legitimate and undesirable Windows processes.
I should have mentioned these uses of netstat in my article. They are not as information rich as some of the process hunting software I mention in my article, but they "come with" MS-DOS and should be available on any machine you may be asked to inspect.
Archived at http://www.securityskeptic.com/arc20070401.htm#BlogID604
by Dave Piscitello