{"id":908,"date":"2021-03-31T19:13:37","date_gmt":"2021-03-31T19:13:37","guid":{"rendered":"https:\/\/feralpacket.org\/?p=908"},"modified":"2021-04-28T14:59:01","modified_gmt":"2021-04-28T14:59:01","slug":"windows-cli-network-troubleshooting","status":"publish","type":"post","link":"https:\/\/feralpacket.org\/?p=908","title":{"rendered":"Windows CLI Network Troubleshooting"},"content":{"rendered":"\n<p>Just the commands. Some are CMD commands. Some are PowerShell commands.<\/p>\n\n\n\n<p>! computer name<br>hostname<br>echo %computername%<br>[System.NET.DNS]::GetHostByName(\u2018\u2018)<br>&nbsp;&nbsp;&nbsp;&nbsp;!  &#8211; two single quotes<br>$env:COMPUTERNAME<br>get-ciminstance -classname Win32_ComputerSystem<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; computer model number<\/p>\n\n\n\n<p>! date \/ time<br>date \/t<br>echo %date%<br>time \/t<br>echo %time%<br>get-date<br>date<br>&nbsp;&nbsp;&nbsp;&nbsp;! \n &#8211; this works in powershell<\/p>\n\n\n\n<p>! MAC addresses<br>getmac \/v<br>ipconfig \/all<br>get-netadapter<br>wmic nic where physicaladapter=true get name,macaddress<br>get-ciminstance win32_networkadapterconfiguration | select description, macaddress<\/p>\n\n\n\n<p>! interfaces and IP addresses<br>netsh interface show interface<br>get-netadapter<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; link speed<br>get-netadapter | ft Name, Status, LinkSpeed, VlanID<br>get-netadapteradvancedproperty<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; VLAN ID, wake on magic packet<br>netsh interface ipv4 show addresses<br>ipconfig<br>get-netipconfiguration<br>(Get-WmiObject Win32_NetworkAdapterConfiguration | where { (($_.IPEnabled -ne $null) -and ($_.DefaultIPGateway -ne $null)) } | select IPAddress -First 1).IPAddress[0]<br>get-ciminstance win32_networkadapterconfiguration | select description, ipaddress<br>[System.NET.DNS]::GetHostAddresses(\u2018\u2018)<br>&nbsp;&nbsp;&nbsp;&nbsp;!  &#8211; two single quotes<\/p>\n\n\n\n<p>! routing table<br>netsh interface ipv4 show route<br>netstat -r<br>route PRINT<br>get-netroute<\/p>\n\n\n\n<p>! ARP table<br>arp -a<br>get-netneighbor<br>get-netneighbor -addressfamily ipv4<\/p>\n\n\n\n<p>! DHCP<br>netsh dhcp show server<br>ipconfig \/release<br>ipconfig \/renew<br>ipconfig \/registerdns<br>get-ciminstance win32_networkadapterconfiguration | select description, dhcpleaseobtained, dhcpserver<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; DHCP server<\/p>\n\n\n\n<p>! DNS<br>netsh interface ipv4 show dnsservers<br>ipconfig \/all<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; lists DNS servers<br>get-dnsclientserveraddress<br>ipconfig \/registerdns<br>ipconfig \/displaydns<br>nslookup cnn.com<br>resolve-dnsname -name cnn.com<br>get-dnsclientcache<br>nslookup cnn.com<br>resolve-dnsname -name cnn.com<br>get-ciminstance win32_networkadapterconfiguration | select description, dnsserversearchorder<\/p>\n\n\n\n<p>! MTU<br>netsh interface ipv4 show subinterfaces<br>netsh interface ipv4 show interfaces level=verbose<br>get-netipinterface<br>ping -f -l 1400 192.0.2.1<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; adjust as necessary<\/p>\n\n\n\n<p>! path MTU<br>netsh interface ipv4 show destinationcache<\/p>\n\n\n\n<p>! discards, header errors, fragments, mtu<br>netsh interface ipv4 show subinterfaces level=verbose<br>get-ciminstance Win32_PerfRawData_Tcpip_NetworkInterface<\/p>\n\n\n\n<p>! windows firewall<br>netsh advfirewall show currentprofile<br>get-netfirewallprofile<br>get-netfirewallprofile -name public | get-netfirewallrule<br>get-netfirewallportfilter<br>get-netfirewalladdressfilter<\/p>\n\n\n\n<p>! connections and listening ports<br>netsh interface ipv4 show tcpconnections<br>netstat -a<br>netstat -an<br>get-nettcpconnection<br>netstat -ab | findstr &#8220;LISTENING&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; lists the executable that is responsible for the listening port<br>netstat -ano<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; lists the owning process ID<br>netstat -ano | find `&#8221;LISTENING`&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; ` escapes the &#8220;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; needed with powershell<br>netstat -ano | find &#8220;&#8221;&#8221;LISTENING&#8221;&#8221;&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; works with powershell<br>netstat -ano | find &#8220;LISTENING&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; works with cmd.exe<br>tasklist | find &#8220;8076&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; use the PID from the above netstat command<br>tasklist \/FI &#8220;PID eq 8076&#8221;<br>tasklist \/APPS \/FI &#8220;PID eq 8076&#8221;<br>tasklist \/SVC \/FI &#8220;PID eq 8076&#8221;<br>tasklist \/FI &#8220;STATUS eq RUNNING&#8221;<br>tasklist \/FI &#8220;STATUS eq NOT RESPONDING&#8221;<\/p>\n\n\n\n<p>! tcp \/ udp \/ ip \/ icmp statistics<br>netsh interface ipv4 show tcpstats<br>netsh interface ipv4 show udpstats<br>netsh interface ipv4 show ipstats<br>netsh interface ipv4 show icmpstats<br>netsh interface ipv4 show icmpstats | findstr \/v &#8221; 0$&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; do not display entries with a zero count<\/p>\n\n\n\n<p>! wireless<br>netsh wlan show wlanreport<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; save report as an .html file<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; error message0x2 if you have both LAN &amp; WLAN connected<br>netsh wlan show networks<br>netsh wlan show all<\/p>\n\n\n\n<p>! ECN capability<br>netsh interface tcp show global<br>get-nettcpsetting<\/p>\n\n\n\n<p>! IPSec<br>netsh ipsec dynamic show all<\/p>\n\n\n\n<p>! test reachability<br>nslookup cnn.com<br>ping 192.0.2.1<br>ping 192.0.2.1 -t<br>test-netconnection 192.0.2.1<br>1..10 | % { test-netconnection 192.0.2.$_ } | ft -AutoSize<br>&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; ping sweep<br>telnet 192.0.2.1 80<br>test-netconnection 192.0.2.1 -port 80<br>tracert 192.0.2.1<br>tracert -d 192.0.2.1<br>test-netconnection 192.0.2.1 -traceroute<br>pathping 192.0.2.1<\/p>\n\n\n\n<p>! nmap<br>&nbsp;&nbsp;&nbsp;&nbsp;! -sT &#8211; TCP connect scan<br>&nbsp;&nbsp;&nbsp;&nbsp;! -sV &#8211; version scan, try to identify the what is running on any open ports<br>&nbsp;&nbsp;&nbsp;&nbsp;! -F &#8211; fast mode<br>nmap -sT -sV -F 192.0.2.1<br>&nbsp;&nbsp;&nbsp;&nbsp;! aggressive scan, throw everything at it, including the kitchen sink<br>&nbsp;&nbsp;&nbsp;&nbsp;! -T4 enables aggressive timing to speed up the scan, otherwise it will take forever to run<br>nmap -A -T4 192.0.2.1<br>&nbsp;&nbsp;&nbsp;&nbsp;! scan a subnet, but only send ICMP echo requests<br>&nbsp;&nbsp;&nbsp;&nbsp;! exclude the network address, the broadcast address, and the local honeypot the &#8220;infosec&#8221; team is proud of<br>&nbsp;&nbsp;&nbsp;&nbsp;! -n to disable DNS lookups<br>&nbsp;&nbsp;&nbsp;&nbsp;! -sn to disable port scan<br>&nbsp;&nbsp;&nbsp;&nbsp;! -PE to specify ICMP echo request packets<br>nmap -n -sn -PE 192.0.2.0\/24 &#8211;exclude 192.0.2.0,192.0.2.69,192.0.2.255<br>&nbsp;&nbsp;&nbsp;&nbsp;! run a script to determine what SSL ciphers are available<br>&nbsp;&nbsp;&nbsp;&nbsp;! https:\/\/nmap.org\/nsedoc\/scripts\/ssl-enum-ciphers.html<br>nmap -sV &#8211;script .\\ssl-enum-ciphers -p 443 192.0.2.1<br>&nbsp;&nbsp;&nbsp;&nbsp;! display the packets being sent and received<br>&nbsp;&nbsp;&nbsp;&nbsp;! -n disables DNS lookup<br>&nbsp;&nbsp;&nbsp;&nbsp;! -sT runs a TCP connect scan<br>&nbsp;&nbsp;&nbsp;&nbsp;! -F enables fast mode, only scan 100 ports<br>&nbsp;&nbsp;&nbsp;&nbsp;! -Pn disables host discovery, with the TCP connect scan no ICMP packets will be sent<br>nmap -n -sT -F -Pn &#8211;packet-trace 192.0.2.1<\/p>\n\n\n\n<p>! run CMD command in powershell<br>invoke-command -scriptblock {ipconfig \/all}<\/p>\n\n\n\n<p>! username<br>echo %username%<br>whoami<\/p>\n\n\n\n<p>! active directory<br>get-addomain<br>get-addomaincontroller<br>get-aduser -identity feralpacket<br>get-aduser -identity feralpacket -properties *<br>\u00a0\u00a0\u00a0\u00a0! &#8211; LockedOut, PasswordExpired, PasswordLastSet<br>get-aduser -identity feralpacket -properties * | format-list LockedOut<br>get-adprincipalgroupmembership feralpacket | select name<br>get-adcomputer -identity heimdallr<br>\u00a0\u00a0\u00a0\u00a0! &#8211; Enabled<br>get-adcomputer -identity heimdallr -properties *<br>echo %logonserver%<br>$env:LOGONSERVER<br>\u00a0\u00a0\u00a0\u00a0! &#8211; LOGONSERVER<br>get-adcomputer heimdallr -properties memberof |<br>\u00a0\u00a0\u00a0\u00a0foreach-object{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$_.memberof | %{get-adobject $_ }<br>\u00a0\u00a0\u00a0\u00a0 } |<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0select name<br>get-aduser feralpacket -properties memberof |<br>\u00a0\u00a0\u00a0\u00a0foreach-object{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$_.memberof | %{get-adobject $_ }<br>\u00a0\u00a0\u00a0\u00a0 } |<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0select name<\/p>\n\n\n\n<p>! logged in users<br>(Get-WmiObject -Class win32_computersystem | Select-Object -ExpandProperty username).split(&#8216;\\&#8217;)[1]<br>(Get-WmiObject -Class win32_computersystem | Select-Object -ExpandProperty username)<br>quser<br>query user<br>query session<br>qwinsta<br>query process<br>qprocess<\/p>\n\n\n\n<p>! group policy<br>gpresult \/r<\/p>\n\n\n\n<p>! environment variables<br>set<br>get-item env:*<br>ls env:<\/p>\n\n\n\n<p>! path<br>echo %PATH%<br>echo $env:path<br>$env:path-split&#8217;;&#8217;<\/p>\n\n\n\n<p>! everything and the kitchen sink<br>wmic nic where physicaladapter=true list full<br>get-ciminstance win32_networkadapter -property *<br>get-ciminstance win32_networkadapterconfiguration -property *<br>get-ciminstance Win32_OperatingSystem -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_ICMP -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_ICMPv6 -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_IPv4 -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_IPv6 -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_UDPv4 -property *<br>get-ciminstance Win32_PerfRawData_Tcpip_UDPv6 -property *<br>get-ciminstance Win32_PerfRawData_TCPIPCounters_TCPIPPerformanceDiagnostics -property *<\/p>\n\n\n\n<p>! windows 10 builtin packet capture tool<br>&nbsp;&nbsp;&nbsp;&nbsp;! run CMD as Administrator<br>c:\\WINDOWS\\system32&gt; pktmon.exe<\/p>\n\n\n\n<p>! configure filters<br>pktmon filter add -p 20<br>pktmon filter add -p 21<br>pktmon filter add -i 192.0.2.1<br>pktmon filter add -t ICMP<br>pktmon filter add -d IPv4<br>pktmon filter list<\/p>\n\n\n\n<p>! list the NICs<br>pktmon comp list<\/p>\n\n\n\n<p>! start and stop the capture<br>pktmon start -etw -p 0 -c 12<br>pktmon stop<\/p>\n\n\n\n<p>! delete any filters<br>pktmon filter remove<\/p>\n\n\n\n<p>! output to ASCII or .pcap<br>! default output file is PktMon.etl<br>pktmon format PktMon.etl -o ftp.txt<br>pktmon pcapng log.etl -o log.pcapng<\/p>\n\n\n\n<p>! capture in real-time<br>pktmon start -etw -p 0 -l real-time<\/p>\n\n\n\n<p>! sshd<br>get-windowscapability -online | ? name -like &#8220;openssh*&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; install if necessary<br>get-service &#8220;sshd&#8221;<br>get-service sshd | select -property name,status,starttype<br>start-service sshd -whatIf<br>set-service -name sshd -startuptype &#8216;Automatic&#8217;<br>set-service sshd -startuptype &#8220;Manual&#8221;<br>start-service sshd<br>start-service sshd -Confirm<br>get-netfirewallrule -name *ssh*<br>get-service | ? status -like &#8220;Stopped&#8221;<br>get-service | ? status -like &#8220;Running&#8221;<br>get-service | ? status -notlike &#8220;Running&#8221;<br>get-service<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; status<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; name<br>&nbsp;&nbsp;&nbsp;&nbsp;!&nbsp; &#8211; displayname<br>get-service sshd | select -property name,status,starttype<br>get-service sshd | select-object *<br>get-service | select -property name,status,starttype | ? starttype -like &#8220;Manual&#8221;<br>get-service | select -property name,status,starttype | ? starttype -like &#8220;Disabled&#8221;<br>get-service &#8220;s*&#8221; | sort-object status<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just the commands. Some are CMD commands. Some are PowerShell commands. ! computer namehostnameecho %computername%[System.NET.DNS]::GetHostByName(\u2018\u2018)&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; two single quotes$env:COMPUTERNAMEget-ciminstance -classname Win32_ComputerSystem&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; computer model number ! date \/ timedate \/techo %date%time \/techo %time%get-datedate&nbsp;&nbsp;&nbsp;&nbsp;! &#8211; this works in powershell ! MAC addressesgetmac \/vipconfig \/allget-netadapterwmic nic where physicaladapter=true get name,macaddressget-ciminstance win32_networkadapterconfiguration | select description, macaddress ! interfaces [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-908","post","type-post","status-publish","format-standard","hentry","category-ccie"],"_links":{"self":[{"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/posts\/908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feralpacket.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=908"}],"version-history":[{"count":32,"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/feralpacket.org\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions\/952"}],"wp:attachment":[{"href":"https:\/\/feralpacket.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feralpacket.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feralpacket.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}