colloide

[historical] Web directory bruteforce script
git clone git://mcdim.xyz/colloide.git
Log | Files | Refs | README | LICENSE

colloide101.py (15776B)


      1 #!/usr/bin/python
      2 #
      3 # MCD's Colloide v1.0.1
      4 # GREECE 2017 - greekhacking.gr
      5 # GNU General Public Lisence
      6 # Pronounced: Kow Lawd
      7 #
      8 #     DO NOT USE FOR MALICIOUS PURPOSES!
      9 #                THE DEVELOPER HAS NO RESPONSIBLITY FOR ANY DAMAGE CAUSED!
     10 #
     11 #
     12 #  				 _.:' VERSION DIARY ':._
     13 #
     14 # In version 0.1:
     15 #	Program is working!
     16 # In version 0.2:
     17 #	Minor bugs fixed
     18 #	Updated the links file
     19 # In version 0.3:
     20 #	Major bug fixed
     21 #	Minor bugs fixed as well
     22 #	Updated the links file
     23 # 	Added option / argument parsing
     24 #	Added legals
     25 # In version 0.4:
     26 #	Minor bugs fixed
     27 #	General stracture has been updated
     28 #	Wordlist option added - Only links.txt could be used before this update
     29 #	Added ASCII logo
     30 #	Added the sexy ASCII wolf
     31 # In version 0.5 MAJOR RELEASE
     32 #	Minor bugs fixed
     33 #	Major bug fixed
     34 #	Updated ASCII logo
     35 #	Updated ASCII wolf
     36 #	Program has been released to the masses!
     37 # In version 0.6:
     38 # 	Minor bugs fixed
     39 # 	Option to save the pages into a txt page added
     40 # 	Added some comments to help contributors read the code
     41 # 	Added a function that checks whether the URL is valid or not
     42 # In version 0.7:
     43 #	One major bug fixed
     44 #	Minor bugs fixed as well
     45 # In version 0.8:
     46 #	Added colors
     47 # In version 0.8.5
     48 #	Added status code next to links
     49 #	Added more link wordlists, more specific to each language
     50 # In version 0.9:
     51 #	Added status code method
     52 # In version 0.9.5
     53 #	Quick robots.txt check added
     54 # In version 1.0.0
     55 #	Directory option added (-f) to search inside of a particular dir
     56 #	Fixed major bug in the status method (false status code retrieved)
     57 #	Removed status code from the urlerror method
     58 #       Red when unauthorized or forbidden in the status method
     59 # In version 1.0.1
     60 #	Users are able to disable/enable ascii by typing -a
     61 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     62 #
     63 #   Project on GitHub:
     64 #	http://yamechanic.com/C3vc
     65 #   Website:
     66 #	http://yamechanic.com/C41V
     67 #
     68 #   Report bugs: anivsante2@gmail.com
     69 #   or /issues if you use github
     70 #
     71 # # # # # # # # # # # # # # # # # # # # # # # #
     72 
     73 # MODULES / LIBRARIES:
     74 
     75 from __future__ import print_function #because some print functions print quotation marks and commas
     76 #SYSTEM MODULES#
     77 import sys
     78 import os
     79 import argparse
     80 #NETWORK MODULES#
     81 import httplib
     82 import socket
     83 import urllib2
     84 import requests
     85 from urllib2 import Request, urlopen, URLError, HTTPError
     86 #STYLE MODULES#
     87 import colorama
     88 from colorama import Fore, Back, Style
     89 
     90 # CODE:
     91 
     92 def logo(): #logo - patorjk.com
     93 	print("MCD's")
     94 	print("_________        .__  .__         .__    .___     ")
     95 	print("\_   ___ \  ____ |  | |  |   ____ |__| __| _/____  ")
     96 	print("/    \  \/ /  _ \|  | |  |  /  _ \|  |/ __ |/ __ \ ")
     97 	print("\     \___(  <_> )  |_|  |_(  <_> )  / /_/ \  ___/")
     98 	print(" \______  /\____/|____/____/\____/|__\____ |\___  >")
     99 	print("        \/                                \/    \/ ")
    100 def checkasciilogo():
    101 	check_value = open("ascii_disable_option_value.txt","r")
    102 	checkvalue = check_value.read(1)
    103 	if checkvalue == "0":
    104 		logo()
    105 	check_value.close()
    106 def banner(): #banner with logo - patorjk.com
    107 	checkasciilogo()
    108 	print("MCD's")
    109 	print("Colloide v 1.0.1")
    110 	print("MD 2017")
    111 	print("www.greekhacking.gr\n\n")
    112 def opts():
    113 	print("  --robots        Check for robots.txt file")
    114 	print("    -u --URL      The URL to the website")
    115 	print("    -c --content  Display contents of robots.txt")
    116 	print("    -d --dump     Dump the contents to a text file\n")
    117 	print("  --status        Use the HTTP status code method (Faster)")
    118 	print("  --urlerror      Use the HTTP/URL error method (More reliable)")
    119 	print("    -h --help     Display the help panel (Shown right now)")
    120 	print("    -u --URL      The URL to the website")
    121 	print("    -f --folder   Directory to search in")
    122 	print("    -p --pages    Path to the wordlist with the page names / links")
    123 	print("    -l --legals   License & legal disclaimer")
    124 	print("    -s --save     Save pages on a text file (name of the file)")
    125 	print("    -L --limit    Add limit to the pages (Integer)")
    126 	print("    -v --verbose  Show all attempts\n")
    127 	print("    -a --ascii    Enable/Disable ASCII\n\n")
    128 def legals():
    129 	#License
    130 	print("MCD's Colloide version 1.0.1 is free software. It can be re-distributed ")
    131 	print("and / or modified under the terms of the GNU General Public License")
    132 	print("as published by the Free Software Foundation; For more information")
    133 	print("read the GNU General Public License that comes")
    134 	print("along with this program.\n\n")
    135 	#Disclaimer
    136 	print("[!] Legal Disclaimer [!]")
    137 	print("Information distributed by this tool may be used maliciously.")
    138 	print("The developer has no responsibility for any damage caused by")
    139 	print("this script or any unauthorized use of it.\n")
    140 def wolf():
    141 	#prints the ASCII colloide wolf
    142 	print(" ___________________      ,     ,")
    143 	print("[ COLLOIDE MISSION! ]     |\---/|       __--__")
    144 	print("                         /      [     ,:',.  (`. ")
    145 	print("                    __.-'|      /    |  `'_.   .|")
    146 	print("           __ ___.-'         \__)   |   _ : () _ |")
    147 	print("        .-'  '        :   :  _/      |    .  .  |")
    148 	print("       / ,    .        .   _ |        ':_)  ,_|'")
    149 	print("      :  ;    :        :   _/             --   ")
    150 	print("      |  |   .'     __:   /      ")
    151 	print("      |  :   /'----'| \  |              __________")
    152 	print("      \  |\  |      | /| |_______,-----'")
    153 	print("       '.'| /__,----| \ | ")
    154 	print("_______| /|.'       '.l \\\_")
    155 	print("       || ||             '-'")
    156 	print("       '-''-'\n")
    157 def checkasciiwolf():
    158 	check_value = open("ascii_disable_option_value.txt","r")
    159 	checkvalue = check_value.read(1)
    160 	if checkvalue == "0":
    161 		wolf()
    162 	else:
    163 		print(" ___________________ ")
    164 		print("[ COLLOIDE MISSION! ]\n\n")
    165 	check_value.close()
    166 def robots_check():
    167 	print("MCD's Colloide v1.0.0")
    168 	print("Report bugs: /MichaelDim02/colloide.py/issues")
    169 	print("Robots.txt check function\n")
    170 	print("INFO:")
    171 	print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    172 	print("URL           =       ", URL)
    173 	robots_link = "http://"+URL+"/robots.txt"
    174 	robots_value = False #robots_value - if it has been found or not
    175 	try:
    176 		IP = socket.gethostbyname(URL)
    177 		print("IP            =       ", IP)
    178 		robot = urllib2.urlopen(robots_link)
    179 		print("robots        =        True")
    180 		robots_value = True
    181 		#robots_value - if it has been found or not
    182 
    183 	#if it encouters url error or httperror / exception robots.txt doesn't exist and it prints false
    184 	#WARNING: This could also mean the given URL is not correct
    185 	#so it is prevented like so:
    186 	except socket.gaierror:
    187 		print("[!] Incorrect URL address")
    188 	except URLError as e:
    189 		print("robots        =        False")
    190 		robots_value = False
    191 	except HTTPError as e:
    192 		print("robots        =        False")
    193 		robots_value = False
    194 	print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
    195 	if robots_value == True:
    196 		contentspage = robot.read()
    197 		#the content that will be dumped / displayed
    198 		if content:
    199 			print("CONTENT:")
    200 			print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
    201 			print(contentspage)
    202 			print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    203 		if dump:
    204 			dump_name = "robots_%s.txt" % URL
    205 			rf = open(dump_name, "w+")
    206 			rf.write(str(contentspage))
    207 			rf.close()
    208 			print("\nCONTENT DUMPED AT: ", dump_name)
    209 
    210 def scan_start():
    211 	print(Fore.RED + Style.BRIGHT + "[!] Report bugs: /MichaelDim02/colloide.py/issues \n" + Style.RESET_ALL)
    212 
    213 	print(Fore.RED + Style.BRIGHT + "[!] Press Ctrl + C to terminate the process.\n" + Style.RESET_ALL)
    214 
    215 def check_names(infile):    #Checking the path to the wordlist
    216 	if os.path.exists(infile):
    217 		if status_method:
    218 			banner()    #calls the banner function
    219 			checkasciiwolf()      #calls the sexy ASCII wolf wallpaper
    220 			statusfindAdmin() #calls the function that basically does the job
    221 		elif error_method:
    222 			banner()
    223 			checkasciiwolf()
    224 			findAdmin()
    225 	else: #in case wordlist cant be found
    226 		banner()
    227 		opts()
    228 		print(Fore.RED + Style.BRIGHT + "[-] Invalid path to the wordlist. File could not be found.\n" + Style.RESET_ALL)
    229 # THIS IS THE STATUS CODE METHOD
    230 def statusfindAdmin():
    231 	if txt:
    232 		tfilename = txt
    233 		f = open(str(tfilename) ,'w+')
    234 		f.write("MCD's Colloide v1.0.1\n")
    235 		f.write("Greece 2017\n")
    236 		f.write("greekhacking.gr\n")
    237 		print("\n")
    238 	scan_start()
    239 	try:
    240 		IP = socket.gethostbyname(URL)
    241 		print(Fore.RED + Style.BRIGHT + "[!] Attacking host: ", IP, " - ", URL, "\n" + Style.RESET_ALL)
    242 		if txt:
    243 			f.write("Attacking:\n")
    244 			f.write("\n")
    245 			f.write(str(URL))
    246 			f.write("\n")
    247 			f.write(str(IP))
    248 			f.write("\n\n")
    249 	except socket.gaierror:
    250 		print(Fore.RED + Style.BRIGHT + "[!] Invalid URL address. Connection could not be established;\n" + Style.RESET_ALL)
    251 		sys.exit(0)
    252 	fi = open(links,"r");
    253 	found = 0
    254 	while (found <= int(limit)):
    255 		try:
    256 			sub_link = fi.readline() #Page name
    257 			if not sub_link:
    258 				break
    259 			link = URL #website name
    260 			req_link = "http://"+link+"/"+sub_link #Final link for attempt
    261 			if directory:
    262 				req_link = "http://"+link+directory+sub_link
    263 			req = Request(req_link)
    264 			con_link = link + "/" + sub_link
    265 			con_ = requests.head(req_link)
    266 			int_status_code_ = con_.status_code
    267 			status_code_ = str(int_status_code_)
    268 			notworking = "[ATTEMPT] - "+ status_code_ + " - " + req_link
    269 			unauth = "[ANAUTHORIZED] - "+ status_code_+ " - " + req_link
    270 			forbid = "[FORBIDDEN] - " + status_code_ + " - " + req_link
    271 			if status_code_.startswith("4"):
    272 				if ver:
    273 					if int_status_code_ == 401:
    274 						print(Fore.RED + unauth.rstrip() + Style.RESET_ALL)
    275 					elif int_status_code_ == 403:
    276 						print(Fore.RED + forbid.rstrip() + Style.RESET_ALL)
    277 					else:
    278 						print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL)
    279 					#notworking.rstrip() So it does not print lines between attempt output line
    280 					#identifies links that show up HTTP error
    281 			else:
    282 				if ver != True:
    283 					print("[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "")
    284 					# if verbose if off
    285 				if ver:
    286 					print("\n[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "")
    287 					#because in verbose mode failed attempts don't have \n at the end
    288 				found = found + 1
    289 				if txt:
    290 					f = open(str(tfilename) ,'a')
    291 					f.write(req_link + "\n")
    292 				else:
    293 					pass
    294 		except KeyboardInterrupt:
    295 			print(Fore.RED + Style.BRIGHT + "\n[!] Process has been terminated - Ctrl + C has been pressed.\n" + Style.RESET_ALL)
    296 			if txt:
    297 				print("All working pages have been saved at: ", tfilename, "\n")
    298 			sys.exit(0)
    299 	if found > int(limit):
    300 		print(Fore.RED + Style.BRIGHT + "[!] Process has been terminated due to the limitation that has been set\n" + Style.RESET_ALL)
    301 	if txt:
    302 		print("All working pages have been saved at: ", tfilename, "\n")
    303 		f.close()
    304 # THIS IS THE HTTP/URL ERROR METHOD
    305 def findAdmin():
    306 	if txt:
    307 		tfilename = txt
    308 		f = open(str(tfilename) ,'w+')
    309 		f.write("MCD's Colloide v1.0.1\n")
    310 		f.write("MD\n")
    311 		f.write("greekhacking.gr\n")
    312 		print("\n")
    313 	scan_start()
    314 	try:
    315 		IP = socket.gethostbyname(URL)
    316 		print(Fore.RED + Style.BRIGHT + "[!] Attacking host: ", IP, " - ", URL, "\n" + Style.RESET_ALL)
    317 		if txt:
    318 			f.write("Attacking:\n")
    319 			f.write("\n")
    320 			f.write(str(URL))
    321 			f.write("\n")
    322 			f.write(str(IP))
    323 			f.write("\n\n")
    324 	except socket.gaierror:
    325 		print(Fore.RED + Style.BRIGHT + "[!] Invalid URL address. Connection could not be established;\n" + Style.RESET_ALL)
    326 		sys.exit(0)
    327 	fi = open(links,"r");
    328 	found = 0
    329 	while (found <= int(limit)):
    330 		try:
    331 			sub_link = fi.readline() #Page name
    332 			if not sub_link:
    333 				break
    334 			link = URL #website name
    335 			req_link = "http://"+link+"/"+sub_link #Final link for attempt
    336 			if directory:
    337 				req_link = "http://"+link+directory+sub_link
    338 			req = Request(req_link)
    339 			if ver:
    340 				notworking = "[ATTEMPT] - " + req_link
    341 				#notworking.rstrip() So it does not print lines between attempt output line
    342 			#identifies links that show up HTTP error
    343 			try:
    344 				response = urlopen(req)
    345 			except HTTPError as e:
    346 				if ver:
    347 					print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL) 
    348 				continue
    349 			except URLError as e:
    350 				if ver:
    351 					print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL)
    352 				continue
    353 			else: #prints working link
    354 				if ver != True:
    355 					print("[+] Link Found" + " -> " + req_link + "")
    356 					# if verbose if off
    357 				if ver:
    358 					print("\n[+] Link Found" + " -> " + req_link + "")
    359 					#because in verbose mode failed attempts don't have \n at the end
    360 				found = found + 1
    361 				if txt:
    362 					f = open(str(tfilename) ,'a')
    363 					f.write(req_link + "\n")
    364 				else:
    365 					pass
    366 		except KeyboardInterrupt:
    367 			print(Fore.RED + Style.BRIGHT + "\n[!] Process has been terminated - Ctrl + C has been pressed.\n" + Style.RESET_ALL)
    368 			if txt:
    369 				print("All working pages have been saved at: ", tfilename, "\n")
    370 			sys.exit(0)
    371 	if found > int(limit):
    372 		print(Fore.RED + Style.BRIGHT + "[!] Process has been terminated due to the limitation that has been set\n" + Style.RESET_ALL)
    373 	if txt:
    374 		print("All working pages have been saved at: ", tfilename, "\n")
    375 
    376 def change_ascii():
    377 	ascii_file = open("ascii_disable_option_value.txt", "r")
    378 	checkascii = ascii_file.read(1)
    379 	ascii_file.close()
    380 	changeascii = open("ascii_disable_option_value.txt", "w")
    381 	if checkascii == "1":
    382 		changeascii.write("0")
    383 		print("[+] ASCII enabled")
    384 	elif checkascii == "0":
    385 		changeascii.write("1")
    386 		print("[+] ASCII disabled")
    387 
    388 #Argument parsing
    389 parser = argparse.ArgumentParser()
    390 parser.add_argument("--robots", action="store_true", help="Check for robots.txt file")
    391 parser.add_argument("-d", "--dump", action="store_true", help="Dump the contents to a text file")
    392 parser.add_argument("-c", "--content", action="store_true", help="Display the contents of robots.txt")
    393 #robots exclusive
    394 parser.add_argument("--status", action="store_true", help="Use the HTTP status code method")
    395 parser.add_argument("--urlerror", action="store_true", help="Use the HTTP/URL error method")
    396 parser.add_argument("-u", "--URL", help="The URL to the website")
    397 parser.add_argument("-f", "--folder", help="Directory to search in (must end and start with '/')")
    398 parser.add_argument("-p", "--pages", help="Path to the wordlist with the page names / links")
    399 parser.add_argument("-l", "--legals", action='store_true', help="License & legal disclaimer")
    400 parser.add_argument("-s", "--save", help="Save all working pages on a text file")
    401 parser.add_argument("-L", "--limit", help="Add limit to the pages. Integer", default="10")
    402 parser.add_argument("-v", "--verbose", help="Show all attempts", action="store_true")
    403 parser.add_argument("-a", "--ascii", help="Enable/Disable ASCII", action="store_true")
    404 
    405 #Declaring Argument Variables
    406 args = parser.parse_args()
    407 status_method = args.status
    408 error_method = args.urlerror
    409 links = args.pages
    410 URL = args.URL
    411 directory = args.folder
    412 txt = args.save
    413 limit = args.limit
    414 ver = args.verbose
    415 ascii = args.ascii
    416 #robots exclusive options / arguments
    417 robots = args.robots
    418 dump = args.dump
    419 content = args.content
    420 
    421 if error_method:
    422 	status_method = False
    423 	robots = False
    424 elif error_method == False:
    425 	status_method = True
    426 	robots = False
    427 elif error_method == False and status_method == False:
    428 	robots = True
    429 
    430 if args.URL and args.pages:
    431 	check_names(links)
    432 elif args.robots and args.URL:
    433 	robots_check()
    434 elif args.legals:
    435 	banner()
    436 	legals()
    437 elif args.ascii:
    438 	change_ascii()
    439 else:
    440 	banner()
    441 	opts()
    442 print("Usage:  python colloide100.py --[method] -u [URL] -p [WORDLIST] -s [TEXT FILE] -L [NUMBER] -v")
    443 print("Robots: python colloide100.py --robots -u [URL] -d -c")
    444 
    445 #
    446 #   MCD's
    447 #   Colloide v1.0.1
    448 #   Can be modified
    449 #   Can be distributed commercially
    450 #   Can be distributed non-commercially
    451 #   Under the terms of the GNU general public license (2007)
    452 #   Project on GitHub:
    453 #	http://yamechanic.com/C3vc
    454 #   Website:
    455 #	http://yamechanic.com/C41V
    456 #
    457 # # # # # # # # # # # # # # # # # # # # # # # # #