public
Last active

LeetSpeak Challenge for PPT Session

  • Download Gist
LeetSpeak.java
Java
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
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;
}
 
}
leet_speak.py
Python
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
################################################################################
# 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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.