<?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>[blog.rayfoo] &#187; SSH</title>
	<atom:link href="http://blog.rayfoo.info/tag/ssh/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.rayfoo.info</link>
	<description>Infosec, DFIR, tech geekery, thoughts and whatnot</description>
	<lastBuildDate>Wed, 25 Jan 2012 00:36:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Profiling of persistent SSHD brute force attack</title>
		<link>http://blog.rayfoo.info/2011/04/profiling-of-persistent-sshd-brute-force-attack</link>
		<comments>http://blog.rayfoo.info/2011/04/profiling-of-persistent-sshd-brute-force-attack#comments</comments>
		<pubDate>Sun, 03 Apr 2011 19:04:19 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[log analysis]]></category>
		<category><![CDATA[log collection]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Splunk]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=823</guid>
		<description><![CDATA[Proper setting up and regular monitoring of logs gives you the avenue to know what's really happening with your box sitting out there in the internets, and to anticipate when bad things are about to happen.  One of the warning signs would be that someone has been poking around your box, looking for an (easy?) [...]]]></description>
			<content:encoded><![CDATA[<p><strong><img class="alignright size-full wp-image-824" title="Brute Force" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/BruteForce.jpg" alt="" width="300" height="240" /></strong></p>
<p>Proper setting up and regular monitoring of logs gives you the avenue to know what's really happening with your box sitting out there in the internets, and to anticipate when <em>bad things</em> are about to happen.  One of the warning signs would be that <em>someone</em> has been poking around your box, looking for an (easy?) way in.</p>
<p>The natural thing that would jump out at you then, is that this <em>someone</em> has been accessing your box in far higher volumes/durations, especially on services that should not be accessed by others.</p>
<p>This is one example of such accesses on a linux box: <em>SSHD brute forcing over long periods of time.</em></p>
<p><span id="more-823"></span>Note: This post is more to talk about the process of digging/profiling, rather than the actual setup processes/log sources involved.  Feel free to ping me/comment below if you wish to discuss though.</p>
<p>The first thing you may ask is: what is "persistent"?  This would be the opposite of the run-of-the-mill opportunistic attackers.  These guys tend to bang your machine for a bit, then leave you alone immediately after failing:</p>
<div id="attachment_826" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/01-opportunistic.png"><img class="size-medium wp-image-826" title="Opportunistic" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/01-opportunistic-300x81.png" alt="" width="300" height="81" /></a><p class="wp-caption-text">Opportunistic attack: Tries and gives up.</p></div>
<p>This contrasts greatly with the persistent buggers:</p>
<div id="attachment_827" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/02-persistent.png"><img class="size-medium wp-image-827" title="Persistent" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/02-persistent-300x83.png" alt="Persistent Bugger" width="300" height="83" /></a><p class="wp-caption-text">Whoa!</p></div>
<p>After digging around first on the IP and supposed country of origin, we want to find out what did the attacker try to do?  One of the logs (*cough*... p0f... *cough*...) feeds info on the ports that were attempted to connect to, this could be a starting point:</p>
<p style="text-align: left;">
<div id="attachment_828" class="wp-caption aligncenter" style="width: 508px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/03-ports-accessed.png"><img class="size-full wp-image-828 " title="Ports Accessed" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/03-ports-accessed.png" alt="" width="498" height="272" /></a><p class="wp-caption-text">Mostly port 22 (SSH), only 1 for port 80 (HTTP)?</p></div>
<p style="text-align: left;">Searching for and viewing the port 80 access attempt, by itself and in relation to the other activities shows the following:</p>
<p style="text-align: center;">
<div id="attachment_832" class="wp-caption aligncenter" style="width: 492px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/04-port-80-access.png"><img class="size-full wp-image-832  " title="04-port-80-access" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/04-port-80-access.png" alt="" width="482" height="205" /></a><p class="wp-caption-text">Pinpointing the port 80 connection</p></div>
<p style="text-align: center;">
<div id="attachment_833" class="wp-caption aligncenter" style="width: 491px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/05-confirming-access-profile.png"><img class="size-full wp-image-833  " title="05-confirming-access-profile" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/05-confirming-access-profile.png" alt="" width="481" height="208" /></a><p class="wp-caption-text">Viewing the logs in chronological order (Splunk defaults to reverse chronological)</p></div>
<p style="text-align: left;">Viewing the logs in chronological order (Splunk defaults to reverse chronological) shows that the port 80 connection preceeded the many many many port 22 connections by 2 minutes.  What's going on here?  If <em>somebody</em> wanted to get at the SSH accounts, why not go for them straight, rather than accessing the web service only once?  Checking the web access logs might give the answer we're looking for:</p>
<p style="text-align: center;">
<div id="attachment_834" class="wp-caption aligncenter" style="width: 524px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/06-accessed-http-page.png"><img class="size-full wp-image-834 " title="06-accessed-http-page" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/06-accessed-http-page.png" alt="" width="514" height="157" /></a><p class="wp-caption-text">So in that TCP/80 connection....NOTHING was retrieved</p></div>
<p style="text-align: left;">Accessing <em>nothing </em>in that (only) one connection makes this look like a ping of sorts, but we can't be certain.</p>
<p style="text-align: left;">The next thing is to look at what this <em>somebody</em> was doing over the past two weeks!  First we get an idea of the kinds of things that were happening:</p>
<p style="text-align: center;">
<div id="attachment_835" class="wp-caption aligncenter" style="width: 545px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/07a-sshd-invalid-user.png"><img class="size-full wp-image-835 " title="07a-sshd-invalid-user" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/07a-sshd-invalid-user.png" alt="" width="535" height="301" /></a><p class="wp-caption-text">Mostly &quot;Attempts to login using a non-existent user&quot;, ala our dear Mr Force, Brute Force</p></div>
<div id="attachment_836" class="wp-caption aligncenter" style="width: 523px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/07b-ssh-scan.png"><img class="size-full wp-image-836" title="07b-ssh-scan" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/07b-ssh-scan.png" alt="" width="513" height="205" /></a><p class="wp-caption-text">...and &quot;SSH scan&quot;</p></div>
<p style="text-align: left;">What do these SSH scans mean?</p>
<p style="text-align: center;">
<div id="attachment_837" class="wp-caption aligncenter" style="width: 491px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/08-ssh-scan-no-ident-str-received.png"><img class="size-full wp-image-837  " title="08-ssh-scan-no-ident-str-received" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/08-ssh-scan-no-ident-str-received.png" alt="" width="481" height="217" /></a><p class="wp-caption-text">Just means that the SSH handshake was not properly done/completed.</p></div>
<p style="text-align: left;">Since we already know that this is a brute force attempt, judging by the frequency of the failed SSH handshakes per day we can assume for now that they're just resulting from either the connections being blocked, or just "normal" failures in the midst of thousands of attempts.  More can be done to confirm this by zooming into the times where these errors occur, but let's say we're not interested in confirming this fact for now.</p>
<p style="text-align: left;">Looking at the nature of the attack provides some clues on the tools being used too.  For that we extract some stats concerning the tool's attack:</p>
<p style="text-align: center;">
<div id="attachment_838" class="wp-caption aligncenter" style="width: 548px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/09-targeted-ssh-user-counts.png"><img class="size-full wp-image-838 " title="09-targeted-ssh-user-counts" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/09-targeted-ssh-user-counts.png" alt="" width="538" height="313" /></a><p class="wp-caption-text">Extracting and counting targeted SSH userids show that 473 userids are attempted in a range from 1 to 21 times each</p></div>
<p style="text-align: center;">
<div id="attachment_839" class="wp-caption aligncenter" style="width: 491px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/11-distribution-first-occurrences-targeted-users.png"><img class="size-full wp-image-839  " title="11-distribution-first-occurrences-targeted-users" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/11-distribution-first-occurrences-targeted-users.png" alt="" width="481" height="132" /></a><p class="wp-caption-text">First occurrence of each targeted userid is spread out fairly evenly throughout the time period...</p></div>
<div id="attachment_840" class="wp-caption aligncenter" style="width: 491px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/12-distribution-last-occurrences-targeted-users.png"><img class="size-full wp-image-840  " title="12-distribution-last-occurrences-targeted-users" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/12-distribution-last-occurrences-targeted-users.png" alt="" width="481" height="126" /></a><p class="wp-caption-text">...and last occurrences of each userid being fairly even throughout too.</p></div>
<p style="text-align: left;">More stats would be needed depending on the theory you're trying to prove/disprove, but you get the picture.</p>
<p style="text-align: left;">One of the things I usually would want to see is the list of userids used to brute force.  In this case, it looks like a predominantly Japanese/Chinese wordlist/namelist being used.  Interesting.</p>
<p style="text-align: center;">
<div id="attachment_841" class="wp-caption aligncenter" style="width: 624px"><a href="http://blog.rayfoo.info/wp-content/uploads/2011/04/14-targeted-usernames.png"><img class="size-full wp-image-841 " title="14-targeted-usernames" src="http://blog.rayfoo.info/wp-content/uploads/2011/04/14-targeted-usernames.png" alt="" width="614" height="360" /></a><p class="wp-caption-text">Am I Japanese?  Am I Chinese? <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p></div>
<p>Maybe I should start blogging in other languages to see what kind of brute force wordlists turn up <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>For now, in any case, <span style="color: #ff0000;"><strong>122.166.127.116 (abts-kk-static-116.127.166.122.airtelbroadband.in), I AM WATCHING YOU</strong></span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2011/04/profiling-of-persistent-sshd-brute-force-attack/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic monitoring and restarting of internet router</title>
		<link>http://blog.rayfoo.info/2010/08/automatic-monitoring-and-restarting-of-internet-router</link>
		<comments>http://blog.rayfoo.info/2010/08/automatic-monitoring-and-restarting-of-internet-router#comments</comments>
		<pubDate>Sat, 07 Aug 2010 19:03:51 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[CC]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[Hack a Day]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[lazy]]></category>
		<category><![CDATA[power cycle]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Tonido]]></category>
		<category><![CDATA[Tonido plug]]></category>
		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=710</guid>
		<description><![CDATA[My internet connection goes down periodically, and I used to have to power cycle the router in order to fix that.  When it started to become too frequent it posed a problem, since I'm too lazy to keep going to the room (my wife too) to restart it.  There's also the option of restarting the [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_713" class="wp-caption alignright" style="width: 273px"><a href="http://www.tonidoplug.com/"><img class="size-full wp-image-713 " title="tonido_plug_logo" src="http://blog.rayfoo.info/wp-content/uploads/2010/08/tonido_plug_logo.jpg" alt="" width="263" height="76" /></a><p class="wp-caption-text">Obligatory blog post graphic, to make this more &quot;interesting&quot; <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />   Meanwhile, check out the really nice Tonido Plug at http://www.tonidoplug.com/</p></div>
<p>My internet connection goes down periodically, and I used to have to power cycle the router in order to fix that.  When it started to become too frequent it posed a problem, since I'm too lazy to keep going to the room (my wife too) to restart it.  There's also the option of restarting the router via the web admin interface, but it required me to login, click to the page for restarting, and click "restart"!  Very complicated indeed for lazy people.</p>
<p>Inspired by this <a href="http://hackaday.com/2010/06/29/power-cycling-a-problematic-modem/">hack (Hack a Day)</a> where the guy automated the physical power cycling process, I decided to automate mine too.  Since I have a <a href="http://www.tonidoplug.com/">Tonido plug</a> which is almost always on, and I've just learnt Python too, I decided to go the scripting method.  As they say: to a man with a hammer, everything looks like a nail <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>A couple of lessons learnt</h2>
<p>I was caught by surprise by when reproducing the login and restart sequence exactly didn't work, and I went so far as to reproduce ALL the requests made by a "normal human".  It turned out (after 2 hours and a shower break) that things worked just fine when I simply converted the minimally needed POST parameters to GET parameters.  Nice classic web application hacking trick learnt from my old job as a web application ethical hacker I'd say.</p>
<p>Also, the restart sequence for my router turned out to not only need the form "POST" to request a restart, but also a subsequent request for the "restarting now" status page, interesting...</p>
<h2>Download</h2>
<p>Note that before you use this, some reverse engineering of the web application calls is needed, and some Python coding too.  You have been forewarned!  Also, I'm not responsible for this script causing you direct/indirect damage in any way, so don't come crying when your lawnmower starts to act crazy because you installed this script.  The script is released under the <a href="http://creativecommons.org/licenses/GPL/2.0/">GPL</a>, and can be <a href="http://blog.rayfoo.info/wp-content/uploads/2010/08/internet_connection_monitor-rel.zip">downloaded here</a>.</p>
<h2>How to install/use</h2>
<ul>
<li>Edit <span style="color: #00ffff;">'router_host': '10.0.0.1',</span> in line 8</li>
<li>Reverse engineer the web admin login and restart sequence, see what you need.  I used tools like a <a href="http://en.wikipedia.org/wiki/Proxy_server#Transparent_and_non-transparent_proxy_server">transparent proxy</a> (<a href="http://portswigger.net/suite/">Burp Suite</a>), notepad and some brain grease.</li>
<li>Hack the <span style="color: #00ffff;">restart_router()</span> (lines 43-73) function in the python script according to your needs (you're on your own here...  Alternatively you could offer me a good amount of Coke/chips for me to help you with the reverse engineering/coding somehow <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</li>
<li>Copy into the Tonido plug's /root directory (assume running as root, for simplicity's sake)</li>
<li>SSH into the Tonido plug as root</li>
<li><span style="color: #339966;"># chmod 400 /root/internet_connection_monitor.py</span></li>
<li><span style="color: #339966;"># crontab -e</span></li>
<li>Add in this line: (makes the script run in the background, 4 minutes after every tonido plug reboot to give the router time to start up)<br />
<span style="color: #339966;">@reboot sleep 4m &amp;&amp; /usr/bin/python /root/internet_connection_monitor.py &amp;</span></li>
<li>Press Alt-X, then "y" to save the new crontab</li>
<li>Reboot the Tonido plug</li>
<li>Profit!</li>
</ul>
<h2>What are the risks to note</h2>
<p>The script basically is a hardcoded piece of info revealing the password and sequence to your login/router's workings! Make sure the script is chmod'ed properly, and isn't accessible via Tonido's interfaces.  For me I don't have this problem, since I don't allow connecting to my Tonido from outside anyway, and people will have to brute force ssh public keys to get in...</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/08/automatic-monitoring-and-restarting-of-internet-router/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visualizing sshd brute-force attempts (part 2)</title>
		<link>http://blog.rayfoo.info/2010/06/visualizing-sshd-brute-force-attempts-part-2</link>
		<comments>http://blog.rayfoo.info/2010/06/visualizing-sshd-brute-force-attempts-part-2#comments</comments>
		<pubDate>Wed, 02 Jun 2010 16:42:57 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[afterglow]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[graphviz]]></category>
		<category><![CDATA[log analysis]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[Splunk]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=581</guid>
		<description><![CDATA[It's always better to Read The Fine Manual (or run perl afterglow.pl -h for the more updated helpfile)...though it's not really that well documented  Afterglow allows for two column inputs, rather than us having to do weird tricks to make them 3-column. (Note to self: get the raw data with fields in the order that [...]]]></description>
			<content:encoded><![CDATA[<p>It's always better to Read The Fine <a href="http://afterglow.sourceforge.net/manual.html#6">Manual</a> (or run <span style="color: #339966;">perl afterglow.pl -h</span> for the more updated helpfile)...though it's not really <em>that</em> well documented <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />   Afterglow allows for two column inputs, rather than us having to do weird tricks to make them 3-column.</p>
<p>(Note to self: get the raw data with fields in the order that you want where possible/faster, rather than pumping it through <span style="color: #339966;">sed</span>.  Makes for good practice though.)</p>
<p>Using the csv file containing userids (visualized in yellow) and IPs (visualized in green) over the past few months from Splunk, here're the results of some of the experiments.</p>
<p>Oh, for the Windows users, you can use <span style="color: #339966;">type</span> instead of <span style="color: #339966;">cat</span> <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>First test using <a href="http://www.graphviz.org/About.php">GraphViz's</a> neato to layout:</p>
<p style="text-align: center;"><span style="color: #339966;">perl afterglow.pl -b 1 -i &lt;infile&gt; -c color.properties -t | neato -Tgif -o output.gif</span></p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="http://lh4.ggpht.com/_evPUEWAwFrY/TAaB9H39-rI/AAAAAAAAI_E/bjhxhWE5vUc/test-neato.png"><img class="    " title="test afterglow neato" src="http://lh4.ggpht.com/_evPUEWAwFrY/TAaB9H39-rI/AAAAAAAAI_E/bjhxhWE5vUc/s400/test-neato.png" alt="" width="400" height="356" /></a><p class="wp-caption-text">Huge, but better visualized with -e 5 option (Resulting image for that is too huge to upload though <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ).  Note the single IP in the middle (the yellow explosion) that had been trying a LOT of userids to date.</p></div>
<p>Second test using fdp:</p>
<p style="text-align: center;"><span style="color: #339966;">perl afterglow.pl -b 1 -i &lt;infile&gt; -c color.properties -t | fdp -Tgif -o output.gif</span></p>
<div class="wp-caption aligncenter" style="width: 226px"><a href="http://lh6.ggpht.com/_evPUEWAwFrY/TAaCCQCGs8I/AAAAAAAAI_I/Sogy7NxglyE/test-fdp.png"><img title="test afterglow fdp" src="http://lh6.ggpht.com/_evPUEWAwFrY/TAaCCQCGs8I/AAAAAAAAI_I/Sogy7NxglyE/s400/test-fdp.png" alt="" width="216" height="400" /></a><p class="wp-caption-text">fdp doesn&#39;t seem to be well suited for this</p></div>
<p>Third test using sfdp:</p>
<p>No command here, you should have noticed the pattern from the first two...</p>
<div class="wp-caption aligncenter" style="width: 410px"><a href="http://lh5.ggpht.com/_evPUEWAwFrY/TAaCESgte6I/AAAAAAAAI_M/Z-jVk3Xf3AE/test-sfdp.png"><img title="test afterglow sfdp" src="http://lh5.ggpht.com/_evPUEWAwFrY/TAaCESgte6I/AAAAAAAAI_M/Z-jVk3Xf3AE/s400/test-sfdp.png" alt="" width="400" height="394" /></a><p class="wp-caption-text">_even_ less suited for this type of data...</p></div>
<p>Last test using twopi:</p>
<p>According to the <a href="http://www.graphviz.org/About.php">GraphViz</a> site, twopi's more suited for visualizing stuff like telecommunications flows.</p>
<div class="wp-caption aligncenter" style="width: 386px"><a href="http://lh4.ggpht.com/_evPUEWAwFrY/TAaCFUsQLcI/AAAAAAAAI_Q/9Y9wHwDpzrI/test-twopi.png"><img title="test afterglow twopi" src="http://lh4.ggpht.com/_evPUEWAwFrY/TAaCFUsQLcI/AAAAAAAAI_Q/9Y9wHwDpzrI/s400/test-twopi.png" alt="" width="376" height="400" /></a><p class="wp-caption-text">twopi</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/06/visualizing-sshd-brute-force-attempts-part-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Splunk: SSHD</title>
		<link>http://blog.rayfoo.info/2010/03/fun-with-splunk-sshd</link>
		<comments>http://blog.rayfoo.info/2010/03/fun-with-splunk-sshd#comments</comments>
		<pubDate>Sat, 13 Mar 2010 11:02:20 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[log analysis]]></category>
		<category><![CDATA[MaxMind]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Splunk]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=489</guid>
		<description><![CDATA[Thought I'd share a bit on the tip of the iceberg, on what can be done with Splunk.  Linux command line tools are still much needed for raw log analysis (since we can't have the luxury of having a Splunk installation around and ready whenever we need it), but if setup and running properly, Splunk [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-498" title="splunk search" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-search1.png" alt="" width="164" height="38" />Thought I'd share a bit on the tip of the iceberg, on what can be done with Splunk.  Linux command line tools are still much needed for raw log analysis (since we can't have the luxury of having a Splunk installation around and ready whenever we need it), but if setup and running properly, Splunk can be pretty helpful (and not to mention faster) for some things.</p>
<p>(This post is pretty unpolished, partly because I can't be bothered to fiddle around with fitting the search strings into the width of the post, etc.  Nonetheless,  comments/discussions are always welcome heh)</p>
<p>One of my favourite tasks with log analysis is to get information on those people/bots which are brute forcing SSHD, so let's start with SSH attacks as an example.<span id="more-489"></span></p>
<h2>Prerequisites</h2>
<p>Before we start off, we'll need Splunk setup to be monitoring the appropriate logfiles.  I configured and run the <a href="http://www.splunkbase.com/apps/All/4.x/app:Splunk+for+OSSEC+(Splunk+v4+version)">OSSEC</a> and <a href="http://www.splunkbase.com/apps/All/4.x/app:Splunk+for+Unix+and+Linux">Linux</a> apps for Splunk, so that the data inputs are taken care of for me.  If you don't want to run these apps, just make sure you index the /var/log and OSSEC alert logs locations.  If you want to do the geolocation stuff the the <a href="http://www.splunkbase.com/apps/All/4.x/Add-On/app:Geo+Location+Lookup+Script">MaxMind</a> app for Splunk would be needed too.</p>
<h2>List of SSH attacks</h2>
<p>Let's start off with a simple query to see the list of previous SSH attacks:</p>
<pre style="text-align: center;"><span style="color: #00ff00;">source=*auth* sshd invalid user from</span></pre>
<p>Using this search string with the needed time range set shows a pretty graph of how many attacks we've got over time, along with the list of log entries for the attack.</p>
<div id="attachment_499" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-1.png"><img class="size-medium wp-image-499" title="splunk listing of sshd attacks" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-1-300x149.png" alt="" width="300" height="149" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>Seems that the attacks everyday are few, probably due to OSSEC's active responses.  A quick search would confirm that OSSEC is blocking the offending hosts.</p>
<pre style="text-align: center;"><span style="color: #00ff00;">sourcetype="ossec_alerts" </span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;">action="SSHD brute force trying to get access to the system."</span></pre>
<div id="attachment_507" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-2.png"><img class="size-medium wp-image-507" title="splunk ossec active responses" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-2-300x146.png" alt="" width="300" height="146" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<h2>Drilling Down</h2>
<p>Now we know that the attacks were especially active on the 22nd Feb, and OSSEC was responding correctly by blocking them off.  Why the large numbers then?  Was it because the attacks were from different IP addresses, or that that IP address was particularly persistent that day?  We could find out by getting more information on the src_ips for the time range in question.  First we click on the bar for the 22nd Feb, then the src_ip field in the sidebar.</p>
<div id="attachment_509" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-31.png"><img class="size-medium wp-image-509" title="splunk ssh ossec src ips" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-31-300x187.png" alt="" width="300" height="187" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>With the time range fixed onto what we're interested in looking at, and the src_ip field showing the unique source IPs that were blocked, the results show that it was most likely a persistent attack by these two IPs.  A quick check with the auth logs tell the same story:</p>
<div id="attachment_510" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-4.png"><img class="size-medium wp-image-510" title="splunk sshd brute force src ips" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-4-300x236.png" alt="" width="300" height="236" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<h2>GeoIP Lookups</h2>
<p>Now that we know which two IPs were actively poking around, let's map them to a location.  The MaxMind app for Splunk helps nicely for this task.</p>
<pre style="text-align: center;"><span style="color: #00ff00;">source=*auth* sshd invalid user from | </span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;">lookup geoip clientip as src_ip</span></pre>
<div id="attachment_511" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-5.png"><img class="size-medium wp-image-511" title="splunk srcip geoiplookup" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-5-300x210.png" alt="" width="300" height="210" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>The app and local geoip database does the lookups for us nicely, mapping to geolocation information like country, city, latitude, longtidue and region.  The country information is available for most/all at least, the rest would be put in if available it seems.</p>
<h2>List/Count of attacked userids for SSH</h2>
<p>The strings for searching for this depends on your SSHD config, but for me searching for the invalid users is enough.</p>
<pre style="text-align: center;"><span style="color: #00ff00;">source=*auth* sshd invalid user from | </span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;">rex field=_raw "Invalid user (?&lt;atk_user_id&gt;\S+) from "</span></pre>
<p>Searching/sorting by the atk_user_id field would show us the attacked userids.  Click on the "Events Table" button to show the table of results with only the fields that you've selected.</p>
<div id="attachment_512" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-6.png"><img class="size-medium wp-image-512" title="splunk searching for attacked sshd userids" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-6-300x153.png" alt="" width="300" height="153" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>If we want a sorted list of the top attacked userids, pipe the search string to a top command.</p>
<pre style="text-align: center;"><span style="color: #00ff00;">source=*auth* sshd invalid user from | rex field=_raw </span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;">"Invalid user (?&lt;atk_user_id&gt;\S+) from "</span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;"> | top atk_user_id limit=1000</span></pre>
<p>The Results Table should show automatically for this search.</p>
<div id="attachment_513" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-7.png"><img class="size-medium wp-image-513" title="slunk sshd userids brute forced" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-7-300x241.png" alt="" width="300" height="241" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>Maybe we'd like an alphabetical list instead, so we just pipe the search to a sort command:</p>
<pre style="text-align: center;"><span style="color: #00ff00;">source=*auth* sshd invalid user from | rex field=_raw </span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;">"Invalid user (?&lt;atk_user_id&gt;\S+) from "</span></pre>
<pre style="text-align: center;"><span style="color: #00ff00;"> | top atk_user_id limit=1000 | sort atk_user_id</span></pre>
<div id="attachment_518" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-8.png"><img class="size-medium wp-image-518" title="splunk sshd userids alphabetical sort" src="http://blog.rayfoo.info/wp-content/uploads/2010/03/splunk-sshd-8-300x221.png" alt="" width="300" height="221" /></a><p class="wp-caption-text">Click to enlarge</p></div>
<p>Alright, that's all for now <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/03/fun-with-splunk-sshd/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH brute force namelist</title>
		<link>http://blog.rayfoo.info/2010/02/ssh-brute-force-namelist</link>
		<comments>http://blog.rayfoo.info/2010/02/ssh-brute-force-namelist#comments</comments>
		<pubDate>Wed, 24 Feb 2010 15:59:56 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=441</guid>
		<description><![CDATA[It's weird, but therapeutic to see what kind of data has been gathered from the public server... Today's feature: the list of user IDs that has been used to attempt brute forcing on ssh till date! *drum roll* From the looks of this list, some of these people/botnet operators think I'm German/Spanish/Japanese.  Really weird, or [...]]]></description>
			<content:encoded><![CDATA[<p>It's weird, but therapeutic to see what kind of data has been gathered from the public server...</p>
<p>Today's feature: the list of user IDs that has been used to attempt brute forcing on ssh till date! *drum roll*</p>
<p>From the looks of this list, some of these people/botnet operators think I'm German/Spanish/Japanese.  Really weird, or these botnets are just whacking away without using the correct wordlist.</p>
<pre class="brush: plain; title: ; notranslate">00089 0123456789 a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa Aadolf Aaliyah Aamu Aapeli aaron Aaron aarti abby abcs abel admin administrator adolfo agata alberto alexandre alexis alias amministratore ana andrew angel anthony anti art arthur backuppc bang bb benjie bind bob bond brian caja cameron candie candy carey cargan carina carissa carl carla carlo carrie cgarcia cgi-bin cis42 cisco clement conter coo cristi cristian cristina cristinel cs cvsroot da damian dasusr1 dati dave db2fenc1 db2inst1 desiree director djeli dk dke dl dle dm dmaac dme dmitra documenti domin Doo doris dragon droguri ebony ecampaig echo ed enzo fax fedora felipe fido finance foc francois ftp ftpuser gary ghost goncalo grant gt05 guest haiduc haitac hammer happiness hugo iasiasur ibiza information informix ionita ipbx jay jd jean joan johan joomla joseluis julius julius123 jun jurca kato kidskhan li71-183 li71-183.members.linode library lord ls lschmidt lscsymbiosis lsnoxell lucas lucia m magnos marian mark marketing marta mathis medina mercedes miguel mike miranda mireya mlmb monica montrelle myky mythtv nagios nana natalia natasha nathan nelson nicoara nlopez no nrg nu office offsite operatore oracle owen pamela pgsl plcmspip PlcmSpIp porno pos post postgres power powered prchal prueba pubblico public q1 r00t raimundo ram reboot recepcion recruit rene ricardo roby rocio Root root123 roto ruut sales samba sami scan se sebastian services sims sims2 sistema skbae skin skipe skype skywalker slayer spam sshadmin sshdu sss staff stan std015 stephanie stone stud student student1 sue swadok sybille teamspeak TeamSpeak teapa tech ted telegest temp test test1 theo thomas thx1138 tom tomcat tony trash ts tss upload user user1 utente ven vh vic vicky victor violet vn volume vova webadmin wen william WinD3str0y work xwang xwp yamazaki yes zoro</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/02/ssh-brute-force-namelist/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH brute force connection attempts #fail</title>
		<link>http://blog.rayfoo.info/2009/10/ssh-brute-force-connection-attempts-fail</link>
		<comments>http://blog.rayfoo.info/2009/10/ssh-brute-force-connection-attempts-fail#comments</comments>
		<pubDate>Tue, 20 Oct 2009 02:18:17 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[audit trail]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=273</guid>
		<description><![CDATA[Collected these over the past few months, reverse chronological order. Seeing different machines attempting to connect hundreds of times a day each is just, wow. Some might say that a SSH blacklist daemon might help, but it only increases the time taken for a brute force attempt, and is of no use against a botnet [...]]]></description>
			<content:encoded><![CDATA[<p>Collected these over the past few months, reverse chronological order.  Seeing different machines attempting to connect <strong>hundreds</strong> of times a day each is just, wow.</p>
<p>Some might say that a SSH blacklist daemon might help, but it only increases the time taken for a brute force attempt, and is of no use against a botnet trying to brute force the ssh login.</p>
<p>There are plenty of things that can be done to lock down the ssh server, and restricting it to only publickey is by far one of the most effective, counting that the resource (the server) you're protecting is pretty important.<br />
<span id="more-273"></span><br />
Plenty of interesting IPs/hosts in this list, take a look if you're really interested, heh. <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="color:green;">reverse mapping checking getaddrinfo for <span style="color: #ff0000;">93.184.69.3.vnet.sk [93.184.69.3]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">237 time(s)</span><br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">95-128-245-59.wiseweb.ru [95.128.245.59]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">567 time(s)</span><br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">h-69-3-215-11-static.lsanca54.covad.net [69.3.215.11]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">543 time(s)</span><br />
reverse mapping checking getaddrinfo for iodc-74-206-96-142.ioconnect.net [74.206.96.142] failed - POSSIBLE BREAK-IN ATTEMPT! : 6 time(s)<br />
reverse mapping checking getaddrinfo for 202-153-191-246-static.unigate.net.tw [202.153.191.246] failed - POSSIBLE BREAK-IN ATTEMPT! : 5 time(s)<br />
reverse mapping checking getaddrinfo for corporat065-167059038.sta.etb.net.co [65.167.59.38] failed - POSSIBLE BREAK-IN ATTEMPT! : 19 time(s)<br />
reverse mapping checking getaddrinfo for ev1s-75-125-43-50.theplanet.com [75.125.43.50] failed - POSSIBLE BREAK-IN ATTEMPT! : 46 time(s)<br />
reverse mapping checking getaddrinfo for hst13.migrateplans.com [72.46.131.181] failed - POSSIBLE BREAK-IN ATTEMPT! : 68 time(s)<br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">bzq-179-135-183.static.bezeqint.net [212.179.135.183]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">298 time(s)</span><br />
reverse mapping checking getaddrinfo for host112163.metrored.net.mx [200.77.249.163] failed - POSSIBLE BREAK-IN ATTEMPT! : 8 time(s)<br />
Address 98.126.208.50 maps to customer.krypt.com, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 50 time(s)<br />
reverse mapping checking getaddrinfo for corporat200-7543230.sta.etb.net.co [200.75.43.230] failed - POSSIBLE BREAK-IN ATTEMPT! : 97 time(s)<br />
Address 61.168.44.5 maps to pc5.zz.ha.cn, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 50 time(s)<br />
reverse mapping checking getaddrinfo for ip36.70.inetmar.com [92.42.36.70] failed - POSSIBLE BREAK-IN ATTEMPT! : 50 time(s)<br />
Address 218.28.20.135 maps to pc0.zz.ha.cn, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 168 time(s)<br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">187-5-142-129.bnut3700.e.brasiltelecom.net.br [187.5.142.129]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">478 time(s)</span><br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">cliente-13108.iberbanda.es [82.198.115.50] </span>failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">324 time(s)</span><br />
reverse mapping checking getaddrinfo for <span style="color: #ff6600;">host-203-92-76-19.lga.net.sg [203.92.76.19] </span>failed - POSSIBLE BREAK-IN ATTEMPT! : 5 time(s)<br />
reverse mapping checking getaddrinfo for <span style="color: #ff0000;">229.1.163.220.broad.km.yn.dynamic.163data.com.cn [220.163.1.229]</span> failed - POSSIBLE BREAK-IN ATTEMPT! : <span style="color: #ff0000;">240 time(s)</span><br />
reverse mapping checking getaddrinfo for 56h29.xjtu.edu.cn [202.117.56.29] failed - POSSIBLE BREAK-IN ATTEMPT! : 54 time(s)<br />
reverse mapping checking getaddrinfo for 202.53.76.24.nettlinx.com [202.53.76.24] failed - POSSIBLE BREAK-IN ATTEMPT! : 45 time(s)<br />
Address 218.28.103.202 maps to pc0.zz.ha.cn, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 373 time(s)<br />
Address 72.9.228.73 maps to marisil.org, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 6 time(s)<br />
Address 72.9.228.73 maps to marisil.org, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! : 6 time(s)<br />
reverse mapping checking getaddrinfo for 74.126.30.110.static.a2webhosting.com [74.126.30.110] failed - POSSIBLE BREAK-IN ATTEMPT! : 15 time(s)<br />
reverse mapping checking getaddrinfo for 74.126.30.110.static.a2webhosting.com [74.126.30.110] failed - POSSIBLE BREAK-IN ATTEMPT! : 15 time(s)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2009/10/ssh-brute-force-connection-attempts-fail/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Futile SSH connection attempts</title>
		<link>http://blog.rayfoo.info/2009/09/futile-ssh-connection-attempts</link>
		<comments>http://blog.rayfoo.info/2009/09/futile-ssh-connection-attempts#comments</comments>
		<pubDate>Sun, 06 Sep 2009 17:32:54 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=54</guid>
		<description><![CDATA[It's pretty funny to see how people try to brute force connect to the SSH daemon on the server: multiple attempts to connect unsuccessfully showing up like a sore thumb on the logs. But hey, stop wasting your time and giving me entertainment like this already, you MUST have the correct private key in order [...]]]></description>
			<content:encoded><![CDATA[<p>It's pretty funny to see how people try to brute force connect to the SSH daemon on the server: multiple attempts to connect unsuccessfully showing up like a sore thumb on the logs.</p>
<p>But hey, stop wasting your time and giving me entertainment like this already, you MUST have the correct private key in order to connect via SSH.  Slightly more inconvenient than using passwords, but it takes a load off my mind knowing that brute forcing passwords is simply impossible, and it would take the SSH keys to be compromised in order to get in (which won't be worth the cost/effort anyway).</p>
<p>Maybe I will start listing these jokers in a wall of shame or something.  Maybe.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2009/09/futile-ssh-connection-attempts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

