Skip to content

Instantly share code, notes, and snippets.

@petehamilton
Created November 27, 2012 22:24
Show Gist options
  • Save petehamilton/4157569 to your computer and use it in GitHub Desktop.
Save petehamilton/4157569 to your computer and use it in GitHub Desktop.
LeetSpeak Challenge for PPT Session
################################################################################
# A python file to demonstrate finding potential passwords made from Leetspeak
# BACKSTORY:
# You overhear someone in the office mention their password out loud.
# You decide to break into their account, however you know they're pretty L337
# so probably won't use standard characters e.g @, 4 in place of a. You decide
# to generate all possible passwords and try them one by one.
#
# Imagine we have done some clarifications and ended up with the following
# mapping/dictionary structure (substitutions below).
#
# Most of the file has been filled in for you, you just need to implement
# the generatePossibilities function with any helper methods.
#
# This won't be marked/assessed in any way, it's just for fun and we'll talk
# about it next session
#
# @author Peter Hamilton
# @version 1.0
################################################################################
substitutions = {
"a": ["@", "4"],
"e": ["3"],
"l": ["!", "1"],
"s": ["5", "$"],
"o": ["0", "#"]
}
# Generates variations of a set password using Leet Speak
def main():
password = "password"
possibilities = generatePossibilities(password)
print "Original Password: %s" % password
print "Possible Spellings:"
for p in possibilities:
print p
print "Total: %d" % len(possibilities)
# TODO: Implement!
# Takes a password string and returns a list of alternative leet spellings
# For example:
# password => p@ssword, p@5sword, pas$w#rd, p@s5w#rd etc
#
# s - A password string e.g. password
def generatePossibilities(s):
possibilities = []
return possibilities
if __name__ == "__main__":
main()
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* A class to demonstrate finding potential passwords made from Leetspeak
*
* BACKSTORY:
* You overhear someone in the office mention their password out loud.
* You decide to break into their account, however you know they're pretty L337
* so probably won't use standard characters e.g @, 4 in place of a. You decide
* to generate all possible passwords and try them one by one.
*
* Most of the file has been filled in for you, you just need to implement
* the generatePossibilities function with any helper methods.
*
* This won't be marked/assessed in any way, it's just for fun and we'll talk
* about it next session
*
* @author Peter Hamilton
* @version 1.0
*/
public class LeetSpeak {
/**
* A mapping of characters to their alternatives
*/
public static HashMap<String,List<String>> substitutions = new HashMap<String,List<String>>() {{
put("a", Arrays.asList("@", "4"));
put("e", Arrays.asList("3"));
put("l", Arrays.asList("!", "1"));
put("s", Arrays.asList("5", "$"));
put("o", Arrays.asList("0", "#"));
}};
/**
* Generates variations of a set password using Leet Speak
*/
public static void main(String[] args) {
String password = "password";
ArrayList<String> possibilities = generatePossibilities(password);
System.out.printf("Original Password: %s\n", password);
System.out.printf("Possible Spellings:\n");
for(String s : possibilities){
System.out.printf("%s\n", s);
}
System.out.printf("Total: %d", possibilities.size());
}
/**
* TODO: Implement!
*
* Generates variations of a set password using Leet Speak
* Takes a password string and returns a list of alternative leet spellings
* For example:
* password => p@ssword, p@5sword, pas$w#rd, p@s5w#rd etc
*
* @param s A password string e.g. password
* @param leet A dictionary of {original_letter : [alternatives]}
* @return a list of potential passwords
*/
public static ArrayList<String> generatePossibilities(String s) {
ArrayList<String> possibilities = new ArrayList<String>();
return possibilities;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment