Giter Site home page Giter Site logo

desigua / collectingnetstat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aleksandrreznik/collectingnetstat

0.0 0.0 0.0 23 KB

running netstst in loop to collect connections statistics by host and protocol

License: GNU General Public License v3.0

PowerShell 100.00%

collectingnetstat's Introduction

CollectingNETSTAT

Continuosly running netstat to collect connections statistics by host and protocol

Prerequisities: Windows operating system with Powershell installed (checked on both 5.2 and 7.3 versions)

Instructions:

Script accepts following paramters:

param_LocalIP - if specified it will use this our server IP for collecting data, if not specified in a parameters it will enumerate local IPs and ask you to choose one to gather statistics on. On Windows Server 2008 enumeration routine is not working (because of older Powershell version) so you have to specify this parameter.

param_numberOfNetstats2run - number of netstats to run, It will stop automatically after reaching this number. Usually it runs 2-3 netstats per second.

param_resolveIPs2FQDNs - Perform reverse resolution of collected IPs to hostnames. Default value is "true". It can take several minutes (may be tens of minutes) after it finish looping netstat to perform this.

param_collectOnlyEstablished - show only connections of "ESTABLISHED" type. Default value is "true".

param_CreateCSV - generate CSV file with stats on connections collected. Default value is "true".

$pathToSaveFiles - path to folder where to save both .txt and .csv files. By default it save them to same folder the script is run from

Example Usage:

simplest way: save code to file with .ps1 extension, lets say collectingNetstat.ps1. Open your powershell console. Perform "cd <path to your file>". Then type ".\collectingNetstat.ps1". It will ask you IP to gather statistics from. After running it a while press Ctrl+C. As we running it without any parameter it will try to perform reverse DNS queries on all IP - you have to wait till it finish this process. After finishing it will show you path to .txt and .csv files with statistics.

.\collectingNetstat.ps1 -param_numberOfNetstats2run 10 -param_resolveIPs2FQDNs $false - will perform 10 netstats and don't try to resolve IPs to FQDNs

N.B.

Use it on your own risk. To my view the risks are minimal. The worst thing if you run it in some remote session on a server and forget to switch it off. It collects all connections stats to in-memory hashtables so some lack of memory problems can theoretically occur if you forget to switch it off.

Unfortunately this script is getting TCP-IP connections only so it very usefull for protocols like LDAP, LDAPS, HTTP, HTTPS etc. Unfortunately it doesn't work with DNS as DNS is using UDP mostly. For DNS statistics we have to analyze DNS log file, I have parser for it - plan to publish it soon.

collectingnetstat's People

Contributors

aleksandrreznik avatar borkabu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.