#!/usr/bin/perl # # Eircom WEP key generator from SSID # Derived from http://h1.ripway.com/kevindevine/wep_key.html # (c) 2007 Alex Bacik # use strict; use CGI; use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); my $cgi = new CGI; my $ssid = $cgi->param('ssid'); print $cgi->header(); &Bail ("Please enter an SSID") unless $ssid; $ssid =~ s/\D//g; # Remove non-digit characters &Bail ("Please enter a valid SSID, eg. 26337520") unless $ssid; &Bail ("Please enter an eight-digit SSID, eg. 26337520") unless $ssid =~ /\d{8}/; # Convert to dec my $dec_ssid = oct($ssid); # XOR with 0x000fcc or 4044 to get MAC my $xor = $dec_ssid ^ 4044; # Add this number to 0x010000000 or 16777216 to get serial my $serial = $xor + 16777216; # Get charter version of serial my @numbers = ('Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'); my @characters = split "", $serial; my $plaintext; foreach my $char (@characters) { $plaintext .= $numbers[$char]; } # Append some text my @lyrics = ("Although your world wonders me, ", "with your superior cackling hen,", "Your people I do not understand,", "So to you I shall put an end and", "You'll never hear surf music aga", "Strange beautiful grassy green, ", "With your majestic silver seas, ", "Your mysterious mountains I wish"); my @appended; foreach (my $x = 0; $x <= 7; $x++) { $appended[$x] = $plaintext . $lyrics[$x]; } # Perform SHA-1 on each line and concatenate my $ciphertext= ""; foreach (my $x = 0; $x <= 7; $x++) { $ciphertext .= sha1_hex ($appended[$x]); } # Break it up into 26-bit portions my $cipherportion1 = substr ($ciphertext, 0, 26); my $cipherportion2 = substr ($ciphertext, 26, 26); my $cipherportion3 = substr ($ciphertext, 52, 26); my $cipherportion4 = substr ($ciphertext, 78, 26); # Print results print< www.bacik.org - Eircom Netopia WEP key generator results for eircom$ssid Eircom Netopia WEP key generator results:

SSIDeircom$ssid
WEP Key 1$cipherportion1
WEP Key 2$cipherportion2
WEP Key 3$cipherportion3
WEP Key 3$cipherportion4

Back EOF ######################### sub Bail { print "$_[0]

\n"; print "Back"; exit (0); }