[Aporte] Generador de diccionarios para fuerza bruta

(1/2) > >>

WHK:
Hola, hice un generador de diccionarios en python, lo pueden descargar desde acá:
https://github.com/WHK102/whk-dictionary-maker

Uso:

Código:

whk@machine:~/$ python whk-dict-maker.py
- WHK Dictionary Maker 1.0, for pentesting purposes.
- Enter max longitude of word [4]        :
- Use letters?                [Y/n]      :
- Use lowercase?              [Y/n]      :
- Use uppercase?              [y/N]      :
- Use numbers?                [Y/n]      :
- Use special chars?          [y/N]      :
- Filename of dictionary      [dict.txt] :

  Summary                                             
  -----------------------------------------------------
- Max longitude of word                  : 4
- Total number of characters to use      : 36
- Total of words                         : 1,727,604
- Use letters                            : Yes
- Use lowercase letters                  : Yes
- Use uppercase letters                  : No
- Use numbers                            : Yes
- Use special chars                      : No
- Filename of dictionary                 : dict.txt
- File size estimated of dictionary      : 8.19MB
  -----------------------------------------------------
- You want to proceed?        [Y/n]      :
- End!                                                 

whk@machine:~/$ ls -lah
total 8,3M
drwxrwxr-x 3 whk whk 4,0K ene 24 20:24 .
drwxrwxr-x 4 whk whk 4,0K ene 24 20:09 ..
-rw-rw-r-- 1 whk whk 8,2M ene 24 20:24 dict.txt
-rw-rw-r-- 1 whk whk 7,0K ene 24 20:09 whk-dict-maker.py
whk@machine:~/$

Código:

Código
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
import sys
import os
import math
 
