{"id":209,"date":"2009-03-13T18:14:38","date_gmt":"2009-03-14T01:14:38","guid":{"rendered":"http:\/\/sp2hari.com\/?p=209"},"modified":"2020-06-20T08:31:35","modified_gmt":"2020-06-20T08:31:35","slug":"dictionary-attack","status":"publish","type":"post","link":"https:\/\/sp2hari.com\/index.php\/2009\/03\/13\/dictionary-attack\/","title":{"rendered":"Dictionary attack"},"content":{"rendered":"<p>This is a tutorial about how to perform a dummy dictionary attack and how web-masters can prevent a dictionary attack.<\/p>\n<p>Wikipedia defines <a href=\"http:\/\/en.wikipedia.org\/wiki\/Dictionary_attack\">Dictionary attack<\/a> as,<br \/>\n<code><br \/>\nIn cryptanalysis and computer security, a dictionary attack is a technique for defeating a cipher or authentication mechanism by trying to determine its decryption key or passphrase by searching likely possibilities.<br \/>\nA dictionary attack uses a brute-force technique of successively trying all the words in an exhaustive list (from a pre-arranged list of values). In contrast with a normal brute force attack, where a large proportion key space is searched systematically, a dictionary attack tries only those possibilities which are most likely to succeed, typically derived from a list of words in a dictionary. Generally, dictionary attacks succeed because many people have a tendency to choose passwords which are short (7 characters or fewer), single words found in dictionaries or simple, easily-predicted variations on words, such as appending a digit.<br \/>\n<\/code><\/p>\n<p>In this post, I&#8217;m going to write a simple code which will send POST requests to the web server and process the response of each request. Before I start, let me tell you that there are many softwares which already do this. Some of them are,<\/p>\n<p>1. <a href=\"http:\/\/portswigger.net\/suite\/\">Burp Suite<\/a><br \/>\n2. <a href=\"http:\/\/www.openwall.com\/john\/\">John the Ripper<\/a><\/p>\n<p>But what&#8217;s the fun in using a software and cracking something. \ud83d\ude42 The fun part is when YOUR code does something. After all, <em>Code is Poetry<\/em> (Check wordpress.org footer)  \ud83d\ude09<\/p>\n<p>For the demo here, I have <a href=\"http:\/\/sp2hari.com\/work\/dict\/login.php\">this login page<\/a>, which is very similar to my college mail server (or any horde server). The user-name and password for a successful login is &#8220;cs10528&#8221; and &#8220;remember&#8221; respectively. If you provide a valid user-name\/password combination, the page will display &#8220;Login Successful&#8221;. For any other user-name\/password combination, the page will display &#8220;Login Failed&#8221;. So, now all we need is a code which can send POST request to the login page and a dictionary from which we can pick up the probable passwords.<\/p>\n<p><a href=\"http:\/\/sp2hari.com\/work\/dict\/curl.php.html\">This is the PHP code<\/a> I&#8217;ve written to automate the login process. It reads from the &#8220;dict.txt&#8221; file and uses that to send the HTTP request. The code is well commented and main login process is done by curl functions. And finally, <a href=\"http:\/\/sp2hari.com\/work\/dict\/dict.txt\">here is the dict.txt<\/a> I&#8217;ve used for this demo. It has only around 25 words, so that the processing ends sooner. In case you are not comfortable with curl in php, you can <a href=\"http:\/\/sp2hari.com\/2008\/10\/01\/fetching-the-internet\/\">see this post<\/a>, which explains about curl basics.<\/p>\n<p>You can see the whole login process in action <a href=\"http:\/\/sp2hari.com\/work\/dict\/curl.php\">here<\/a>.<\/p>\n<p><strong>So, how can a web-master prevent these automatic logins?<\/strong><\/p>\n<p>1. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Captcha\">Captcha<\/a><br \/>\nAdding a captcha prevents almost all the automatic login attempts. But be careful about what kind of captcha you choose. There are quite a few captchas which confuse people and scare them away.<\/p>\n<p>2. <a href=\"http:\/\/sw-guide.de\/wordpress\/plugins\/math-comment-spam-protection\/\">Math Puzzles<\/a><br \/>\nInstead of images, you can ask the user to enter some simple arithmetic calculations (like what is 10+15). This loads much faster and prevents any confusion.<\/p>\n<p>3. Maintaining the state in server<br \/>\nStore the login access time for each user, and if the time difference is less than 5 seconds, then block the user for next 10 minutes. This needs some more modification in the server side code, with new tables needed to store the login access time data.<\/p>\n<p>Note :<br \/>\n1. The code posted here won&#8217;t work for horde. There are cookies and other stuff to be handled in many cases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a tutorial about how to perform a dummy dictionary attack and how web-masters can prevent a dictionary attack. Wikipedia defines Dictionary attack as, In cryptanalysis and computer security, a dictionary attack is a technique for defeating a cipher or authentication mechanism by trying to determine its decryption key &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-209","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":12,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":1363,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/209\/revisions\/1363"}],"wp:attachment":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}