Rewrite netstat and arp/net-neighbor collection method #197
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This rewrite changes the way information about active connections and the arp cache is collected from a live system.
Netstat
Originally,
netstat -ano
was invoked by theNetstat
module. Now, information about the active connections (both TCP4/6 and UDP4/6) is obtained using theGetExtendedTcpTable
andGetExtendedUdpTable
API calls fromiphlpapi.dll
.Arp
Originally, either
arp -av
orGet-NetNeighbor
was invoked by theWinArpCache
module, depending on the operating system version. Now, information about peers is obtained usingGetIpNetTable(2)
. Additionally, information about the adapters is obtained.Formatting
No changes were made in the way the information is stored within the resulting package, which remains "command output", as to not introduce any major changes. The output is shown in a similar manner to that of the originally invoked binaries. However, the ability to format the information as both JSON and CSV output is included, and exposed by the following functions:
format_net_connections_csv
format_net_connections_json
and
format_net_neighbors_csv
format_net_neighbors_json
These formats could later be used for more easy parsing of the information.
Collection using acquire was tested on both 32 and 64 bit.