class MainCLS:
 
   total_of_words      = 0
   total_of_characters = 0
   current             = 0
   user_longitude      = 0
   user_use_letters    = False
   user_use_lowercase  = False
   user_use_uppercase  = False
   user_use_numbers    = False
   user_use_specials   = False
   user_filename       = ''
   list_string         = ''
 
 
   def processWord(self, str):
       self.current = self.current + 1
       self.file_handler.write("%s\n" % str)
       sys.stdout.write("\r- Progress: %d/%d (%s)                " % (self.current, self.total_of_words, str))
       sys.stdout.flush()
 
 
   def loop(self, prefix, loops):
       if loops == 0:
           return
 
       last_list = []
       for id_letter in range(0, len(self.list_string)):
           final_str = prefix + self.list_string[id_letter]
           last_list.append(final_str)
           self.processWord(final_str)
 
       for id_array in range(0, len(last_list)):
           self.loop(last_list[id_array], loops - 1)
 
 
   def getInput(self, message, type_inp, default_value):
       inp = raw_input(message)
       inp = inp.strip()
 
       if inp == '':
           inp = default_value
 
       if type_inp == 'int':
           try:
               val = int(inp)
               if val > -1:
                   return val
               else:
                   print '- That\'s not an number. Try again.'
                   return self.getInput(message, type_inp, default_value)
 
           except ValueError:
               print '- That\'s not an number. Try again.'
               return self.getInput(message, type_inp, default_value)
 
       elif type_inp == 'bool':
           if inp.lower() == 'y':
               return True
           elif inp.lower() == 'n':
               return False
           else:
               print '- Please, respond with yes (y) or not (n). Try again.'
               return self.getInput(message, type_inp, default_value)
 
       elif type_inp == 'file':
           if os.path.isfile(inp):
               respond = self.getInput('- The file exists.You want to replace it? [y/N] : ', 'bool', 'n')
               if respond == False:
                   return self.getInput(message, type_inp, default_value)
               else:
                   return inp
           else:
               return inp
 
       else:
           return inp
 
   def printSummary(self):
       print '                                                       '
       print '  Summary                                              '
       print '  -----------------------------------------------------'
       print '- Max longitude of word                  : ' + '{0:,}'.format(self.user_max_longitude)
       print '- Total number of characters to use      : ' + '{0:,}'.format(len(self.list_string))
       print '- Total of words                         : ' + '{0:,}'.format(self.total_of_words)
 
       if self.user_use_letters == True:
           print '- Use letters                            : Yes'
           print '- Use lowercase letters                  : ' + ('Yes' if self.user_use_lowercase  else 'No')
           print '- Use uppercase letters                  : ' + ('Yes' if self.user_use_uppercase  else 'No')
       else:
           print '- Use letters                            : No'
 
 
       print '- Use numbers                            : ' + ('Yes' if self.user_use_numbers  else 'No')
       print '- Use special chars                      : ' + ('Yes' if self.user_use_specials else 'No')
       if os.path.isfile(self.user_filename):
           print '- Filename of dictionary                 : ' + self.user_filename + ' (override)'
       else:
           print '- Filename of dictionary                 : ' + self.user_filename
 
       print '- File size estimated of dictionary      : ' + self.convertSize(self.total_of_characters)
 
       print '  -----------------------------------------------------'
       return self.getInput('- You want to proceed?        [Y/n]      : ', 'bool', 'y')
 
 
   def convertSize(self, size, precision=2):
       # size = size + 0.0
       suffixes=['B','KB','MB','GB','TB','PB']
       suffixIndex = 0
       while size > 1024 and suffixIndex < 4:
           suffixIndex += 1 #increment the index of the suffix
           size = size/1024.0 #apply the division
       return ("%.*f%s" % (precision, size, suffixes[suffixIndex]))
 
 
   def __init__(self):
 
       print '- WHK Dictionary Maker 1.0, for pentesting purposes.';
       # self.user_min_longitude = self.getInput('- Enter min longitude of word [0]        : ', 'int',  '0')
       self.user_max_longitude = self.getInput('- Enter max longitude of word [4]        : ', 'int',  '4')
 
       self.user_use_letters   = self.getInput('- Use letters?                [Y/n]      : ', 'bool', 'y')
       if self.user_use_letters == True:
           self.user_use_lowercase   = self.getInput('- Use lowercase?              [Y/n]      : ', 'bool', 'y')
           self.user_use_uppercase   = self.getInput('- Use uppercase?              [y/N]      : ', 'bool', 'n')
 
       self.user_use_numbers   = self.getInput('- Use numbers?                [Y/n]      : ', 'bool', 'y')
       self.user_use_specials  = self.getInput('- Use special chars?          [y/N]      : ', 'bool', 'n')
       self.user_filename      = self.getInput('- Filename of dictionary      [dict.txt] : ', 'file', 'dict.txt')
 
       self.list_string = ''
 
       if self.user_use_letters == True:
 
           if self.user_use_lowercase == True:
               self.list_string = self.list_string + 'abcdefghijklmnopqrstuvwxyz'
 
           if self.user_use_uppercase == True:
               self.list_string = self.list_string + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
       if self.user_use_numbers == True:
           self.list_string = self.list_string + '0123456789'
 
       if self.user_use_specials == True:
           self.list_string = self.list_string + '\\/\'"@#$%&/()=?¿!¡+-*_.:,;'
 
 
       self.total_of_words      = 0
       self.total_of_characters = 0
       for n in range(0, self.user_max_longitude):
           total = (len(self.list_string)**(n + 1))
           self.total_of_words      = self.total_of_words + total
           # (word length * count words) + \n
           self.total_of_characters = self.total_of_characters + (total * (n + 1)) + total
 
       # Summary
       response = self.printSummary()
       if response == False:
           return
 
       # Load file
       if os.path.isfile(self.user_filename):
           os.remove(self.user_filename)
       self.file_handler = open(self.user_filename, 'w')
 
       # Execute all
       self.loop('', self.user_max_longitude)
 
       # End
       self.file_handler.close()
       print "\r                                                       \r- End!"
 
if __name__ == '__main__':
   mainCLS = MainCLS()
 

Enjoy.

