Advertisement
Guest User

Password Recovery

a guest
Apr 16th, 2014
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.47 KB | None | 0 0
  1. #!/usr/bin/ruby -w
  2. #list of potentional passwords
  3. passphraseList = ['possibility1','possibility2','possibility3']
  4. $allPhrases=''
  5. $countList=0
  6. passphraseList.each do |passphrase|
  7.     def display(phrase)
  8.         if phrase.length != 1
  9.             $allPhrases<<phrase
  10.             $allPhrases<<'
  11. '
  12.         end
  13.  
  14.         $countList += 1
  15.     end
  16.     def scramble(passphrase)
  17.       characters = " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  18.       list = []
  19.  
  20.       # transpose adjacent chars
  21.       (passphrase.length - 1).times do |i|
  22.         testphrase = passphrase.dup
  23.         testphrase[i] = passphrase[i+1]
  24.         testphrase[i+1] = passphrase[i]
  25.         list << testphrase
  26.       end
  27.  
  28.       # delete one char
  29.       passphrase.length.times do |i|
  30.         testphrase = passphrase.dup
  31.         testphrase = testphrase[0,i] + testphrase[(i+1)..-1]
  32.         list << testphrase
  33.       end
  34.  
  35.       # substitutute one char
  36.       passphrase.length.times do |i|
  37.         characters.chars.each do |c|
  38.           testphrase = passphrase.dup
  39.           testphrase[i] = c
  40.           list << testphrase
  41.         end
  42.       end
  43.  
  44.       # insert one char
  45.       (passphrase.length + 1).times do |i|
  46.         characters.chars.each do |c|
  47.           testphrase = passphrase.dup
  48.           testphrase.insert(i, c)
  49.           list << testphrase
  50.         end
  51.       end
  52.       return list.uniq
  53.     end
  54.     list1 = scramble(passphrase)
  55.     list1.each { |i| display i }
  56.     print 'total count'
  57.     print $countList
  58.     fo = open("wordlist.txt","w")
  59.     fo.write( $allPhrases )
  60.     fo.close()
  61. end
  62. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement