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

<channel>
	<title>Daniel Hall&#039;s Website &#187; Security</title>
	<atom:link href="http://www.danielhall.me/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danielhall.me</link>
	<description>Because the Internet doesn&#039;t have enough opinions already</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:52:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Protecting Email with DKIM</title>
		<link>http://www.danielhall.me/2010/07/protecting-email-with-dkim/</link>
		<comments>http://www.danielhall.me/2010/07/protecting-email-with-dkim/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 12:57:19 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Phishing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=629</guid>
		<description><![CDATA[<p>One of the problems with the email and the protocols used to transfer it (SMTP) is that they were designed long ago when the Internet was a much friendlier place. When SMTP was designed it was assumed that other hosts on the Internet could be trusted. This is particularly visible in the configuration of relays [...]]]></description>
			<content:encoded><![CDATA[<p>One of the problems with the email and the protocols used to transfer it (SMTP) is that they were designed long ago when the Internet was a much friendlier place. When SMTP was designed it was assumed that other hosts on the Internet could be trusted. This is particularly visible in the configuration of relays where the sender doesn&#8217;t have to be identified. A mail relay will accept mail from any server regardless of where the mail appears to be coming from.</p>
<p>To attempt to rectify this SPF was created. To setup SPF you add either a TXT or an SPF record to the DNS zone you will be sending from. This record defines which servers are allowed to send mail that is coming from that domain. So on my domain danielhall.me I could publish an SPF record that says only my mail server is allowed to send mail that ends in @danielhall.me. Any mailservers receiving mail that is from my domain but not coming from an address listed in my SPF record can see that the mail is likely forged and throw it away. SPF works well in most situations but fails at a very common use case. If someone I send mail to tries to forward it to another address using an automatic process (no clicking forward in their client) then the mail will appear to come from my domain when it gets to the user it was forwarded to, however it will have came from the original recipients mailserver.</p>
<p>DKIM solves this problem by giving each sending mailserver a cryptographic key pair. The public keys is then published in a DNS record in that zone and stores the private key somewhere safe on the server. The server then proceeds to sign the headers (especially the From: header) and the body of all outgoing emails. This signature is then attached to the email as an extra header. When the receiving server get the email it gets the signature and uses that along with the list of signed headers to verify the signature against the public key of the signing domain. This means as long as the mail has passed through an authorised mailserver at any point it will be considered valid.</p>
<p>Setting up a DKIM is relatively simple process. You will need access to the  zone records for your domain and access to the configuration of all the mailservers which all mail originating at your domain passes through. You also need to be aware that signing mail makes it slightly more processor intensive to send an email. If you send a large amount of email this difference could be quite significant. If you&#8217;re using sendmail you may be able to alleviate it by switching to a less resource hungry MTA like Exim. You should also note that in some configurations DKIM can not be setup. For example if you use masquerading in sendmail DKIM will always fail as sendmail will modify the from header after signing.</p>
<p>Ultimately DKIM is a good move for the internet community at large, especially when combined with SPF. DKIM mail is assured to come from the sender and can be cryptographically proven so. While it does take more take a little more effort to setup and maintain it assures mail from your domain is secure and can be assured to have come from you or your company. Ultimately DKIM can protect your company against phishing attempts and boost your spam scores.</p>
<p><strong>Random thought:</strong> What would Email look like if it were designed today?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/07/protecting-email-with-dkim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cross-Domain AJAX</title>
		<link>http://www.danielhall.me/2010/05/cross-domain-ajax/</link>
		<comments>http://www.danielhall.me/2010/05/cross-domain-ajax/#comments</comments>
		<pubDate>Tue, 04 May 2010 21:21:58 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=499</guid>
		<description><![CDATA[<p>When making an xmlhttprequest from a website the browser will restrict you to the site from which the script came. This is a security precaution. If sites were able to tell the browser to make requests from other domains then they would be able to DDOS a site with a users browser. There are legitimate [...]]]></description>
			<content:encoded><![CDATA[<p>When making an xmlhttprequest from a website the browser will restrict you to the site from which the script came. This is a security precaution. If sites were able to tell the browser to make requests from other domains then they would be able to DDOS a site with a users browser. There are legitimate reasons to make requests to other sites though.</p>
<p>Many sites offer web services, xml data and json encoded data. These can provide almost anything from the weather, to search results, to advanced APIs. To use these services from your site using javascript you&#8217;ll have to employ one of the methods below.</p>
<h1>Signing Javascript</h1>
<p>Firefox allows you to sign your Javascript and place it in a jar file. This will give your code more privileges, You can also request these permissions explicitly without having your code signed, but having a dialog box appear for every AJAX request could get very tiring for the user. Another problem with this approach is that it isn&#8217;t documented very well and its Firefox specific. The first link in the references section deals with this method.</p>
<h1>Access-Control Headers</h1>
<p>This is the w3 approved method of allowing a client from another domain to access your web service. It is a server side method and requires no changes on the client to implement. This is both and advantage and a disadvantage. If you have control over the server then this method is simple, otherwise (for sites such as Yahoo API or other public services) you will not be able to implement this. It should also be noted that this was implemented in Firefox 3.5 so it can&#8217;t be used with earlier versions, or other browsers.</p>
<p>To use this method you tell your service to output extra headers that tell the browser whether access was allowed or denied.</p>
<h1>Flash Enabled xmlhttprequest</h1>
<p>This method involves using an invisible flash player to perform the actual request then handing the result back to the Javascript for processing. Flash still performs permission checking by looking for a /crossdomain.xml file in the root directory of the domain the request is being made to. There are several libraries that implement this approach and a few even implement in a way which is compatible with xmlhttprequest. One downside is this Flash is required, though recently Flash is required for several major sites and most browsers will have it installed.</p>
<h1>Add Sites To Trusted Zone</h1>
<p>Internet Explorer allows and denies cross-domain based xmlhttprequests based on the security setting. This approach is likely not going to be used on the Internet as it requires user interaction and is Internet Explorer specific. On a corporate Intranet this is slightly less difficult but not by much.</p>
<h1>Apache mod_proxy</h1>
<p>With this method you use the same server you shared the page from to proxy the requests automatically to the server with the data you&#8217;re fetching. For this to work your version of Apache has to be compiled with proxy support or you need to have the mod_proxy dso loaded. This method increases the latency of requests as they must first go via your server. It should also be noted that this cannot be implemented in .htaccess file and must be done in the main configuration.</p>
<h1>Manual Proxy</h1>
<p>If you don&#8217;t have control over your servers configuration then you can mimic the above method by writing a script that forwards the variables required and forwards back the data. This approach can even be more preferable than the above method as it allows you to preprocess the variables and cache the data if required.</p>
<h1>References</h1>
<p><a href="http://www.mozilla.org/projects/security/components/signed-scripts.htm">http://www.mozilla.org/projects/security/components/signed-scripts.htm</a>l</p>
<p><a href="http://dev.w3.org/2006/waf/access-control/">http://dev.w3.org/2006/waf/access-control/</a></p>
<p><a href="http://developer.yahoo.com/javascript/howto-proxy.html">http://developer.yahoo.com/javascript/howto-proxy.html</a></p>
<p><a href="https://developer.mozilla.org/En/HTTP_Access_Control">https://developer.mozilla.org/En/HTTP_Access_Control</a></p>
<p><a href="http://ejohn.org/blog/cross-site-xmlhttprequest/">http://ejohn.org/blog/cross-site-xmlhttprequest/</a></p>
<p><a href="http://ajaxpatterns.org/XMLHttpRequest_Call">http://ajaxpatterns.org/XMLHttpRequest_Call</a></p>
<p><a href="http://ajaxpatterns.org/Flash-enabled_XHR">http://ajaxpatterns.org/Flash-enabled_XHR</a></p>
<p><strong>Random Thought:</strong> Can you use AJAX to make web applications cleaner?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/05/cross-domain-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using EncFS to encrypt your files</title>
		<link>http://www.danielhall.me/2010/04/using-encfs-to-encrypt-your-files/</link>
		<comments>http://www.danielhall.me/2010/04/using-encfs-to-encrypt-your-files/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:53:38 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=546</guid>
		<description><![CDATA[About EncFS
<p>EncFS is an encrypted filesystem based on FUSE. It transparently encrypts files stored in it and places them on another volume. This is in contrast to block level encrypted filesystems which transparently encrypt the data under the filesystem layer as it is being written to disk. Think of EncFS as a bind mount, except [...]]]></description>
			<content:encoded><![CDATA[<h1>About EncFS</h1>
<p>EncFS is an encrypted filesystem based on FUSE. It transparently encrypts files stored in it and places them on another volume. This is in contrast to block level encrypted filesystems which transparently encrypt the data under the filesystem layer as it is being written to disk. Think of EncFS as a bind mount, except that the source for the mount is encrypted and the place it is mounted to is the only place it is available unencrypted.</p>
<p>The main advantage of EncFS filesystems is that when backing up only the files which have changed need to be backed up. This means it works perfectly with tools such as rsnapshot. Another advantage is that the filesystem doesn&#8217;t need a block of disk allocated to it and will shrink and expand as the files inside change.</p>
<p>Finally because this is all implemented with FUSE it is all done in userspace. No root access is required (apart from setting FUSE up) to create and alter encfs filesystems.</p>
<h2>Setting Up an EncFS Volume</h2>
<p>So the first thing you need to do to setup an encfs volume is to install FUSE and EncFS. If you don&#8217;t have root access you will have to ask your sysadmin to do this for you, otherwise follow your distribution specific method of installing new packages. On Fedora it is called &#8216;fuse-encfs&#8217; and on Debian/Ubuntu its called &#8216;encfs&#8217;. On some older systems users wishing to use FUSE may need to be added to the correct group.</p>
<p>First you need to decide where you will put the encfs volume, and where you&#8217;ll mount it. I usually put mine in /home/daniel/.crypt and mount it to /home/daniel/crypt. But feel free to name it whetever you want. When you&#8217;ve decided run the EncFS with those arguments, for example to use the example I specified it would look like this:</p>
<pre class="brush: plain;">
&lt;daniel@server ~&gt;$ encfs /home/daniel/.crypt /home/daniel/crypt
The directory &quot;/home/daniel/.crypt/&quot; does not exist. Should it be created? (y,n) y
The directory &quot;/home/daniel/crypt&quot; does not exist. Should it be created? (y,n) y
Creating new encrypted volume.
Please choose from one of the following options:
 enter &quot;x&quot; for expert configuration mode,
 enter &quot;p&quot; for pre-configured paranoia mode,
 anything else, or an empty line will select standard mode.
?&gt;

Standard configuration selected.

Configuration finished.  The filesystem to be created has
the following properties:
Filesystem cipher: &quot;ssl/aes&quot;, version 2:2:1
Filename encoding: &quot;nameio/block&quot;, version 3:0:1
Key Size: 192 bits
Block Size: 1024 bytes
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File holes passed through to ciphertext.

Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism.  However, the password can be changed
later using encfsctl.

New Encfs Password:
Verify Encfs Password:
</pre>
<p>As you can see the directories don&#8217;t need to be created first. There is also a prompt for what security settings you want to use. Hitting enter will give you standard settings, but for something more powerful you should hit &#8216;p&#8217; then enter. You can now proceed to place files in /home/daniel/crypt and they will be encrypted and placed into /home/daniel/.crypt. If you don&#8217;t believe me go ahead and check.</p>
<p>See? I told you so. Now you can unmount it using &#8216;fusermount -u /home/daniel/crypt&#8217; and mount it again using <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">encfs /home/daniel/.crypt /home/daniel/crypt and typing your password.</span></p>
<p><strong>Random Thought:</strong> When travelling to other countries, local laws may mean that customs can search your laptop, including encrypted filesystems. You may have to reveal your key, or be arrested.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/04/using-encfs-to-encrypt-your-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Australian Mandatory Internet Filter</title>
		<link>http://www.danielhall.me/2010/04/the-australian-mandatory-internet-filter/</link>
		<comments>http://www.danielhall.me/2010/04/the-australian-mandatory-internet-filter/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 09:39:40 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[The Internet]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[No Clean Feed]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=564</guid>
		<description><![CDATA[<p>I&#8217;m ashamed that in today&#8217;s society I have to begin this post with this paragraph but I have to nonetheless. For the record I am absolutely opposed to child pornography, bestiality, sexual violence and rape. I am abhorred that people are involved in the production and distribution of such material and I strongly feel that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m ashamed that in today&#8217;s society I have to begin this post with this paragraph but I have to nonetheless. For the record I am absolutely opposed to child pornography, bestiality, sexual violence and rape. I am abhorred that people are involved in the production and distribution of such material and I strongly feel that these people need to be brought to justice. I feel strongly that the government needs to implement measures to catch and prosecute these people and to make such material impossible to produce or distribute. I do however believe that the Mandatory Internet Filter as proposed by Steven Conroy is the wrong way to go about this.</p>
<p>The Internet filter, quite simply put is technically infeasible. The filter will work by directing all requests from Australian users towards a site containing RC content to a filtering device. This device then relays all requests to that site to the actual server, unless a requests is made for a blocked page, which will instead return a page indicating the site is blocked. This is similar to the way the firewall in China and other countries with a national Internet filter. This method is effective in that it is often 100% effective (which means that every page on the blocked list is blocked, with no false positives) when done right. There is a problem however, this method does not scale well. If the government were to block a page on a large site (as was attempted to Wikipedia in the UK) then the filter would not be able to handle the load. Secondly it appears to the administrators of that site that all requests are coming from a few IP adresses. This could cause Wikipedia to eventually block all Australians either because the requests will look similar to a DDOS or because they have no way to distinguish between users and need to prevent abuse. Although the filter may be 100% accurate at blocking web traffic it will not be capable of dealing with many other varieties of Internet data.</p>
<p>The proposed filter will only be capable of filtering standard web traffic from web browsers. The Internet consists of a large number of computers talking in any number of protocols. While web traffic is one of these there are many other ways to exchange information. This filter will not be capable of filtering email, bit torrent, edonkey, gnutella, XMPP, DDC, SSH, VPN, TOR and that is only naming a small portion. Many people caught to have been in possession of child pornography and other illegal content are found to have downloaded it via peer to peer technology. This is because standard web traffic makes it easy to trace and identify the owner, where as peer to peer traffic can be hidden much easier. Secondly web traffic can be &#8216;tunnelled&#8217; or hidden inside these other protocols and this way completely bypass the filter. This means anyone with sufficient knowledge or five minutes to learn will be able to configure their PC to hide their data amongst an SSH or VPN connection. These technical arguments come from my experience as a systems Administrator, but there are other arguments not so technical.</p>
<p>Steven Conroy has said that the filter will only deal with RC rated content, however there is no transparency about what will be blocked. The government can&#8217;t publish a list of sites that are blocked because that will effectively give people looking for this content a list of places to find it. Without knowing what sites are being blocked we won&#8217;t know if or when the government decides that they would like to start blocking sites that are debating for or against abortion, euthanasia or any other politically sensitive topic. It may be interesting to know that the definition for RC content includes pages instructing in any crime, which would include euthanasia. A representative for Steven Conroy has specifically stated the filter won&#8217;t be filtering pages related to euthanasia but because of this broad definition it could be changed at any time and we wouldn&#8217;t know until after the material was blocked.</p>
<p>I am a Unix Systems Administrator, and for the reasons listed above, and more covered better by other bloggers, I am opposed to the filter proposed by Senator Steven Conroy and the Labor government. I urge my readers who are also opposed to the filter to write to your local MP, to Senator Conroy, to Tony Smith (Shadow Minister Minister for Broadband, Communications<br />
and the Digital Economy). If all else fails and the Government does not see sense then use your vote. The filter will not work and will waste taxpayer money that could be used in many better ways.</p>
<p><strong>Random Thought:</strong> Will posting instructions about how to bypass the filter be illegal?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/04/the-australian-mandatory-internet-filter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fingerprint readers and PC security</title>
		<link>http://www.danielhall.me/2010/02/fingerprint-readers-and-pc-security/</link>
		<comments>http://www.danielhall.me/2010/02/fingerprint-readers-and-pc-security/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 11:16:34 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Biometrics]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=508</guid>
		<description><![CDATA[How fingerprint readers work
The user sees
<p>You register your fingerprint using the built in reader and it saves it as your password. Next time you go to login you choose your username, swipe your finger and the PC verifies it against the one you scanned last time. If it matches then the computer logs you in.</p>
What [...]]]></description>
			<content:encoded><![CDATA[<h1>How fingerprint readers work</h1>
<h3>The user sees</h3>
<p>You register your fingerprint using the built in reader and it saves it as your password. Next time you go to login you choose your username, swipe your finger and the PC verifies it against the one you scanned last time. If it matches then the computer logs you in.</p>
<h3>What actually happens</h3>
<ol>
<li>You open up the fingerprint reader application on your laptop, it adds hooks into the Windows login system (Credential Providers).</li>
<li>You scan in one or more fingers and register them to your account.</li>
<li>The application stores the fingerprints for later use, some will even <a href="http://www.pcworld.com/article/124978/researcher_hacks_microsoft_fingerprint_reader.html">store them unencrypted</a>.</li>
<li>When the user goes to login next time they select their username and scans a finger.</li>
<li>The fingerprint reader takes the scan and compares it to the previous scan</li>
<li>If the scan matches one of the stored scans then the user is authenticated</li>
</ol>
<h1>Why its not secure</h1>
<p>How often do you write down your password? If you do where would you leave it? Now think about your fingerprint. Where would you leave your fingerprint? In general people don&#8217;t constantly where gloves and end up leaving fingerprints all over the place, on glasses, door handles, keyboards, touch screens and mobiles. It is a little bit harder to copy a fingerprint but security by obscurity is not an excuse. So it can be argued that a password is more secure (in that its harder to obtain) than a fingerprint.</p>
<p>Most fingerprint authentications allow you to use either your fingerprint, or your password. This effectively doubles the possible attack vectors for trying to get into the system. A malicious attacker can now either use a dictionary attack against your password, a fingerprint based attack against the fingerprint reader, or look for holes in either system.</p>
<h1>Why it may actually endanger you</h1>
<p>Do you know how the fingerprint reader is storing your fingerprints? Is it storing them as bitmaps, as a collection of swirls and whorls or as a md5 hash or some key identifiable features? If you can&#8217;t answer that question with 100% certainty then you should be concerned. If someone managed to hack your machine and retrieve bitmaps of your fingerprints then they could use them to open any other fingerprint locks you have, or implicate you in a crime.</p>
<p>Finally if someone is determined enough to break a law to hack your computer they could simply cut off your fingers to gain access to your PC. Of course if the fingerprint sensor has a warmth sensor they might need to microwave them first. I would hope though that you keep something that sensitive or valuable under all sorts on encryption and armed guards.</p>
<p>Don&#8217;t rely on fingerprint readers for added security, that is quite simply not the case. Fingerprint readers are primarily for convenience, and they could put your security and your wellbeing in danger.</p>
<p><strong>Random Thought:</strong> What is this obsession with altering perfectly fine machines to remove an component that never bothers anyone? Dyson has the bladeless fan, and recently we&#8217;re seeing the spokeless bike. Have you ever looked at a fan and said: &#8220;Those blades really make that fan so annoying!&#8221;?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2010/02/fingerprint-readers-and-pc-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cryptographically Secure Random Numbers in Java</title>
		<link>http://www.danielhall.me/2009/09/cryptographically-secure-random-numbers-in-java/</link>
		<comments>http://www.danielhall.me/2009/09/cryptographically-secure-random-numbers-in-java/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 20:58:06 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=367</guid>
		<description><![CDATA[The Random Class
<p>Most people wanting to generate random numbers in Java do something similar to the following:</p>
public static void main(String[] args) {
  Random generator = new Random();
  int randomnumber = generator.nextInt(5) + 1;
  System.out.println(&#34;Dice rolled: &#34; + randomnumber);
}
<p>This is perfectly fine for a simple dice rolling application where there isn&#8217;t going to [...]]]></description>
			<content:encoded><![CDATA[<h1>The Random Class</h1>
<p>Most people wanting to generate random numbers in Java do something similar to the following:</p>
<pre class="brush: java;">public static void main(String[] args) {
  Random generator = new Random();
  int randomnumber = generator.nextInt(5) + 1;
  System.out.println(&quot;Dice rolled: &quot; + randomnumber);
}</pre>
<p>This is perfectly fine for a simple dice rolling application where there isn&#8217;t going to be much effort put into cracking it. For example in this application the only real reason you would bother cracking it would be to show off a neat party trick to your geeky friends. No doubt though the effort wouldn&#8217;t be worth it.</p>
<p>Java states that the Random class and its subclasses must produce predictable results when seeded with the same data. This however is not why this is insecure, and it is useful when testing. The reason that this class is predictable though is the way in which it is seeded. The Random class, in the absence of a seed in its constructor it will seed its random number generator with the current time in milliseconds. This means that if somebody knows the time that the Random object was seeded and has several consecutive bytes of output then they can reasonably predict the next numbers. Once somebody has discovered the seed for the generator all number produced from it can be seen as compromised.</p>
<h1>The SecureRandom Class</h1>
<p>The SecureRandom class is different, it again uses algorithms that when seeded will produce predictable results, but the algorithm is much more complex. It uses a digest algorithm such as SHA-1 on the seed and a counter to generate random data. SHA-1 is much more costly than the simple algorithm used in the Random class and as such it is much harder to brute force.</p>
<p>Its true strength however lies in the method in which it is seeded. The SecureRandom class is seeded using true random data gathered by the operating system. This is data gathered by the OS from sources of true randomisation, such as mouse movements, network packet arrival times, IO statistics and interrupts. On Linux the data is gathered from /dev/random and on Windows via the CryptGenRandom() call in Windows.</p>
<p>When using SecureRandom though you should be aware of a few things:</p>
<ul>
<li>The more random numbers some can get a hold of the more likely they can figure out the seed. You should either throw away the SecureRandom object every now and then or reseed it. Keeping in mind the next point though.</li>
<li>The seeding the generator takes entropy out of the system, if it cannot get any entropy it will block until the system has some. This means if you&#8217;re reseeding the generator too often your program will hang along with anything else on the system requiring entropy.</li>
<li>Don&#8217;t seed the SecureRandom class yourself, unless you are 100% absolutely sure you are seeding it with purely random data, or you are testing and need repeatable results. Whatever you do, don&#8217;t let your testing code leak into a production system.</li>
</ul>
<h1>How to decide</h1>
<p>Generally when you&#8217;re coding you don&#8217;t need secure random numbers. For example if you&#8217;re writing a number guessing game, or a quiz generating program then high quality random numbers aren&#8217;t required. It should be noted though that if money is involved people will often go to greater lengths and a more secure generator will be required, such as in a slot machine.</p>
<p>Again generally if what you are generating is a security token of some sort then you will need a secure generator. For example a session id, a one time password or an encryption key. The exception here is a salt for a password, salts can be generated using predictable entropy sources, even a simple time stamp would work here (especially if your also storing the time stamp to measure password expiry).</p>
<p><strong>Random Thought:</strong> For those of you who don&#8217;t know <a href="http://en.wikipedia.org/wiki/Bruce_Schneier">Bruce Schneier</a> is the <a href="http://www.schneierfacts.com/">Chuck Norris</a> of cryptography.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/09/cryptographically-secure-random-numbers-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up GPG Keys</title>
		<link>http://www.danielhall.me/2009/09/setting-up-gpg-keys/</link>
		<comments>http://www.danielhall.me/2009/09/setting-up-gpg-keys/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 22:00:22 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[GPG]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=336</guid>
		<description><![CDATA[<p>Yesterday you may have read my GPG Symmetric Encryption Guide. The last tip on that page was that you should setup GPG keys and publish them on a keyserver. I say this because publishing GPG keys allows you to encrypt things for anyone else who has published their GPG keys without contacting them and exchanging [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday you may have read my <a href="http://www.danielhall.me/2009/09/gpg-symmetric-encryption/">GPG Symmetric Encryption</a> Guide. The last tip on that page was that you should setup GPG keys and publish them on a keyserver. I say this because publishing GPG keys allows you to encrypt things for anyone else who has published their GPG keys without contacting them and exchanging a symmetric key first.</p>
<h2>Generating a GPG key</h2>
<p>If you haven&#8217;t had a GPG or PGP key before, or the one you previously has has expired you will need to generate a new keypair. A keypair consists of a private key, that you keep absolutely secret, and a public key, that you publish to the world.</p>
<p>You should generate a GPG key on your desktop and not on a server. Most likely a server will not have enough entropy in its random number generator and could take a while. All you then have to do is:</p>
<pre>gpg --gen-key</pre>
<p>You then answer the questions as follows:</p>
<ul>
<li>The type of key that you want is &#8216;DSA and Elgamal&#8217; this way you can both encrypt messages and sign them.</li>
<li>1024 bits is probably enough, if you are planning a long expiry for your key you may want to choose 2048, and if your extremely paranoid use 4096.</li>
<li>I&#8217;d suggest a key expiry of two years for a 1024 bit key, but remember you can set an expiry later, and you can also revoke your key at any time if you believe it is compromised.</li>
<li>Then you fill in your details in the prompts</li>
<li>Never use a key without a passphrase, any compromise of your key will result in all data people have encrypted for you being compromised and people will be able to sign things as coming from you.</li>
</ul>
<p>After you enter the details you computer will start generating some very large numbers using cryptographically secure random data, and checking if those numbers are prime. Once your computer has two prime numbers it will generate your keys and save them for you.</p>
<h2>Add extra uids to the key</h2>
<p>A key can contain many uids. For example your key may contain a work uid and a home uid. If you work at many different companies or have a large number of email addresses then you could have many uids. The uids are what people who sign your key are indicating they trust. So I might decide to indicate that I trust your work uid but because I don&#8217;t know you personally  To add new uids to the key you type:</p>
<pre>gpg --edit-key
Command&gt; adduid</pre>
<p>Then just as before you enter all your details. You can list the uids on the key by typing &#8216;uid&#8217; at that same prompt. When you are done type &#8216;save&#8217; to save the key.</p>
<h2>Entering the web of trust</h2>
<p>The first thing you should do is decide what keyserver you would like to publish your keys to. Most keyservers sync with other ones so this is not really that important. I would suggest hkp://keys.gnupg.net but the choice is up to you. When you have decided what keyserver you want to use place an entry in your ~/.gnupg/gpg.conf file like that says &#8216;keyserver hkp://keys.gnupg.net&#8217; or whatever server you would like to use.</p>
<p>Now you are ready to build the inner circle of your web of trust. To do this you need to get other people to sign your keys, and them to sign yours. The more signatures you build up the easier it is to find a common link between you that is trusted.</p>
<p>To download another persons key you use the receive key argument for GPG. For example to download my key you can use any of the following commands:</p>
<pre>gpg --search-keys "Daniel Hall"
gpg --search-keys "smarthall@gmail.com"
gpg --recv-keys "A3A386ED"</pre>
<p>The first two may produce multiple matches and may ask you to select which particular key to download. At this point you should contact the user and confirm their ID so you get the right key.</p>
<p>Now that you&#8217;ve downloaded your friends keys you need to confirm who they are and then if all check out sign their keys. When you sign somebodies key you need to be extremely careful, signing a key is your declaration to the world that you trust that this key represents this person. If you sign keys without checking you could end up trusting people who aren&#8217;t who they say they are and people will begin to stop trusting you. To verify somebody you should meet them personally (or at an absolute minimum talk over the phone) to get their key fingerprint. As you are signing check that this fingerprint matches the key you are about to sign. To sign my key you could use the following command:</p>
<pre>gpg --sign-key "A3A386ED"</pre>
<p>Then you upload their key to the keyserver again to ensure that your signature on that key is now visible for the world to see. It is polite to ask people before you sign their key as many spam like signatures on a key may look bad in the eyes of others. If you had just signed my key you would upload it with:</p>
<pre>gpg --send-key "A3A386ED"</pre>
<p>Now all you need to do is get other people to sign your keys. I&#8217;d suggest you start with those people whose keys you have just signed as they&#8217;ll be the most willing to help you. You aim is to get enough signatures so that everybody who will need to send an encrypted document to you can find someone they trust who trusts you. It is a little more complicated than that but its essentially the idea.</p>
<p><strong>Random Thought:</strong> What should the random thought on my next blog post be? Hrmmmm.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/09/setting-up-gpg-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPG Symmetric Encryption</title>
		<link>http://www.danielhall.me/2009/09/gpg-symmetric-encryption/</link>
		<comments>http://www.danielhall.me/2009/09/gpg-symmetric-encryption/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 03:35:24 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[GPG]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System Administration]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=334</guid>
		<description><![CDATA[<p>I often come into a situation where I have to exchange some important confidential file with somebody who doesn&#8217;t have GPG keys setup. Explaining how to setup keys can be a pain, especially if you believe that the user will lose them or simply forget how to use them. There are all manner of propriety [...]]]></description>
			<content:encoded><![CDATA[<p>I often come into a situation where I have to exchange some important confidential file with somebody who doesn&#8217;t have GPG keys setup. Explaining how to setup keys can be a pain, especially if you believe that the user will lose them or simply forget how to use them. There are all manner of propriety software packages to deal with this but this post is about an easy free way using software that almost anyone has access to. I will be showing you how to do this using GPG on Unix operating systems. For windows you could follow <a href="http://mysys.wordpress.com/2006/11/02/setting-up-gnupg-in-windows/">this guide</a>.</p>
<h2>Encrypting</h2>
<p>To encrypt a file symmetrically using GPG just run:</p>
<pre class="brush: bash;">gpg --symmetric &lt;filename&gt;</pre>
<p>It will prompt you for a password twice and create a &lt;filename&gt;.gpg file in the current directory. If you want to put the encrypted text in an email then add the &#8211;armour flag. The &#8211;armour flag will cause gpg to instead output a &lt;filename&gt;.asc file which consists of ASCII text.</p>
<h2>Decrypting</h2>
<p>You decrypt it like any other GPG encrypted file:</p>
<pre class="brush: bash;">gpg -d &lt;filename&gt;.gpg</pre>
<p>This will prompt you for the password and decrypt the file, printing it to standard out.</p>
<h2>Tips</h2>
<ul>
<li>Don&#8217;t send the password and the attachment over the same medium, especially not in the same message. I suggest you send the email with the file and call and tell them the password.</li>
<li>GPG uses <a href="http://en.wikipedia.org/wiki/CAST-128">really strong encryption</a>, much more secure than that used in zipfile encryption. That said if you set the password to &#8217;123&#8242; or &#8216;password&#8217; no amount of encryption will help you. Your encryption is only as secure as the weakest point.</li>
<li>With enough time files like this can be cracked using brute force. You should still do all that you can to prevent the encrypted file falling into the wrong hands.</li>
<li>You really should setup GPG keys and publish them to a keyserver. That way you won&#8217;t have to worry about secure passphrase distribution.</li>
</ul>
<p><strong>Random Thought:</strong> How did people find the first search engine?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/09/gpg-symmetric-encryption/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ATM Phishing</title>
		<link>http://www.danielhall.me/2009/09/atm-phishing/</link>
		<comments>http://www.danielhall.me/2009/09/atm-phishing/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 11:14:55 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Phishing]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=325</guid>
		<description><![CDATA[<p>You&#8217;ve probably heard of ATM fishing by now. If you haven&#8217;t you should have. It typically involves placing a card reading device that is designed to blend in perfectly with the ATM. Then a camera or other device is placed that records the PIN of the user as they type it. So effectively while the [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve probably heard of ATM fishing by now. If you haven&#8217;t you should have. It typically involves placing a card reading device that is designed to blend in perfectly with the ATM. Then a camera or other device is placed that records the PIN of the user as they type it. So effectively while the user is entering their credentials into the ATM they are unwittingly entering them into a scammers database.</p>
<p>In a flash of inspiration last night I think I may have found a solution! My first instinct was to put a poster next to or on the ATM that shows what the ATM looks like. There are a few problems with this though. First, the scammer can simply replace the poster, secondly only the security concious will check it. So this is really a non solution.</p>
<p>So what if you placed pictures of critical parts in the software and display them when the user first puts in their card. Show a shot of the card insertion point, the keyboard and and overall picture. Scammers can&#8217;t simply place a poster over the screen as the user needs it to use the ATM. You ask the user to confirm all the pictures and if any don&#8217;t match you don&#8217;t let them enter their PIN, and possibly eat their card.</p>
<p>I&#8217;m not sure how this would work in practice. If the recent response to Vista&#8217;s UAC is anything to go by people will probably just click accept on anything. This may get the pictures in their face though. So after seeing this many pictures of ATMs they might more easily notice something amiss. Maybe its a bit ambitious, maybe its not quite scammer proof. What do my readers think?</p>
<p><strong>Random Thought:</strong> I&#8217;m getting an Android phone because it runs on an ARM CPU. That and my Windows phone is on its last LEGS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/09/atm-phishing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH Agent Forwarding</title>
		<link>http://www.danielhall.me/2009/08/ssh-agent-forwarding/</link>
		<comments>http://www.danielhall.me/2009/08/ssh-agent-forwarding/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 23:01:29 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=160</guid>
		<description><![CDATA[<p>So you use keys to SSH between your hosts, and you either have separate keys for each machine you use, or worse you have the same key on each machine. Lets go over why each of those are bad, and lets see how SSH Agent forwarding will help with those issues and make things easier [...]]]></description>
			<content:encoded><![CDATA[<p>So you use keys to SSH between your hosts, and you either have separate keys for each machine you use, or worse you have the same key on each machine. Lets go over why each of those are bad, and lets see how SSH Agent forwarding will help with those issues and make things easier for you in general.</p>
<p>So the key part of why a SSH agent and SSH agent forwarding forwarding is so useful is due to the way keys can be attacked. If I wanted to get your SSH private key I could find some flaw in the system that would give me that /home/you/.ssh/id_rsa file you have. Of course a malicious user with root access to the system could just go in and grab it. You can prevent this kind of attack by setting a passphrase on the key. Of course the root user could replace SSH with a special version designed to get your passphrase, steal the key out of memory or setup a keylogger. This means effectively that your private key is not safe on any system where a person you don&#8217;t trust has root access, or has other users and exploitable vulnerabilities.</p>
<h2>Single Private Key on Multiple Machines</h2>
<p>In this example you&#8217;re trusting the security of every single machine you have your private key on. Should it get compromised then you have to revoke you public key from every host, and regenerate private keys to place on every host. Every time you put your private key on a machine you increase the chances that it could be compromised.</p>
<h2>Multiple Private Keys On Multiple Machines</h2>
<p>So we&#8217;re getting a little closer to a good solution. In this instance we don&#8217;t have to generate our key and roll it out to all hosts in event of a compromise. You can also have segregate groups, on set of keys for work, another for home and so on. Your keys can still be compromised easily though, and once compromised they can be used until you revoke them manually.</p>
<h2>SSH Agent Forwarding</h2>
<p>There is a way to keep your key safe from compromise. Now I&#8217;ll have to explain how SSH authenticates you using your key. When your authenticating with SSH keys your key isn&#8217;t sent, the server sends you some random data and challenges your client to encrypt it with your private key. It then verifies the encrypted data by decrypting it with the public key and checking if it matches the data originally sent. Now the way most people would SSH from the second host to another third host is to utilise a private key on the second host to connect to the third host. Unfortunately this method means that you have to store a key (that is open for compromise) on the second host. SSH agent forwarding tells the SSH client on the second server to send the challenge data through to the SSH client (or ssh agent) on the first host. The agent encrypts the data and sends it via the SSH session to the third client.</p>
<p>The beauty of this method is that the second host never sees a private key, and the challenge data is useless to try and connect to a different host. Even if the second host is compromised there isn&#8217;t a private key there to compromise. It should be noted that if the second host is compromised it can still request the agent identify for a different host, or the session to the third host can be taken over. Both these are temporary though and unless the malicious user installs their key (something easy to notice) they cannot get back in.</p>
<div id="attachment_173" class="wp-caption alignright" style="width: 160px"><a href="http://www.danielhall.me/wp-content/uploads/2009/08/SSHAgent.png"><img class="size-thumbnail wp-image-173 " title="SSHAgent" src="http://www.danielhall.me/wp-content/uploads/2009/08/SSHAgent-150x150.png" alt="Diagram detailing how an SSH connection is authenticated using agent forwarding." width="150" height="150" /></a><p class="wp-caption-text">Diagram detailing how an SSH connection is authenticated using agent forwarding.</p></div>
<p>If you want to know more about how this works, there is a wonderful tech tip at <a href="http://unixwiz.net/techtips/ssh-agent-forwarding.html">http://unixwiz.net/techtips/ssh-agent-forwarding.html</a>.</p>
<h2>But how?</h2>
<p>SSH agent forwarding is even easier than copying keys all over the place. The first step is to generate keys for all the machines you log on to directly. You need to be sure these machines are secure and that your keys will stay safe, though this is sometimes not possible. You then add the generated public key to the authorized hosts file of all the machines you will connect to from this one, including ones that take two or more steps to get to. Finally you edit your ~/.ssh/ssh_config file to tell SSH to forward your agent through those hosts. Include the intermediate hosts in this list, but not the endpoints. You could also use <a href="http://www.danielhall.me/2009/07/sshmenu/">SSHmenu</a> to add the arguments automatically to those SSH commands. The following disables forwarding to all hosts, and explicitly enables it to fred, and aaron.missgner.com.</p>
<pre>Host fred
  ForwardAgent yes

Host aaron.missgner.com
  ForwardAgent yes

Host *
  ForwardAgent no</pre>
<p><strong>Random thought: </strong>Linux has Plug &#8216;n Pray too, you plug the device in and pray the drivers aren&#8217;t proprietary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/08/ssh-agent-forwarding/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
