-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenOS Policies
More file actions
29 lines (26 loc) · 1.62 KB
/
ScreenOS Policies
File metadata and controls
29 lines (26 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$policy = Get-Content .\policy.txt
$policy = $policy -join ''
$policy = $policy -split '\s:\s\(\d+'
$rules = @()
$policy | foreach {
$pol_name = ([regex]::Match("$_",':pol_name\s(\((?>[^()]+|(\1))*\))')).value
$enabled = ([regex]::Match("$_",':enabled\s(\((?>[^()]+|(\1))*\))')).value
$from_zone = ([regex]::Match("$_",':from_zone\s(\((?>[^()]+|(\1))*\))')).value
$to_zone = ([regex]::Match("$_",':to_zone\s(\((?>[^()]+|(\1))*\))')).value
$src_addr = ([regex]::Match("$_",':src_addr\s\(\s+:\s(\(.+?\)\s+)+\)')).value
$dst_addr = ([regex]::Match("$_",':dst_addr\s\(\s+:\s(\(.+?\)\s+)+\)')).value
$service = ([regex]::Match("$_",':service\s\(\s+:\s(\(.+?\)\s+)+\)')).value
$action = ([regex]::Match("$_",':action\s\(\s+:\w+')).value
$rule = New-Object -TypeName psobject -Property @{
Name = $pol_name -replace '(\(|\)|:|pol_name)',''
enabled = $enabled -replace '(\(|\)|:|enabled)',''
SourceZones = $from_zone -replace '(\(|\)|:|from_zone)',''
DestinationZones = $to_zone -replace '(\(|\)|:|to_zone)',''
SourceNetworks = (($src_addr -replace '\(|\)|:src_addr\s\(\s+:\s','') -split '\s+:\s+') -join ','
DestinationNetworks = (($dst_addr -replace '\(|\)|:dst_addr\s\(\s+:\s','') -split '\s+:\s+') -join ','
DestinationPorts = (($service -replace ':service\s\(\s+:\s|\(|\)','') -split '\s+:\s+' ) -join ','
Action = $action -replace '(\(|\)|:|action|\s+)',''
}
$rules += $rule
}
$rules | select Name,SourceZones,DestinationZones,SourceNetworks,DestinationNetworks,DestinationPorts,Action,enabled | export-csv rules1.csv -NoClobber -NoTypeInformation