colloide095.py (14150B)
1 #!/usr/bin/python 2 # 3 # MCD's Colloide v0.9.5 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 # 55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 # 57 # Project on GitHub: 58 # http://yamechanic.com/C3vc 59 # Website: 60 # http://yamechanic.com/C41V 61 # 62 # Report bugs: anivsante2@gmail.com 63 # or /issues if you use github 64 # 65 # # # # # # # # # # # # # # # # # # # # # # # # 66 67 # MODULES / LIBRARIES: 68 69 from __future__ import print_function #because some print functions print quotation marks and commas 70 import sys 71 import argparse 72 import httplib 73 import os 74 import socket 75 import urllib2 76 from urllib2 import Request, urlopen, URLError, HTTPError 77 import colorama 78 from colorama import Fore, Back, Style 79 80 # CODE: 81 82 def banner(): #banner with logo - patorjk.com 83 print("MCD's") 84 print("_________ .__ .__ .__ .___ ") 85 print("\_ ___ \ ____ | | | | ____ |__| __| _/____ ") 86 print("/ \ \/ / _ \| | | | / _ \| |/ __ |/ __ \ ") 87 print("\ \___( <_> ) |_| |_( <_> ) / /_/ \ ___/") 88 print(" \______ /\____/|____/____/\____/|__\____ |\___ >") 89 print(" \/ \/ \/ ") 90 print("MCD's") 91 print("Colloide v 0.9.5") 92 print("MD 2017") 93 print("www.greekhacking.gr\n\n") 94 def opts(): 95 print(" --robots Check for robots.txt file") 96 print(" -u --URL The URL to the website") 97 print(" -c --content Display contents of robots.txt") 98 print(" -d --dump Dump the contents to a text file\n") 99 print(" --status Use the HTTP status code method (Faster)") 100 print(" --urlerror Use the HTTP/URL error method (More reliable)") 101 print(" -h --help Display the help panel (Shown right now)") 102 print(" -u --URL The URL to the website") 103 print(" -p --pages Path to the wordlist with the page names / links") 104 print(" -l --legals License & legal disclaimer") 105 print(" -s --save Save pages on a text file (name of the file)") 106 print(" -L --limit Add limit to the pages (Integer)") 107 print(" -v --verbose Show all attempts\n\n") 108 def legals(): 109 #License 110 print("MCD's Colloide version 0.9.5 is free software. It can be re-distributed ") 111 print("and / or modified under the terms of the GNU General Public License") 112 print("as published by the Free Software Foundation; For more information") 113 print("read the GNU General Public License that comes") 114 print("along with this program.\n\n") 115 #Disclaimer 116 print("[!] Legal Disclaimer [!]") 117 print("Information distributed by this tool may be used maliciously.") 118 print("The developer has no responsibility for any damage caused by") 119 print("this script or any unauthorized use of it.\n") 120 def wolf(): 121 #prints the ASCII colloide wolf 122 print(" ___________________ , ,") 123 print("[ COLLOIDE MISSION! ] |\---/| __--__") 124 print(" / [ ,:',. (`. ") 125 print(" __.-'| / | `'_. .|") 126 print(" __ ___.-' \__) | _ : () _ |") 127 print(" .-' ' : : _/ | . . |") 128 print(" / , . . _ | ':_) ,_|'") 129 print(" : ; : : _/ -- ") 130 print(" | | .' __: / ") 131 print(" | : /'----'| \ | __________") 132 print(" \ |\ | | /| |_______,-----'") 133 print(" '.'| /__,----| \ | ") 134 print("_______| /|.' '.l \\\_") 135 print(" || || '-'") 136 print(" '-''-'\n") 137 def robots_check(): 138 print("MCD's Colloide v0.9.5") 139 print("Report bugs: anivsante2@gmail.com") 140 print("Robots.txt check function\n") 141 print("INFO:") 142 print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") 143 print("URL = ", URL) 144 robots_link = "http://"+URL+"/robots.txt" 145 robots_value = False #robots_value - if it has been found or not 146 try: 147 IP = socket.gethostbyname(URL) 148 print("IP = ", IP) 149 robot = urllib2.urlopen(robots_link) 150 print("robots = True") 151 robots_value = True 152 #robots_value - if it has been found or not 153 154 #if it encouters url error or httperror / exception robots.txt doesn't exist and it prints false 155 #WARNING: This could also mean the given URL is not correct 156 #so it is prevented like so: 157 except socket.gaierror: 158 print("[!] Incorrect URL address") 159 except URLError as e: 160 print("robots = False") 161 robots_value = False 162 except HTTPError as e: 163 print("robots = False") 164 robots_value = False 165 print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") 166 if robots_value == True: 167 contentspage = robot.read() 168 #the content that will be dumped / displayed 169 if content: 170 print("CONTENT:") 171 print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") 172 print(contentspage) 173 print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") 174 if dump: 175 dump_name = "robots_%s.txt" % URL 176 rf = open(dump_name, "w+") 177 rf.write(str(contentspage)) 178 rf.close() 179 print("\nCONTENT DUMPED AT: ", dump_name) 180 181 def scan_start(): 182 print(Fore.RED + Style.BRIGHT + "[!] Report bugs: anivsante2@gmail.com \n" + Style.RESET_ALL) 183 #OR https://github.com/MichaelDim02/colloide.py/issues 184 print(Fore.RED + Style.BRIGHT + "[!] Press Ctrl + C to terminate the process.\n" + Style.RESET_ALL) 185 186 def check_names(infile): #Checking the path to the wordlist 187 if os.path.exists(infile): 188 if status_method: 189 banner() #calls the banner function 190 wolf() #calls the sexy ASCII wolf wallpaper 191 statusfindAdmin() #calls the function that basically does the job 192 elif error_method: 193 banner() 194 wolf() 195 findAdmin() 196 else: #in case wordlist cant be found 197 banner() 198 opts() 199 print(Fore.RED + Style.BRIGHT + "[-] Invalid path to the wordlist. File could not be found.\n" + Style.RESET_ALL) 200 # THIS IS THE STATUS CODE METHOD 201 def statusfindAdmin(): 202 if txt: 203 tfilename = txt 204 f = open(str(tfilename) ,'w+') 205 f.write("MCD's Colloide v0.9.5\n") 206 f.write("Greece 2017\n") 207 f.write("greekhacking.gr\n") 208 print("\n") 209 scan_start() 210 try: 211 IP = socket.gethostbyname(URL) 212 print(Fore.RED + Style.BRIGHT + "[!] Attacking host: ", IP, " - ", URL, "\n" + Style.RESET_ALL) 213 if txt: 214 f.write("Attacking:\n") 215 f.write("\n") 216 f.write(str(URL)) 217 f.write("\n") 218 f.write(str(IP)) 219 f.write("\n\n") 220 except socket.gaierror: 221 print(Fore.RED + Style.BRIGHT + "[!] Invalid URL address. Connection could not be established;\n" + Style.RESET_ALL) 222 sys.exit(0) 223 fi = open(links,"r"); 224 found = 0 225 while (found <= int(limit)): 226 try: 227 con_ = httplib.HTTPConnection(str(URL)) 228 sub_link = fi.readline() #Page name 229 if not sub_link: 230 break 231 link = URL #website name 232 req_link = "http://"+link+"/"+sub_link #Final link for attempt 233 req = Request(req_link) 234 con_link = link + "/" + sub_link 235 con_.request("GET", "/" + str(sub_link)) 236 int_status_code_ = con_.getresponse().status 237 status_code_ = str(int_status_code_) 238 notworking = "[ATTEMPT] - "+ status_code_ + " - " + req_link 239 if status_code_.startswith("4"): 240 if ver: 241 print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL) 242 #notworking.rstrip() So it does not print lines between attempt output line 243 #identifies links that show up HTTP error 244 else: 245 if ver != True: 246 print("[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "") 247 # if verbose if off 248 if ver: 249 print("\n[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "") 250 #because in verbose mode failed attempts don't have \n at the end 251 found = found + 1 252 if txt: 253 f = open(str(tfilename) ,'a') 254 f.write(req_link + "\n") 255 else: 256 pass 257 except KeyboardInterrupt: 258 print(Fore.RED + Style.BRIGHT + "\n[!] Process has been terminated - Ctrl + C has been pressed.\n" + Style.RESET_ALL) 259 if txt: 260 print("All working pages have been saved at: ", tfilename, "\n") 261 sys.exit(0) 262 if found > int(limit): 263 print(Fore.RED + Style.BRIGHT + "[!] Process has been terminated due to the limitation that has been set\n" + Style.RESET_ALL) 264 if txt: 265 print("All working pages have been saved at: ", tfilename, "\n") 266 f.close() 267 # THIS IS THE HTTP/URL ERROR METHOD 268 def findAdmin(): 269 if txt: 270 tfilename = txt 271 f = open(str(tfilename) ,'w+') 272 f.write("MCD's Colloide v0.9.5\n") 273 f.write("Greece 2017\n") 274 f.write("greekhacking.gr\n") 275 print("\n") 276 scan_start() 277 try: 278 IP = socket.gethostbyname(URL) 279 print(Fore.RED + Style.BRIGHT + "[!] Attacking host: ", IP, " - ", URL, "\n" + Style.RESET_ALL) 280 if txt: 281 f.write("Attacking:\n") 282 f.write("\n") 283 f.write(str(URL)) 284 f.write("\n") 285 f.write(str(IP)) 286 f.write("\n\n") 287 except socket.gaierror: 288 print(Fore.RED + Style.BRIGHT + "[!] Invalid URL address. Connection could not be established;\n" + Style.RESET_ALL) 289 sys.exit(0) 290 fi = open(links,"r"); 291 found = 0 292 while (found <= int(limit)): 293 try: 294 con_ = httplib.HTTPConnection(str(URL)) 295 sub_link = fi.readline() #Page name 296 if not sub_link: 297 break 298 link = URL #website name 299 req_link = "http://"+link+"/"+sub_link #Final link for attempt 300 req = Request(req_link) 301 con_link = link + "/" + sub_link 302 con_.request("GET", "/" + str(sub_link)) 303 int_status_code_ = con_.getresponse().status 304 status_code_ = str(int_status_code_) 305 if ver: 306 notworking = "[ATTEMPT] - "+ status_code_ + " - " + req_link 307 #notworking.rstrip() So it does not print lines between attempt output line 308 #identifies links that show up HTTP error 309 try: 310 response = urlopen(req) 311 except HTTPError as e: 312 if ver: 313 print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL) 314 continue 315 except URLError as e: 316 if ver: 317 print(Fore.GREEN + notworking.rstrip() + Style.RESET_ALL) 318 continue 319 else: #prints working link 320 if ver != True: 321 print("[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "") 322 # if verbose if off 323 if ver: 324 print("\n[+] Link Found" + " - " + status_code_ +" -"+ " -> " + req_link + "") 325 #because in verbose mode failed attempts don't have \n at the end 326 found = found + 1 327 if txt: 328 f = open(str(tfilename) ,'a') 329 f.write(req_link + "\n") 330 else: 331 pass 332 except KeyboardInterrupt: 333 print(Fore.RED + Style.BRIGHT + "\n[!] Process has been terminated - Ctrl + C has been pressed.\n" + Style.RESET_ALL) 334 if txt: 335 print("All working pages have been saved at: ", tfilename, "\n") 336 sys.exit(0) 337 if found > int(limit): 338 print(Fore.RED + Style.BRIGHT + "[!] Process has been terminated due to the limitation that has been set\n" + Style.RESET_ALL) 339 if txt: 340 print("All working pages have been saved at: ", tfilename, "\n") 341 342 #Argument parsing 343 parser = argparse.ArgumentParser() 344 parser.add_argument("--robots", action="store_true", help="Check for robots.txt file") 345 parser.add_argument("-d", "--dump", action="store_true", help="Dump the contents to a text file") 346 parser.add_argument("-c", "--content", action="store_true", help="Display the contents of robots.txt") 347 #robots exclusive 348 parser.add_argument("--status", action="store_true", help="Use the HTTP status code method") 349 parser.add_argument("--urlerror", action="store_true", help="Use the HTTP/URL error method") 350 parser.add_argument("-u", "--URL", help="The URL to the website") 351 parser.add_argument("-p", "--pages", help="Path to the wordlist with the page names / links") 352 parser.add_argument("-l", "--legals", action='store_true', help="License & legal disclaimer") 353 parser.add_argument("-s", "--save", help="Save all working pages on a text file") 354 parser.add_argument("-L", "--limit", help="Add limit to the pages. Integer", default="10") 355 parser.add_argument("-v", "--verbose", help="Show all attempts", action="store_true") 356 357 #Declaring Argument Variables 358 args = parser.parse_args() 359 status_method = args.status 360 error_method = args.urlerror 361 links = args.pages 362 URL = args.URL 363 txt = args.save 364 limit = args.limit 365 ver = args.verbose 366 #robots exclusive options / arguments 367 robots = args.robots 368 dump = args.dump 369 content = args.content 370 371 if error_method: 372 status_method = False 373 robots = False 374 elif error_method == False: 375 status_method = True 376 robots = False 377 elif error_method == False and status_method == False: 378 robots = True 379 380 if args.URL and args.pages: 381 check_names(links) 382 elif args.robots and args.URL: 383 robots_check() 384 elif args.legals: 385 banner() 386 legals() 387 else: 388 banner() 389 opts() 390 print("Usage: python colloide095.py --[method] -u [URL] -p [WORDLIST] -s [TEXT FILE] -L [NUMBER] -v") 391 print("Robots: ptyhon colloide095.py --robots -u [URL] -d -c") 392 393 # 394 # MCD's 395 # Colloide v0.9.5 396 # Can be modified 397 # Can be distributed commercially 398 # Can be distributed non-commercially 399 # Under the terms of the GNU general public license (2007) 400 # Project on GitHub: 401 # http://yamechanic.com/C3vc 402 # Website: 403 # http://yamechanic.com/C41V 404 # 405 # # # # # # # # # # # # # # # # # # # # # # # # #