当前位置:网站首页>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}
边栏推荐
- Station B takes goods to learn from New Oriental
- Auto. JS to realize automatic unlocking screen
- Rewrite, maplocal and maplocal operations of Charles
- database/sql
- Big factories go out to sea and lose "posture"
- Oauth1.0 introduction
- Football information query system based on C language course report + project source code + demo ppt+ project screenshot
- 升哲科技 AI 智能防溺水服务上线
- Shengzhe technology AI intelligent drowning prevention service launched
- 188. the best time to buy and sell stocks IV
猜你喜欢

CondaValueError: The target prefix is the base prefix. Aborting.

Web project deployment

Dynamic routing protocol rip, OSPF

【产品设计研发协作工具】上海道宁为您提供蓝湖介绍、下载、试用、教程

Memcached full profiling – 1 Fundamentals of memcached

The first day of handwritten RPC -- review of some basic knowledge

Oauth2.0 introduction

推荐模型之多任务模型:ESMM、MMOE

Why are life science enterprises on the cloud in succession?

The virtual currency evaporated $2trillion in seven months, and the "musks" ended the dream of 150000 people becoming rich
随机推荐
架构实战营 第 6 期 毕业总结
Advanced secret of xtransfer technology newcomers: the treasure you can't miss mentor
介绍BootLoader、PM、kernel和系统开机的总体流程
Notes_ Vlan
123. the best time to buy and sell shares III
Shengzhe technology AI intelligent drowning prevention service launched
Three more days
Blender's simple skills - array, rotation, array and curve
B站带货当学新东方
基于C语言实现的足球信息查询系统 课程报告+项目源码+演示PPT+项目截图
关于Unity中的transform.InverseTransformPoint, transform.InverseTransofrmDirection
Unity about conversion between local and world coordinates
图的邻接表存储 数组实现
基于STM32的物联网下智能化养鱼鱼缸控制控制系统
[product design and R & D collaboration tool] Shanghai daoning provides you with blue lake introduction, download, trial and tutorial
Analysis of tcpdump packet capturing kernel code
Ebpf XDP mount point analysis
go_ keyword
Pod lifecycle in kubernetes
Realization of truth table assignment by discrete mathematical programming