当前位置:网站首页>WMI and PowerShell get TCP connection list
WMI and PowerShell get TCP connection list
2022-06-24 21:36:00 【allway2】
The network port number provides critical information about applications that access the computer over the network . Understand the applications that use the network and the corresponding network ports , You can create precise rules for firewalls and configure remote hosts to allow only useful traffic . Besides , Activity on endpoint TCP/IP The port may indicate potential malicious activity or network attack . Get all activities TCP A list of connections in each of your networks TCP On endpoint , This is an important first step in understanding the attack surface and locking your network from future security incidents and ransomware . The information should include source and target IP Address and port 、 Process information and other data . This manual describes how to Windows Create activities on the operating system TCP Some ways to simplify the connection list . Besides , You will learn how to use PowerShell obtain TCP Connect .
Manual :
1. stay ROOT\StandardCIMV2 Namespace WMI Inquire about :
start-up WMI Explorer Or anything else that can run WMI Query tools .
function WMI Inquire about : SELECT * FROM MSFT_NetTCPConnection
2. Run this simple Windows Powershell Script :
adopt WMI object :Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer RemoteComputerName
3. Use the following code to select a specific column :
perform :Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer RemoteComputerName | Select object RemoteAddress、RemotePort、OwningProcess、PSComputerName
4. Use the following lines to sort the results :
Call the command :Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer RemoteComputerName | Select object RemoteAddress、RemotePort、OwningProcess、PSComputerName | Sort object remote address
5. The next code helps filter the results :
Use it : Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer RemoteComputerName | Select object RemoteAddress、RemotePort、OwningProcess、PSComputerName | Where-Object -FilterScript {$_.RemoteAddress -like “192.168.*”}
6. Save the results to CSV file :
function : Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer RemoteComputerName | Select object RemoteAddress、RemotePort、OwningProcess、PSComputerName | export -CSV “c:\file.csv” -Append -NoTypeInformation
7. The next step is to query multiple computers :
Computer from text file :Get-Content -Path c:\computers.txt | ForEach-Object {Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer $_} come from AD Domain computers : Get-ADComputer -Filter {OperatingSystem -Like 'Windows 10*'} | ForEach-Object {Get-WmiObject -Namespace ROOT\StandardCIMV2 -Class MSFT_NetTCPConnection -Computer $_.Name}
边栏推荐
- Unity about conversion between local and world coordinates
- Volcano becomes spark default batch scheduler
- [product design and R & D collaboration tool] Shanghai daoning provides you with blue lake introduction, download, trial and tutorial
- Kernel Debugging Tricks
- memcached全面剖析–2. 理解memcached的内存存储
- Pattern recognition - 9 Decision tree
- how to install clustershell
- BBR bandwidth per second conversion logic
- 关于Unity中的transform.InverseTransformPoint, transform.InverseTransofrmDirection
- Pytest test framework II
猜你喜欢
66 pitfalls in go programming language: pitfalls and common errors of golang developers
Handwritten RPC the next day -- review of some knowledge
VSCode无网环境快速迁移开发环境(VIP典藏版)
JMeter implementation specifies concurrent loop testing
memcached全面剖析–2. 理解memcached的內存存儲
Simple analysis of WordPress architecture
Php-pdo parameter binding problem
memcached全面剖析–5. memcached的应用和兼容程序
Multi task model of recommended model: esmm, MMOE
BPF_ PROG_ TYPE_ SOCKET_ Filter function implementation
随机推荐
Role of wait function
Distributed basic concepts
Tso hardware sharding is a header copy problem
Address mapping of virtual memory paging mechanism
一文理解OpenStack网络
66 pitfalls in go programming language: pitfalls and common errors of golang developers
力扣每日一题-第25天-496.下一个更大元素Ⅰ
Ebpf XDP mount point analysis
Network layer
Please open online PDF carefully
Decoration home page custom full screen video playback effect GIF dynamic picture production video tutorial playback code operation settings full screen center Alibaba international station
JMeter basic learning records
Failed to open after installing Charles without any prompt
【Camera基础(二)】摄像头驱动原理和开发&&V4L2子系统驱动架构
Typescript syntax
Bld3 getting started UI
Simple analysis of WordPress architecture
[cloud native learning notes] learn about kubernetes' pod
Appium desktop introduction
Slider控制Animator动画播放进度