From c7d81b75a11d897fdfd0212e2454865723f25bd9 Mon Sep 17 00:00:00 2001 From: Thumbscrew Date: Tue, 5 Nov 2019 20:36:08 +0000 Subject: [PATCH 1/2] Created format ps1xml. Needs tweaking some more. --- PSWinFW.psd1 | Bin 8068 -> 8138 bytes formats/FirewallEvent.Format.ps1xml | 75 ++++++++++++++++++++++++++++ public/Get-PSFirewallLog.ps1 | 2 + 3 files changed, 77 insertions(+) create mode 100644 formats/FirewallEvent.Format.ps1xml diff --git a/PSWinFW.psd1 b/PSWinFW.psd1 index 128309da12abeed4c76b884841024de456cf5a1f..926927d51623d54a2e40b8f41c2c71eb8a3c89be 100644 GIT binary patch delta 90 zcmZp%KV`q+1pnkS{92ys3~3Dc3`GpN42cXS48;sF3~mgWKz=GiIZz}A2wfSY%G&K_<1H@;g_4-$IG|bOQ3-t0HNm!0{{R3 diff --git a/formats/FirewallEvent.Format.ps1xml b/formats/FirewallEvent.Format.ps1xml new file mode 100644 index 0000000..223ff5a --- /dev/null +++ b/formats/FirewallEvent.Format.ps1xml @@ -0,0 +1,75 @@ + + + + + FirewallEvent + + PSWinFW.Log.Event + + + + + 10 + + + 8 + + + 5 + + + 4 + + + + + 5 + + + 5 + + + + 7 + + + + + + + Date + + + Time + + + Action + + + Protocol + + + SourceIP + + + DestinationIP + + + SourcePort + + + DestinationPort + + + Size + + + Path + + + + + + + + \ No newline at end of file diff --git a/public/Get-PSFirewallLog.ps1 b/public/Get-PSFirewallLog.ps1 index e55e033..d406ee3 100644 --- a/public/Get-PSFirewallLog.ps1 +++ b/public/Get-PSFirewallLog.ps1 @@ -134,6 +134,8 @@ function Get-PSFirewallLog { $fwEvent | Add-Member NoteProperty -Name $member.Name -Value $split[$member.Value] } + $fwEvent.pstypenames.insert(0, 'PSWinFW.Log.Event') + $fwEvent } } From 4419df1e5b8a8f6871a5d1044d4821f3aef2da29 Mon Sep 17 00:00:00 2001 From: Thumbscrew Date: Wed, 6 Nov 2019 19:35:16 +0000 Subject: [PATCH 2/2] Adjusted Table width, added labels. Removed Include switches as no longer required. --- PSWinFW.psd1 | Bin 8138 -> 8186 bytes formats/FirewallEvent.Format.ps1xml | 5 ++- public/Get-PSFirewallLog.ps1 | 49 +++++----------------------- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/PSWinFW.psd1 b/PSWinFW.psd1 index 926927d51623d54a2e40b8f41c2c71eb8a3c89be..f19fb4bb23bcffa1af9c3dc2b5f63ef5a86a9ec0 100644 GIT binary patch delta 117 zcmX?Q|I28 - 5 + 6 + 4 + 5 + 5 diff --git a/public/Get-PSFirewallLog.ps1 b/public/Get-PSFirewallLog.ps1 index d406ee3..a3f4d9b 100644 --- a/public/Get-PSFirewallLog.ps1 +++ b/public/Get-PSFirewallLog.ps1 @@ -28,21 +28,6 @@ function Get-PSFirewallLog { [int] $Tail = 0, - # Include extended TCP information (TCP Flags, TCP Sequence Number, TCP ACK Number, TCP Window Size). Defaults to false. - [Parameter(Mandatory = $false)] - [switch] - $IncludeTcpInfo, - - # Include extended ICMP information (ICMP Type and Code). Defaults to false. - [Parameter(Mandatory = $false)] - [switch] - $IncludeIcmpInfo, - - # Include Info field. Defaults to false. - [Parameter(Mandatory = $false)] - [switch] - $IncludeInfo, - # ComputerName to retrieve log from [Parameter(Mandatory = $false, ParameterSetName = 'remote')] [string] @@ -96,34 +81,16 @@ function Get-PSFirewallLog { "SourcePort" = 6 "DestinationPort" = 7 "Size" = 8 + "TcpFlags" = 9 + "TcpSyn" = 10 + "TcpAck" = 11 + "TcpWin" = 12 + "IcmpType" = 13 + "IcmpCode" = 14 + "Info" = 15 + "Path" = 16 } - if($IncludeTcpInfo) { - $tcpMembers = @{ - "TcpFlags" = 9 - "TcpSyn" = 10 - "TcpAck" = 11 - "TcpWin" = 12 - } - - $members += $tcpMembers - } - - if($IncludeIcmpInfo) { - $icmpMembers = @{ - "IcmpType" = 13 - "IcmpCode" = 14 - } - - $members += $icmpMembers - } - - if($IncludeInfo) { - $members += @{ "Info" = 15 } - } - - $members += @{ "Path" = 16 } - $log | ForEach-Object { $line = $_ $split = $line -split ('\s')