Example #1
0
 def confirm_traffic_routs_through_tor(cls):
     rh = RequestHandler()
     try:
         page = rh.send("GET", url="https://check.torproject.org")
         if "Congratulations. This browser is configured to use Tor." in page.text:
             return
         elif "Sorry. You are not using Tor" in page.text:
             raise RaccoonException("Traffic does not seem to be routed through Tor.\nExiting")
     except RequestHandlerException:
         raise RaccoonException("Tor service seems to be down - not able to connect to 127.0.0.1:9050.\nExiting")
Example #2
0
 def validate_executables(cls):
     if not (cls.find_nmap_executable() and cls.find_openssl_executable()):
         raise RaccoonException(
             "Could not find Nmap or OpenSSL "
             "installed. Please install them and run Raccoon again.")
     if system() == "Darwin":
         if not cls.find_mac_gtimeout_executable():
             raise RaccoonException(
                 "To support Raccoon with macOS 'gtimeout' must be installed.\n"
                 "gtimeout can be installed by running 'brew install coreutils'"
             )
     return
Example #3
0
 def validate_proxy_args(cls, *args):
     """No more than 1 of the following can be specified: tor_routing, proxy, proxy_list"""
     supplied_proxies = Counter((not arg for arg in (*args, ))).get(False)
     if not supplied_proxies:
         return
     elif supplied_proxies > 1:
         raise RaccoonException("Must specify only one of the following:\n"
                                "--tor-routing, --proxy-list, --proxy")
Example #4
0
 def parse_cookie_arg(cls, cookie_arg):
     try:
         cookies = {}
         for c in cookie_arg.split(','):
             c = c.split(":")
             cookies[c[0]] = c[1]
         return cookies
     except (IndexError, TypeError):
         raise RaccoonException(
             "Cookie parsing error occurred, probably due to invalid cookie format.\n"
             "Cookie format should be comma separated key:value pairs. Use --help "
             "for more info.")
Example #5
0
 def parse_header_arg(cls, headers_arg):
     try:
         headers = {}
         for h in headers_arg.split(','):
             h = h.split(":")
             headers[h[0]] = h[1]
         return headers
     except (IndexError, TypeError):
         raise RaccoonException(
             "Header parsing error occurred, probably due to invalid header format.\n"
             "Header format should be comma separated key:value pairs. Use --help "
             "for more info.")
Example #6
0
 def validate_target_is_up(cls, host):
     cmd = "ping -c 1 {}".format(host)
     try:
         check_call(cmd.split(), stdout=PIPE, stderr=PIPE)
         return
     except CalledProcessError:
         # Maybe ICMP is blocked. Try web server
         try:
             if "http" not in host:
                 host = "http://" + host
             rh = RequestHandler()
             rh.send("GET", url=host, timeout=10)
             return
         except (ConnectionError, RequestHandlerException):
             raise RaccoonException("Target {} seems to be down.\n"
                                    "Run with --skip-health-check to ignore hosts considered as down.".format(host))
Example #7
0
 def validate_target_is_up(cls, host):
     cmd = "ping -c 1 {}".format(host.target)
     try:
         check_call(cmd.split(), stdout=PIPE, stderr=PIPE)
         return
     except CalledProcessError:
         # Maybe ICMP is blocked. Try web server
         try:
             if host.port == 443 or host.port == 80:
                 url = "{}://{}".format(host.protocol, host.target)
             else:
                 url = "{}://{}:{}".format(host.protocol, host.target,
                                           host.port)
             rh = RequestHandler()
             rh.send("GET", url=url, timeout=15)
             return
         except (ConnectionError, RequestHandlerException):
             raise RaccoonException(
                 "Target {} seems to be down (no response to ping or from a web server"
                 " at port {}).\nRun with --skip-health-check to ignore hosts"
                 " considered as down.".format(host, host.port))
Example #8
0
 def validate_executables(cls):
     if not (cls.find_nmap_executable() and cls.find_openssl_executable()):
         raise RaccoonException(
             "Could not find Nmap or OpenSSL "
             "installed. Please install them and run Raccoon again.")
     return