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