using System.Collections.Generic;
public static void Main()
Proto Local Address Foreign Address State
TCP 10.144.216.90:22 10.137.118.123:57231 ESTABLISHED
TCP 10.144.216.90:22 10.137.118.123:57330 ESTABLISHED
TCP 10.144.216.90:445 10.137.118.123:57301 ESTABLISHED
Can not obtain ownership information
TCP 10.144.216.90:3389 10.137.118.123:61798 ESTABLISHED
TCP 10.144.216.90:7680 10.144.216.114:51894 TIME_WAIT
TCP 10.144.216.90:51120 168.63.129.16:32526 ESTABLISHED
[WindowsAzureGuestAgent.exe]
TCP 10.144.216.90:51131 168.63.129.16:http ESTABLISHED
[WindowsAzureGuestAgent.exe]
TCP 10.144.216.90:51195 168.63.129.16:32526 ESTABLISHED
TCP 10.144.216.90:51222 20.60.61.4:https ESTABLISHED
[WindowsAzureGuestAgent.exe]
TCP 10.144.216.90:54086 20.7.2.167:https ESTABLISHED
TCP 10.144.216.90:54372 TDC1126681084:ms-do ESTABLISHED
Can not obtain ownership information
TCP 10.144.216.90:54503 20.7.2.167:https ESTABLISHED
TCP 10.144.216.90:54644 CO1-RED-DC-78:epmap ESTABLISHED
TCP 10.144.216.90:54645 CO1-RED-DC-78:49668 ESTABLISHED
TCP 10.144.216.90:54707 40.71.12.237:https CLOSE_WAIT
TCP 10.144.216.90:54763 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54764 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54765 CO1-RED-DC-60:epmap TIME_WAIT
TCP 10.144.216.90:54766 CO1-RED-DC-60:49668 ESTABLISHED
TCP 10.144.216.90:54770 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54772 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54773 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54779 CO1-RED-DC-78:epmap ESTABLISHED
TCP 10.144.216.90:54780 CO1-RED-DC-78:49668 ESTABLISHED
TCP 10.144.216.90:54781 40.71.12.233:https TIME_WAIT
TCP 10.144.216.90:54784 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54785 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54786 13.87.187.111:https ESTABLISHED
Can not obtain ownership information
TCP 10.144.216.90:54787 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54788 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:54789 20.42.65.84:https TIME_WAIT
TCP 10.144.216.90:54790 20.62.132.7:https TIME_WAIT
TCP 10.144.216.90:63314 13.107.21.200:https CLOSE_WAIT
TCP 10.144.216.90:63322 52.96.15.2:https CLOSE_WAIT
TCP 10.144.216.90:63328 bingforbusiness:https CLOSE_WAIT
TCP 10.144.216.90:63329 40.67.154.119:https CLOSE_WAIT
TCP 10.144.216.90:63330 72.21.91.29:http ESTABLISHED
TCP 10.144.216.90:63331 52.96.15.2:https CLOSE_WAIT
TCP 127.0.0.1:51210 TDC2368423466:51211 ESTABLISHED
TCP 127.0.0.1:51211 TDC2368423466:51210 ESTABLISHED
TCP 127.0.0.1:51213 TDC2368423466:51214 ESTABLISHED
TCP 127.0.0.1:51214 TDC2368423466:51213 ESTABLISHED
TCP 127.0.0.1:54674 TDC2368423466:54676 ESTABLISHED
TCP 127.0.0.1:54674 TDC2368423466:54677 ESTABLISHED
TCP 127.0.0.1:54676 TDC2368423466:54674 ESTABLISHED
TCP 127.0.0.1:54677 TDC2368423466:54674 ESTABLISHED
List<string> sshLinesZ = Message.Split('\n').ToList();
IEnumerable<string> sshLinesZ1 = sshLinesZ.Where(i => sshLinesZ[sshLinesZ.IndexOf(i) + 1].Contains("sshd.exe") && i.Contains("ESTABLISHED"));
foreach (string s in sshLinesZ1) {
Console.WriteLine("===========================================================================");
Console.WriteLine(s.Trim());
Console.WriteLine("---------------------------------------------------------------------------");
var words = s.Split(' ').Select(w => w).Where(ww => !string.IsNullOrEmpty(ww)).ToList();
Console.WriteLine(string.Format("{0,-20} {1,-20}","Connection", "[sshd.exe]"));
Console.WriteLine(string.Format("{0,-20} {1,-20}","Protocol", words[0]));
Console.WriteLine(string.Format("{0,-20} {1,-20}","Local Address: ", words[1].Split(':')[0]));
Console.WriteLine(string.Format("{0,-20} {1,-20}","SSH port: ", words[1].Split(':')[1]));
Console.WriteLine(string.Format("{0,-20} {1,-20}","Foreign Address: ", words[2]));
Console.WriteLine(string.Format("{0,-20} {1,-20}","Status: ", words[3]));