Projects STRLCPY cupp Commits b5d3988a
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    cupp.cfg
    skipped 66 lines
    67 67  alectourl=https://github.com/yangbh/Hammer/raw/b0446396e8d67a7d4e53d6666026e078262e5bab/lib/cupp/alectodb.csv.gz
    68 68   
    69 69  [downloader]
    70  -ftpname=FUNET
    71  -ftpurl=ftp.funet.fi
    72  -ftppath=/pub/unix/security/passwd/crack/dictionaries/
    73  -ftpuser=anonymous
    74  -ftppass=cupp3
     70 +dicturl=http://ftp.funet.fi/pub/unix/security/passwd/crack/dictionaries/
    75 71   
  • ■ ■ ■ ■ ■ ■
    cupp.py
    skipped 32 lines
    33 33  import argparse
    34 34  import configparser
    35 35  import csv
    36  -import ftplib
    37 36  import functools
    38 37  import gzip
    39 38  import os
    skipped 4 lines
    44 43   
    45 44  __author__ = "Muris Kurgas"
    46 45  __license__ = "GPL"
    47  -__version__ = "3.2.4-alpha"
     46 +__version__ = "3.2.5-alpha"
    48 47   
    49 48  CONFIG = {}
    50 49   
    skipped 17 lines
    68 67   "wcto": config.getint("nums", "wcto"),
    69 68   "threshold": config.getint("nums", "threshold"),
    70 69   "alectourl": config.get("alecto", "alectourl"),
     70 + "dicturl": config.get("downloader", "dicturl"),
    71 71   }
    72 72   
    73 73   # 1337 mode configs, well you can add more lines if you add it to the
    skipped 6 lines
    80 80   leetc[letter] = config.get("leet", letter)
    81 81   
    82 82   CONFIG["LEET"] = leetc
    83  - 
    84  - ftp_config = functools.partial(config.get, "downloader")
    85  - 
    86  - CONFIG["FTP"] = dict(
    87  - name=ftp_config("ftpname"),
    88  - url=ftp_config("ftpurl"),
    89  - path=ftp_config("ftppath"),
    90  - user=ftp_config("ftpuser"),
    91  - password=ftp_config("ftppass"),
    92  - )
    93 83   
    94 84   
    95 85  def make_leet(x):
    skipped 600 lines
    696 686   print_to_file(profile["name"] + ".txt", unique_list_finished)
    697 687   
    698 688   
     689 +def download_http(url, targetfile):
     690 + print("[+] Downloading " + targetfile + " from " + url + " ... ")
     691 + webFile = urllib.request.urlopen(url)
     692 + localFile = open(targetfile, "wb")
     693 + localFile.write(webFile.read())
     694 + webFile.close()
     695 + localFile.close()
     696 + 
     697 + 
    699 698  def alectodb_download():
    700 699   """Download csv from alectodb and save into local file as a list of
    701 700   usernames and passwords"""
    skipped 1 lines
    703 702   url = CONFIG["global"]["alectourl"]
    704 703   
    705 704   print("\r\n[+] Checking if alectodb is not present...")
    706  - if not os.path.isfile("alectodb.csv.gz"):
    707  - print("[+] Downloading alectodb.csv.gz...")
    708  - webFile = urllib.request.urlopen(url)
    709  - localFile = open(url.split("/")[-1], "wb")
    710  - localFile.write(webFile.read())
    711  - webFile.close()
    712  - localFile.close()
     705 + 
     706 + targetfile = "alectodb.csv.gz"
     707 + 
     708 + if not os.path.isfile(targetfile):
     709 + 
     710 + download_http(url, targetfile)
    713 711   
    714  - f = gzip.open("alectodb.csv.gz", "rt")
     712 + f = gzip.open(targetfile, "rt")
    715 713   
    716 714   data = csv.reader(f)
    717 715   
    skipped 20 lines
    738 736   
    739 737   
    740 738  def download_wordlist():
    741  - """Implementation of -l switch. Download wordlists from ftp repository as
     739 + """Implementation of -l switch. Download wordlists from http repository as
    742 740   defined in the configuration file."""
    743 741   
    744 742   print(" \r\n Choose the section you want to download:\r\n")
    skipped 12 lines
    757 755   print(" 12 dutch 25 net 38 exit program")
    758 756   print(" 13 finnish 26 norwegian \r\n")
    759 757   print(
    760  - " \r\n Files will be downloaded from " + CONFIG["FTP"]["name"] + " repository"
     758 + " \r\n Files will be downloaded from "
     759 + + CONFIG["global"]["dicturl"]
     760 + + " repository"
    761 761   )
    762 762   print(
    763 763   " \r\n Tip: After downloading wordlist, you can improve it with -w option\r\n"
    skipped 10 lines
    774 774   filedown = input("> Enter number: ")
    775 775   filedown = str(filedown)
    776 776   
    777  - download_wordlist_ftp(filedown)
     777 + download_wordlist_http(filedown)
    778 778   return filedown
    779 779   
    780 780   
    781  -def download_wordlist_ftp(filedown):
    782  - """ do the FTP download of a wordlist """
     781 +def download_wordlist_http(filedown):
     782 + """ do the HTTP download of a wordlist """
    783 783   
    784  - ftpname = CONFIG["FTP"]["name"]
    785  - ftpurl = CONFIG["FTP"]["url"]
    786  - ftppath = CONFIG["FTP"]["path"]
    787  - ftpuser = CONFIG["FTP"]["user"]
    788  - ftppass = CONFIG["FTP"]["password"]
    789  - 
    790  - if os.path.isdir("dictionaries") == 0:
    791  - os.mkdir("dictionaries")
     784 + mkdir_if_not_exists("dictionaries")
    792 785   
    793 786   # List of files to download:
    794 787   arguments = {
    skipped 184 lines
    979 972   37: ("yiddish", ("yiddish.gz",)),
    980 973   }
    981 974   
    982  - def downloader():
    983  - ftp.login(ftpuser, ftppass)
    984  - ftp.cwd(ftppath)
    985  - 
    986  - # retrieve a file from FTP
    987  - def retr_binary_file(ftp, dire, filename):
    988  - def handleDownload(block):
    989  - f.write(block)
    990  - print(".", end="")
    991  - 
    992  - f = open(dire + filename, "wb")
    993  - print("\r\n[+] downloading " + filename + "...")
    994  - # ftp.retrbinary("RETR " + filename, f.write)
    995  - ftp.retrbinary("RETR " + filename, handleDownload)
    996  - f.close()
    997  - print(" done.")
    998  - 
    999  - # retrieve a list of files
    1000  - def retr_file_list(ftp, dire, file_list):
    1001  - for f in file_list:
    1002  - retr_binary_file(ftp, dire, f)
    1003  - 
    1004  - # create the directory if it doesn't exist
    1005  - def mkdir_if_not_exists(dire):
    1006  - if not os.path.isdir(dire):
    1007  - os.mkdir(dire)
    1008  - 
    1009 975   # download the files
    1010 976   
    1011 977   intfiledown = int(filedown)
    1012 978   
    1013 979   if intfiledown in arguments:
    1014 980   
    1015  - print("\r\n[+] connecting...\r\n")
    1016  - ftp = ftplib.FTP(ftpurl)
    1017  - downloader()
    1018  - ftp.cwd(arguments[intfiledown][0])
    1019  - 
    1020 981   dire = "dictionaries/" + arguments[intfiledown][0] + "/"
    1021 982   mkdir_if_not_exists(dire)
    1022  - 
    1023  - print(arguments[int(filedown)][0])
    1024 983   files_to_download = arguments[intfiledown][1]
    1025 984   
    1026  - # download the files
    1027  - retr_file_list(ftp, dire, files_to_download)
     985 + for fi in files_to_download:
     986 + url = CONFIG["global"]["dicturl"] + arguments[intfiledown][0] + "/" + fi
     987 + tgt = dire + fi
     988 + download_http(url, tgt)
    1028 989   
    1029 990   print("[+] files saved to " + dire)
    1030  - ftp.quit()
    1031 991   
    1032 992   else:
    1033 993   print("[-] leaving.")
     994 + 
     995 + 
     996 +# create the directory if it doesn't exist
     997 +def mkdir_if_not_exists(dire):
     998 + if not os.path.isdir(dire):
     999 + os.mkdir(dire)
    1034 1000   
    1035 1001   
    1036 1002  # the main function
    skipped 72 lines
  • ■ ■ ■ ■ ■
    test_cupp.py
    skipped 62 lines
    63 63   }
    64 64   read_config()
    65 65   generate_wordlist_from_profile(profile)
    66  - pass
    67 66   
    68 67   def test_parser(self):
    69 68   """ downloads a file and checks if it exists """
    70 69   
    71  - download_wordlist_ftp("16")
     70 + download_wordlist_http("16")
    72 71   
    73 72   filename = "dictionaries/hindi/hindu-names.gz"
    74 73   
    skipped 23 lines
Please wait...
Page is in error, reload to recover