<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>yurisk.info &#187; Awk weekly</title>
	<atom:link href="http://yurisk.info/category/awk-weekly/feed/" rel="self" type="application/rss+xml" />
	<link>http://yurisk.info</link>
	<description>Technical Blog about IT Security and Networking</description>
	<lastBuildDate>Tue, 07 Sep 2010 12:42:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>List of valid domain names for load testing DNS</title>
		<link>http://yurisk.info/2010/08/14/list-of-valid-domain-names/</link>
		<comments>http://yurisk.info/2010/08/14/list-of-valid-domain-names/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 09:45:19 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scan of the week]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=1032</guid>
		<description><![CDATA[I am currently running a bunch of tests on DNS resolver software called Unbound to see what it is worth and for that needed a list of valid domain names in different but controllable TLDs. The only resource to download such list I could find was 3 million records file from Nominum Sample query data [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently running a bunch of tests on DNS resolver software called  <a href="http://www.unbound.net/"> Unbound </a> to see what it is worth and for that needed a list of valid domain names in different but controllable TLDs. The only resource to download such list I could find was 3 million records file from Nominum  <a href="ftp://ftp.nominum.com/pub/nominum/dnsperf/data/queryfile-example-3million.gz">  Sample query data file for use with resperf </a> . Only that it contains all kinds of record types &#58; A, PTR, AAAA and  I want list of domain names where I can modify query type but also that it will be of a specific TLD sample.<br />
Say all domains in .ASIA only TLD . To compile such list I took a word list , added to each word specific extensions and then run against some DNS server. Then I filtered the answers to include only existing resolvable domains that return at least 1 answer to query ANY. So far I did it for extensions &#58; .ASIA .COM .CA .BIZ .EDU .EU .FR .INFO .MIL .NET .ORG .RU and it brought 831903 valid domains.<br />
You can download  the final list of those domains here &#58; <a href="http://yurisk.info/domain_list.txt.gz"> Domain list 831903 domains </a></p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/08/14/list-of-valid-domain-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 usernames used in SSH brute force</title>
		<link>http://yurisk.info/2010/06/04/top-10-usernames-used-in-ssh-brute-force/</link>
		<comments>http://yurisk.info/2010/06/04/top-10-usernames-used-in-ssh-brute-force/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 09:08:23 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=874</guid>
		<description><![CDATA[In continuation to yesterday&#8217;s post I thought it would be interesting to know statistics of the usernames used in those bruteforce probes. I thought and I did . Find below awk/sed script to get usernames for failed ssh login attempts and sort it for statistics and also list of the usernames I got from my [...]]]></description>
			<content:encoded><![CDATA[<p>In continuation to yesterday&#8217;s post I thought it would be interesting to know statistics of the usernames used in those bruteforce probes. I thought and I did . Find below awk/sed script to get usernames for failed ssh login attempts and sort it for statistics and also list of the usernames I got from my server. The full list of usernames can be found at the end.<br />
The script&#58;</p>
<div class="cmd"> awk   &#39;/Failed password for/  &#39;  /var/log/secure*  | sed  &#39;s/.* \([[:print:]]\+\) from .*/  \1  /g &#39; | sort | uniq &#45;c | sort &#45;n &#45;k1</div>
<p>And the winners are&#58;</p>
<table summary="The table listing top 10 usernames used in real cracking attampts on SSH service">
<caption>The table listing top 10 usernames used in real cracking attampts on SSH service</caption>
<tr class="thcolor">
<th>Username</th>
<th>Number of times seen</th>
</tr>
<tr>
<td>mysql</td>
<td>232</td>
</tr>
<tr class="cellcolor">
<td>info</td>
<td>252</td>
</tr>
<tr>
<td>postgres</td>
<td>317</td>
</tr>
<tr class="cellcolor">
<td>guest</td>
<td>435</td>
</tr>
<tr>
<td>nagios</td>
<td>452</td>
</tr>
<tr class="cellcolor">
<td>user</td>
<td> 459</td>
</tr>
<tr>
<td>oracle</td>
<td>598</td>
</tr>
<tr class="cellcolor">
<td>admin</td>
<td> 884</td>
</tr>
<tr>
<td>test</td>
<td>1017</td>
</tr>
<tr class="cellcolor">
<td>root</td>
<td>22058</td>
</tr>
</table>
<p>Full list of the usernames <a href="http://yurisk.info/usernames.log">Usernames.log</a></p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/06/04/top-10-usernames-used-in-ssh-brute-force/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH brute force is on the rise</title>
		<link>http://yurisk.info/2010/06/03/ssh-brute-force-on-the-rise/</link>
		<comments>http://yurisk.info/2010/06/03/ssh-brute-force-on-the-rise/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 19:31:43 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=865</guid>
		<description><![CDATA[SSH brute forcing is still in high demand. I have , for my own testing and pleasure, virtual servers scattered around the world. All of them being of the Linux/BSD family I manage by SSH. The other quirk of mine is that I have on purpose no static IP at home for various reasons (saving [...]]]></description>
			<content:encoded><![CDATA[<p>SSH brute forcing is still in high demand. I have , for my own testing and pleasure, virtual servers scattered around the world. All of them being of the Linux/BSD family  I manage by SSH. The other quirk of mine is that I have on purpose no static IP at home for various reasons (saving  me money being one of them). And to manage those servers by SSH I implement a very simple security rule – from Any to SSH port allow. Port is left to be standard one – 22. After all that time my server was broken into just once , when I gave access by SSH to the colleague of mine and later he changed the password to something crackable in 5 secs. Since then I  &#8211; first don’t give ssh access to colleagues <img src='http://yurisk.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , and second &#8211; look from time to time at ssh failed attempts logs for amusement.<br />	<br />
My observations so far are &#58;<br />
 &#8211; ssh brute forcing is still/yet/again extremely popular and increasing . On average after unfirewalled access to port 22 is discovered it goes to ~ 5000-6000 attempts per day .<br />
 &#8211; crackers do have some means of communicating between them (market economy ?) – my servers have static IPs and first days after its set up brute force login attempts are as low as 2-10 a day. But once the server IP has been discovered by determined crackers it goes up in numbers very quickly.<br />
 &#8211; origins of the attacks correlate pretty well with the known sources of Spam/Malware &#58; Brazil, China, US etc.<br />
If you’d like to look at your SSH logs and do some stats on failed attempts here is the awk one-liner I use. Enjoy.</p>
<div class="cmd">
awk &#45;&#45;re-interval &#39;/authentication failure/ {}<br />
/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]/ {match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]/,IP);  IPS[IP[0]]++ } END { for (cracker_ips in IPS) print cracker_ips &#34;  &#34; IPS[cracker_ips]}&#39; /var/log/secure.1 | sort -n -k2 </div>
<div class="cmdout">
190.202.85.3  1<br />
194.192.14.7  1<br />
212.111.199.3  1<br />
222.124.195.1  1<br />
210.71.71.1  2<br />
89.138.195.1  5<br />
212.156.65.7  25<br />
202.117.51.2  32<br />
210.51.48.7  32<br />
115.146.138.5  47<br />
60.191.98.5  88<br />
174.120.208.5  107<br />
61.129.60.2  165<br />
202.103.180.4  175<br />
213.251.192.2  239<br />
91.82.101.4  242<br />
220.173.60.6  264<br />
12.11.210.3  271<br />
144.16.72.1  291<br />
212.118.5.1  360<br />
66.11.122.1  384<br />
211.160.160.1  703<br />
190.12.66.1  999<br />
83.19.184.3  1176<br />
67.213.8.2  4955<br />
199.187.120.2  5312<br />
95.0.180.2  6680<br />
85.131.163.5  7685
</div>
<p>NB Crackers IPs are not sanitized</p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/06/03/ssh-brute-force-on-the-rise/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Schedule fw monitor to run unattended</title>
		<link>http://yurisk.info/2010/05/29/schedule-fw-monitor-to-run-unattended/</link>
		<comments>http://yurisk.info/2010/05/29/schedule-fw-monitor-to-run-unattended/#comments</comments>
		<pubDate>Sat, 29 May 2010 08:43:48 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Checkpoint NG/NGX]]></category>
		<category><![CDATA[Checkpoint]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=838</guid>
		<description><![CDATA[Not a groundbreaking idea but worth remembering that you can also run scheduled fw monitor using the cron. In case you have some problem occurring at the late night hours or you want to run debug at night when system is loaded less or put your case here this is one of the ways to [...]]]></description>
			<content:encoded><![CDATA[<p>Not a groundbreaking idea but worth remembering that you can also run scheduled fw monitor using the cron. In case you have some problem occurring at the late night hours or you want to run debug at night when system is loaded less or put your case here this is one of the ways to do it.<br />
First, the script named timed_fw_monitor.sh  that starts the fw monitor:</p>
<div class="cmdout">
#!/bin/bash <br />
# We have to source Checkpoint environment variables for fw monitor to work<br />
. /etc/profile.d/CP.sh<br />
/opt/CPsuite-R71/fw1/bin/fw monitor -o /home/lambada/capture.cap  -e &#8216;accept icmp or port(25);&#8217;</div>
<p>Then of course I will want to stop fw monitor , here is the script named stop_fw_monitor.sh that I also put in cron jobs that stops previously started fw monitor :</p>
<div class="cmdout">
#!/bin/bash<br />
ps ax | grep  &#8216;capture.cap&#8217; | grep -v grep | awk &#8216;{ print (&#8220;kill -s 3 &#8221; $1) | &#8220;/bin/bash&#8221; }&#8217;</div>
<p>Now my crontab looks like this:</p>
<div class="cmdout">
# DO NOT EDIT THIS FILE &#8211; edit the master and reinstall.<br />
# (/tmp/crontab.4760 installed on Sat May 29 11:00:22 2010)<br />
# (Cron version &#8212; $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)<br />
03 23  * * * /home/lambada/timed_fw_monitor.sh > /dev/null<br />
17 23  * * * /home/lambada/stop_fw_monitor.sh > /dev/null</div>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/05/29/schedule-fw-monitor-to-run-unattended/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alert on change of SOA in domain</title>
		<link>http://yurisk.info/2010/05/22/alert-on-change-of-soa-in-domain/</link>
		<comments>http://yurisk.info/2010/05/22/alert-on-change-of-soa-in-domain/#comments</comments>
		<pubDate>Sat, 22 May 2010 12:27:57 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=819</guid>
		<description><![CDATA[This comes from unpleasant experience of mine. One of my clients’ domain records (MX for the case involved) was mistakenly changed. While it was a human error and trying to fix humans is rolling the rock of Sisyphus,damage would be much lesser had I known about the change immediately . To take care of this [...]]]></description>
			<content:encoded><![CDATA[<p>This comes from unpleasant experience of mine. One of my clients’ domain records (MX for the case involved) was mistakenly changed. While it was a human error and trying to fix humans is rolling the rock of Sisyphus,damage would be much lesser had I known about the change immediately . To take care of this side of the story I wrote awk one-liner that when invoked by cron compares  SOA of the domain with  the one saved locally in the file. If there is a discrepancy the mail is sent.<br />I tried to find more elegant solution on Google but found zillions of tools too complex for such a simple task.</p>
<div class="cmdout">
#!/bin/bash<br />
awk &#8216;  BEGIN {&#8220;dig +short soa yurisk.info&#8221; | getline<br />
  SOA_NOW=$3<br />
getline SOA &lt; &#8220;serial-yurisk.info&#8221;<br />
  if (SOA_NOW != SOA) { print ( &#8221; mail -c yurisk@yurisk.info -s \&#8221;SOA of domain yurisk.info has changed\&#8221;  president@whitehouse.gov&#8221;) | &#8220;/bin/bash&#8221; }}&#8217; </div>
<div class="cmdout">serial-yurisk.info:<br />2010012000</div>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/05/22/alert-on-change-of-soa-in-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scan of the week &#8211; scan by country scan by continent</title>
		<link>http://yurisk.info/2010/03/22/scan-of-the-week-scan-by-country-scan-by-continent/</link>
		<comments>http://yurisk.info/2010/03/22/scan-of-the-week-scan-by-country-scan-by-continent/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 21:15:09 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Scan of the week]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=622</guid>
		<description><![CDATA[Gooood morning everyone . Today I launch yet another weekly column &#8220;Scan of the week&#8221; and this will be all about scanning the Net. Tools will be many but they will not be the point, my wanting here is to show interesting/funny/unusual/useful things you can see on the Internet by going out there and exploring. [...]]]></description>
			<content:encoded><![CDATA[<div class="portant"> Gooood morning everyone . Today I launch yet another weekly column &#8220;Scan of the week&#8221; and this will be all about scanning the Net. Tools will be many but they will not be the point, my wanting here is to show interesting/funny/unusual/useful things you can see on the Internet by going out there and exploring.<br />
Dis+claimer &#8211; all this stuff I bring to your attention is for educational purposes only, and what may be fine and ok here and for me can easily get you somewhere else in trouble so use your discretion here .<br />
Happy scanning.</div>
<p> <em>&#8220;&#8230;Don&#8217;t know much about geography&#8221;</em> as the song goes was ok in 1958 but can be embarrassing in our times of globalization. So let&#8217;s fill the gap using the <a href="http://nmap.org"><strong>NMAP</strong></a> . Say you<br />
are investigating the issue of negative attitude towards foreigners in Russia , and as part of the research<br />
you just have to see active members of the movement(s) in question voicing their opinions. Only that many<br />
times access to such forums or messageboards is limited by their admins to Russian IPs only. So to get there you need a free open Russian proxy. So let&#8217;s see how to find one.</p>
<p><strong>Round 1-Gimme the addresses. </strong>IP geolocation databases as it is known in the Net , or simply GeoIP databases are compilation of IP ranges per their assigned country. Take it with a bit of salt as accuracy is the issue here. The one of the most known and used free GeoIP source is <a href="http://maxmind.com"> Maxmind.com</a> free database that is updated once per month (good enough for this).<br />
The Maxmind database comes as binary proprietary format file you can work with using 3rd party tools or as CSV file I will be using here. Download it as <a href="http://www.maxmind.com/app/geolitecountry"> Geolite country  </a> , unzip and you have GeoIpCountryCSV.csv . Format of the records in it goes like this -</p>
<pre>
"1.0.0.0","1.0.0.255","16777216","16777471","AP","Asia/Pacific Region"
"1.1.1.0","1.1.1.255","16843008","16843263","AU","Australia"
"1.2.3.0","1.2.3.255","16909056","16909311","AU","Australia"
"1.50.0.0","1.50.3.255","20054016","20055039","AP","Asia/Pacific Region"
</pre>
<p>The purpose here is to :</p>
<ol>
<li> Find all IP ranges that belong to the country of interest</li>
<li> Reformat found IP ranges into the presentation suitable for the NMAP</li>
</ol>
<div class="cmd">
awk -F, &#8216;/RU/  { gsub(/&#8221;/,&#8221;",$0);  print $1 &#8220;-&#8221; $2} &#8216; GeoIPCountryWhois.csv  > IPs.data</div>
<pre><strong>head IPs.data</strong>
62.5.128.0-62.5.255.255
62.12.80.0-62.12.81.255
62.16.32.0-62.16.66.255
</pre>
<p>- After I found all Russian IPs reformat it to the NMAP eatable form</p>
<div class="cmd">
awk -F\. &#8216;{split($4,aaa,&#8221;-&#8221;); print $1&#8243;-&#8221;aaa[2]&#8220;.&#8221;$2&#8243;-&#8221;$5 &#8220;.&#8221; $3&#8243;-&#8221;$6&#8243;.&#8221;aaa[1]&#8220;-&#8221;$7}&#8217; IPs.data > scan.me</div>
<pre> <strong>head scan.me</strong>
62-62.5-5.128-255.0-255
62-62.12-12.80-81.0-255
62-62.16-16.32-66.0-255
62-62.16-16.68-127.0-255
62-62.32-32.64-95.0-255
</pre>
<p><strong> Round 2 &#8211; find me some proxy</strong> Here I will use LUA script from NSE repository of the nmap called http-open-proxy </p>
<div class="cmd">nmap -n -PN -oN proxy-check.grep &#8211;script=http-open-proxy   -iL scan.me -p 8080,3128</div>
<p>That completes this opening article of the <strong>Scan of the week</strong> united with <strong>Awk weekly</strong> . Hope you found it educational enough and see you next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/03/22/scan-of-the-week-scan-by-country-scan-by-continent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>awk weekly &#8211; rule hits statistics . Checkpoint again</title>
		<link>http://yurisk.info/2010/03/13/awk-weekly-rule-hits-statistics-checkpoint-again/</link>
		<comments>http://yurisk.info/2010/03/13/awk-weekly-rule-hits-statistics-checkpoint-again/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 10:50:36 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Checkpoint NG/NGX]]></category>
		<category><![CDATA[Checkpoint]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=572</guid>
		<description><![CDATA[I know , I know, I have to get out of this Checkpoint-only land and am working on this ,but for today again comes the awk travelling diary on the Checkpoint firewall roads. As I mentioned before once you export firewall logs into human-readable format you can do lots of interesting things &#8211; for example [...]]]></description>
			<content:encoded><![CDATA[<p>I know , I know, I have to get out of this Checkpoint-only land and am working on this ,but for today again comes the awk  travelling diary on the Checkpoint firewall roads. As I mentioned before once you export firewall logs into human-readable format you can do lots of interesting things &#8211; for example script that gives statistics of how many times each Security rule was hit .<br />
Be aware that this counts explicit Security rules only &#8211; i.e. the ones you see in Security tab of the Smartdashboard. No other rules you usually see in Smartview Tracker are counted &#8211; e.g. SmartDefense,Web Filtering etc. Also afterwards I sort it by number of hits to see what rules are used most:</p>
<div class="cmd">awk -F\;  &#8216; {match($0,/rule: +([0-9]+)/,rules);rule_count[rules[1]]++} END {for (rule_number in rule_count) print &#8221; Rule number: &#8221;  rule_number &#8221; Hits: &#8221; rule_count[rule_number]}&#8217; ./fw.log.txt | sort -n -k5 </div>
<pre>
Rule number:  Hits: 1197330 <strong> Ignore this line as it counts non-matched lines I dont want to filter with additional conditions and added time processing</strong>
 Rule number: 2 Hits: 9
 Rule number: 5 Hits: 366
 Rule number: 11 Hits: 12296
 Rule number: 9 Hits: 14457
 Rule number: 0 Hits: 17094
 Rule number: 1 Hits: 44066
 Rule number: 7 Hits: 233643
 Rule number: 10 Hits: 366275
 Rule number: 6 Hits: 424639 </pre>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/03/13/awk-weekly-rule-hits-statistics-checkpoint-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>awk weekly &#8211; Checkpoint Anti Spam statistics or viva la Open Relays</title>
		<link>http://yurisk.info/2010/03/08/awk-weekly-checkpoint-anti-spam-statistics-or-viva-la-open-relays/</link>
		<comments>http://yurisk.info/2010/03/08/awk-weekly-checkpoint-anti-spam-statistics-or-viva-la-open-relays/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:56:38 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Checkpoint NG/NGX]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=556</guid>
		<description><![CDATA[Goooood day everyone again, today I have had another fight with the spam cartel that my client fell victim of. Once upon a time there was not so powerful UTM providing internet to not so crowded office in not so security-aware Central Europe. All would be good and well if not this problem &#8211; they [...]]]></description>
			<content:encoded><![CDATA[<p>Goooood day everyone again,<br />
today I have had another fight with the spam cartel that my client fell victim of. Once upon a time there was not so powerful UTM providing internet to not so crowded office in not so security-aware Central Europe.<br />
All would be good and well if not this problem &#8211; they could not send emails outside as the IP of the firewall entered every imaginable blacklist on the Earth. Hmm, but the firewall has AntiSpam subscription service up and running.<br />
LAN is blocked on port 25 outbound except the Exchange. Antivirus is everywhere so low chance of spam coming from LAN. In SmartView Tracker lots of SMTP rule logs in red &#8211; spam entering Exchange is blocked .</p>
<p>So what the &#8230;? tcpdump with -w option for 5 minutes was all I needed to see that Exchange was open relay and kindly offered to relay spam from everyone to everywhere.<br />
To really measure the impact of the event I had to have some statistics and Checkpoint didn&#8217;t help me much with that , eventhough this UTM has also SmartView Monitor license it is not suited for the task. So I exported fw.log on the UTM into text human-awk-readable format , that took some 40 mins on 300 Mb log file and produced text file of 475 Mb, and then did whatever I wanted with the data using awk.<br />
Now get some action:<br />
Script 1 &#8211; Find all mails rejected in direction from LAN (interface Internal, remember it is UTM) to the Internet (interface External) , then gather statistics of how many mails came from what ip [less relevant here as all mails come from Exchnage, but in environment where hosts send mails directly outside it is] and show us :</p>
<div class="cmd"># awk -F\; &#8216;/Internal to External/ &amp;&amp; /reject/ {print $2}&#8217; ./fw.log.txt | awk &#8216; {match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/,IP); IPS[IP[0]]++ } END { for (spammer_ips in IPS) print spammer_ips &#8221; &#8221; IPS[spammer_ips]}&#8217; | sort -n -k2,2</div>
<div class="cmdout">192.168.14.12 402804</div>
<p>Yahooooo! In the timeframe of 28 hours there were blocked 402804 mails as spam coming from Exchange!<br />
Not bad at all &#8211; all this without any malware installed on the client side [my educated by Wireshark guess here as I dont have access to the Exchange],just amazing!</p>
<p>Now let&#8217;s have a look at overal number of mails that was accepted and sent outside to the Internet :<br />
Script 2 &#8211; Find all mails accepted in direction from LAN (interface Internal) to the Internet (interface External) , then gather statistics of how many mails came from what ip and show us :</p>
<div class="cmd"># awk -F\; &#8216;/Internal to External/ &amp;&amp; /accept/ {print $2}&#8217; ./fw.log.txt | awk &#8216; {match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/,IP); IPS[IP[0]]++ } END { for (spammer_ips in IPS) print spammer_ips &#8221; &#8221; IPS[spammer_ips]}&#8217; | sort -n -k2,2<br />
192.168.14.12 257940</div>
<p>Wow! in addition to 402804 mails blocked by Checkpoint firewall as spam 257940 mails were sent out as clean, given that this is a very small office hardly sending 300 mails a day we get ratio of 39% spam passing through the Checkpoint Antispam , pity . Antispam blocking rate of 61% ? In 21st century ? Wake up !</p>
<p>Just for statistics I also calculated how many spam emails were blocked from outside inbound:<br />
Script 3 &#8211; gather how many mails from outside coming in were rejected by Checkpoint as spam.</p>
<div class="cmd"># awk -F\; &#8216;/External to Internal/ &amp;&amp; /reject/ {print $2}&#8217; ./fw.log.txt | wc</div>
<div class="cmdout"># 5593 11186 112648</div>
<p>So only 5593 incoming spam emails and almost half a million outgoing ones &#8211; that&#8217;s what I call effectiveness.<br />
Script 4 &#8211; gather statistics on blocked emails and IPs it came from:</p>
<div class="cmd"># awk -F\; &#8216;/External to Internal/ &amp;&amp; /reject/ {print $2}&#8217; ./fw.log.txt | awk &#8216; {match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/,IP); IPS[IP[0]]++ } END { for (spam_ips in IPS) print spam_ips &#8221; &#8221; IPS[spam_ips]}&#8217; | sort -n -k2,2 </div>
<p>And here are some results</p>
<div class="cmdout">93.81.26.2 75<br />
91.121.114.1 81<br />
220.168.57.1 87<br />
58.9.205.2 129<br />
122.102.101.1 149<br />
58.137.99.7 160<br />
189.35.231.6 189<br />
60.248.174.6 631</div>
<p>PS I know Checkpoint folks visit here , so if you think I get some data wrong &#8211; don&#8217;t be shy to correct me,all fixes are gladly welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/03/08/awk-weekly-checkpoint-anti-spam-statistics-or-viva-la-open-relays/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>awk weekly &#8211; how to see Checkpoint logs on command line</title>
		<link>http://yurisk.info/2010/02/26/awk-weekly-how-to-see-checkpoint-logs-on-command-line/</link>
		<comments>http://yurisk.info/2010/02/26/awk-weekly-how-to-see-checkpoint-logs-on-command-line/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 20:12:57 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Awk weekly]]></category>
		<category><![CDATA[Checkpoint NG/NGX]]></category>
		<category><![CDATA[Checkpoint]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=518</guid>
		<description><![CDATA[Hey Everyone, I decided to start a weekly column of awk scripting where I will bring interesting (I am being subjective I know) short scripts that made my life easier in dealing with actual problems in the wild or just look cool. Until recently I had never had any need to work with Checkpoint log [...]]]></description>
			<content:encoded><![CDATA[<div class="portant">Hey Everyone, I decided to start a weekly column of awk scripting where I will bring interesting (I am being subjective I know) short scripts that made my life easier in dealing with actual problems in the wild or just look cool.</div>
<p>Until recently I had never had any need to work with Checkpoint log files without SmartView Tracker , namely on the command line. But there is always first time . Client complained on some dropped mail traffic and to even say if there is any problem or not I had to look at relevant logs, not a big deal except that I had only ssh access to the firewall . Checkpoint provided for such cases <strong>fw log </strong> command line log extracting utility that reads the binary log file (<strong> fw.log </strong> by default) you feed in and outputs it in human-readable format. That’s good, but its filtering possibilities are quite bad . You can see all available options with <strong>fw log –h </strong>, but selection is limited to source, start/end time,action (drop/reject/etc) . Not that much to say the least . No port/direction filtering . And specifically it was a very busy firewall – some 80 mbytes of traffic passing through at any given moment and log is the default action on any rule. So using fw log filters would help me not. <br />
Here is how I solved this with the help of awk – I exported to text format all logs using</p>
<div class="cmd"># fw log -n> fw_log.txt &#038; </div>
<p>Note –n option to fw log here – it prevents resolving IP/ports to names , shortens processing time by ~70%<br />
Then I just used all-powerful awk to search the text file to show the client what was the reason (Exchange in LAN was sending heaps of spam that Anti-Spam stopped at its best but nevertheless some spam leaked and caused RBL blocking of the external firewall IP) :</p>
<div class="cmd">[Expert@Orlean] # awk &#8216;/Anti Spam/ &#038;&#038; /Internal to External/&#8217; fw_log.txt | awk -F: &#8216; {print $5 $6}&#8217; </div>
<pre>192.168.143.12; dst 65.55.37.88; proto
192.168.143.12; dst 65.55.92.136; proto
192.168.143.12; dst 65.55.92.136; proto
192.168.143.12; dst 203.216.247.184; proto</pre>
<p>Here:<br />
External, Internal &#8211; UTM appliance interface names and direction of the Anti-Spam scanning<br />
NOTE: exporting logs from binary to text takes a bit of time, depends on situation. Enabling name resolving sky-rocketed the processing time to 15 minutes , but on the other hand gave some additional insight :</p>
<pre>Exchange; dst col0-mc2-f.col0.hotmail.com; proto
Exchange; dst mx1.hotmail.com; proto
Exchange; dst mx1.hotmail.com; proto
Exchange; dst mta19.mail.vip.tnz.yahoo.co.jp; proto
Exchange; dst bay0-mc2-f.bay0.hotmail.com; proto
Exchange; dst mx3.hotmail.com; proto</pre>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/02/26/awk-weekly-how-to-see-checkpoint-logs-on-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