nevachana:
Yo tambien hice uno hace tiempo en c# , aqui esta mi ejemplo ^^
Código
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Combolist2
{
   class Program
   {
       public static List<string> usernames = new List<string>();
       public static List<string> passwords = new List<string>();
       public static string line = "";
       static void Main(string[] args)
       {
           Console.Title = "ComboList 2.0 - Nevachana";
           Console.Write("Name of usernames file: ");
           string userFile = Console.ReadLine();
           using (StreamReader sr = File.OpenText(userFile))
           {
               string lines = sr.ReadToEnd();
               string[] line = lines.Split('\n');
               foreach (string filtering in line)
               {
                       usernames.Add(filtering);
               }
           }
           Console.Write("Name of password file: ");
           string passwordFile = Console.ReadLine();
           using (StreamReader sr = File.OpenText(passwordFile))
           {
               string lines = sr.ReadToEnd();
               string[] line = lines.Split('\n');
               foreach (string filtering in line)
               {
                   if (filtering.Contains(" "))
                       filtering.Replace(" ", "");
                   passwords.Add(filtering);
               }
           }
           Console.Write("max prefix and sufix intenger: ");
           int max = int.Parse(Console.ReadLine());
           Console.WriteLine("Doing combo..");
           using (TextWriter tw = new StreamWriter("Combo.txt")) // we create the file.
           {
               for (int x = 1; x < usernames.Count; x++)
               {
 
                   for (int y = 0; y < passwords.Count; y++)
                   {
                       if (passwords[y].ToLower().Contains("%user%"))
                           line = string.Format("{0}:{1}", usernames[x], passwords[y].Replace("%user%", usernames[x]));
                       else
                       line = string.Format("{0}:{1}", usernames[x], passwords[y]);
                       tw.Write(line + Environment.NewLine);
                   }
                   for (int z = 0; z < max; z++)
                   {
                       tw.Write(usernames[x]+":" + usernames[x]+z+ Environment.NewLine);
 
                       tw.Write(usernames[x] + ":" +z+ usernames[x] +  Environment.NewLine);
                       if (usernames[x].Any(c => char.IsUpper(c)))
                       {
                           tw.Write(usernames[x] + ":" + usernames[x].ToLower() + z + Environment.NewLine);
                           tw.Write(usernames[x] + ":" + z + usernames[x].ToLower() + Environment.NewLine);
                       }
                   }
 
               }
           }
           Console.WriteLine("Done");
           Console.ReadLine();
       }
   }
}
 

B4tm4n:
Hola, pues estan chidos, pero que tal el crunch?

WHK:
Cita de: B4tm4n en 31 Enero 2016, 19:49 pm

Hola, pues estan chidos, pero que tal el crunch?


Código:

whk@machine:~$ time crunch 0 4 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 > dict.txt
Crunch will now generate the following amount of data: 74846649 bytes
71 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 15018571

real 0m4.349s
user 0m1.332s
sys 0m0.016s

whk@machine:~$ time python whk-dict-maker.py
- WHK Dictionary Maker 1.0, for pentesting purposes.
                                                       
  Summary                                             
  -----------------------------------------------------
- Max longitude of word                  : 4
- Total number of characters to use      : 62
- Total of words                         : 15,018,570
- Use letters                            : Yes
- Use lowercase letters                  : Yes
- Use uppercase letters                  : Yes
- Use numbers                            : Yes
- Use special chars                      : No
- Filename of dictionary                 : dict2.txt
- File size estimated of dictionary      : 71.38MB
  -----------------------------------------------------
- End!                                                 

real 0m7.010s
user 0m6.956s
sys 0m0.048s
whk@machine:~$

Definitivamente el crunch es casi el doble de rápido que el mio y creo que se debe porque es compilado y el mio interpretado. No conocía crunch, está bastante bueno.

El_Andaluz:
WHK:Gracias por el aporte hacía tiempo que no veía algún generador diccionario nuevo por aquí, me gustaría probarlo en el Wifislax es la única distribución así que tengo de linux y me gustaría saber como podría hacerlo funcionar ? Si se puede, me gustaría si no te importa que me expliques los pasos a seguir para hacerlo funcionar tengo ganas de probarlo.  

Otra opción sería hacer un modulo en xzm de este generador de diccionario y probarlo en Wifislax, creo que sería mas fácil si a ti no te importaría hacerlo si no es mucho pedir.

Yo probé hacerlo hace tiempo pero luego no me funcionan bien por que le faltan dependencias o cosas así. :P

Navegación

[0] Índice de Mensajes

[#] Página Siguiente