If you'd like to export your Check Point security policy into Microsoft Excel, look no further.
Within Excel you can then easily sort rules by their hit count, first hit, last hit, you name it. So let's start.
- Use Check Point's Show Package Tool to export your security policy to HTML
- SSH login into the export mode of your SmartCenter and run
$MDS_FWDIR/scripts/web_api_show_package.sh -n 443 -c
- Copy the resulting .tgz to your Admin PC and unarchive to a new folder
- Open the exported security policy in your web browser of choice
- View the generated html via DOM inspect and save it into a new .html file
- Remove unnecessary JavaScript code from that .html with your text editor of choice
- Replace
<div>, </div>
and </div></td>
with #!%!#
- Open the .html file with a web browser and copy all content to your clipboard (crtl-a, crtl-c)
- Create an empty Excel sheet and paste your clipboard to it (crtl-v)
- Replace the string #!%!# with crtl-j (creates newlines within the same row)
- Remove any groupings to make sorting functional
- Adjust formatting according to your needs (freeze title pane, hide section titles to allow sorting by hit count etc. etc.)
- Repeat the steps above for all your security policies
Want to add first hit and last hit columns to your Excel sheet? Here you go:
- Unarchive the .tgz from step 1 above into a new directory within expert mode on your SmartCenter Server
- Run the following one-liner on the extracted policy.json file
cat policy.json|tr ',' '\n'|egrep -A6 hits|tr -d '"{}'|sed -e '/hits:level:zero/,/--/c\hits:level:zero\nfine\n--'|egrep 'first-date|last-date|posix|fine'|tr -d '\n'|sed 's/fine/\<\/td\>\<\/tr\>\n\<tr\>\<td\>-\<\/td\>\<td\>-\<\/td\>\<td\>-\<\/td\>\<td\>-/g'|sed 's/first-date:iso-8601:/\<\/td\>\<\/tr\>\n\<tr\>\<td\>/g'|sed 's/posix:/\<\/td\>\<td\>/g'|sed 's/last-date:iso-8601:/\<\/td\>\<td\>/g'
- Copy the output from step 2 into a new .html file and open it with a Web browser on your Admin PC
- Copy the web content into your clipboard (crtl-a, crtl-c)
- Paste your clipboard into two new colums within your Excel sheet (crtl-v)
- Adjust formatting and make sortable
- Verify result > Done!
Want a video that documents the described procedure? Like this thread and I'll create one.