# Path: wifiphisher/common/constants.py
# BIRTHDAY = "01-05"
# 
# CHANNEL = 6
# 
# DEAUTH_EXTENSION = "deauth"
# 
# DEFAULT_EXTENSIONS = [DEAUTH_EXTENSION]
# 
# DEV = 1
# 
# DN = open(os.devnull, 'w')
# 
# G = '\033[32m'  # green
# 
# HANDSHAKE_VALIDATE_EXTENSION = "handshakeverify"
# 
# INTERFERING_PROCS = [
#     "wpa_action", "wpa_supplicant", "wpa_cli", "dhclient", "ifplugd", "dhcdbd",
#     "dhcpcd", "udhcpc", "avahi-autoipd", "avahi-daemon", "wlassistant",
#     "wifibox", "NetworkManager", "knetworkmanager"
# ]
# 
# KNOWN_BEACONS_EXTENSION = "knownbeacons"
# 
# LOGGING_CONFIG = {
#     'version': 1,
#     # Defined the handlers
#     'handlers': {
#         'file': {
#             'class': 'logging.handlers.RotatingFileHandler',
#             'level': LOG_LEVEL,
#             'formatter': 'detailed',
#             'filename': LOG_FILEPATH,
#             'backupCount': 3,
#         },
#     },
#     # fomatters for the handlers
#     'formatters': {
#         'detailed': {
#             'format': '%(asctime)s - %(name) 32s - %(levelname)s - %(message)s'
#         },
#     },
#     'root': {
#         'level': 'DEBUG',
#         'handlers': [
#             'file',
#         ],
#     },
#     "loggers": {},
#     'disable_existing_loggers': False
# }
# 
# LURE10_EXTENSION = "lure10"
# 
# MAC_PREFIX_FILE = dir_of_data + "wifiphisher-mac-prefixes"
# 
# NETWORK_GW_IP = "10.0.0.1"
# 
# NEW_YEAR = "01-01"
# 
# O = '\033[33m'  # orange
# 
# PORT = 8080
# 
# R = '\033[31m'  # red
# 
# ROGUEHOSTAPDINFO = "roguehostapdinfo"
# 
# SSL_PORT = 443
# 
# T = '\033[93m'  # tan
# 
# W = '\033[0m'  # white (normal)
# 
# WEBSITE = "https://wifiphisher.org"
# 
# WPSPBC = "wpspbc"


import argparse
import curses
import fcntl
import logging
import logging.config
import os
import signal
import socket
import struct
import subprocess
import sys
import time
import wifiphisher.common.accesspoint as accesspoint
import wifiphisher.common.extensions as extensions
import wifiphisher.common.firewall as firewall
import wifiphisher.common.globals as universal
import wifiphisher.common.interfaces as interfaces
import wifiphisher.common.macmatcher as macmatcher
import wifiphisher.common.opmode as opmode
import wifiphisher.common.phishinghttp as phishinghttp
import wifiphisher.common.phishingpage as phishingpage
import wifiphisher.common.recon as recon
import wifiphisher.common.tui as tui
import wifiphisher.common.victim as victim
from shutil import copyfile
from subprocess import PIPE, Popen, check_output
from threading import Thread
from six.moves import range, input
from wifiphisher.common.constants import (BIRTHDAY, CHANNEL, DEAUTH_EXTENSION, DEFAULT_EXTENSIONS,
                                          DEV, DN, G, HANDSHAKE_VALIDATE_EXTENSION,
                                          INTERFERING_PROCS, KNOWN_BEACONS_EXTENSION,
                                          LOGGING_CONFIG, LURE10_EXTENSION, MAC_PREFIX_FILE,
                                          NETWORK_GW_IP, NEW_YEAR, O, PORT, R, ROGUEHOSTAPDINFO,
                                          SSL_PORT, T, W, WEBSITE, WPSPBC)

        # EM depends on Network Manager.
        # It has to shutdown first.
        self.em.on_exit()
        # AP depends on NM too.
        self.access_point.on_exit()
        try:
             self.network_manager.on_exit()
        except interfaces.InvalidMacAddressError as err:
            print(("[{0}!{1}] {2}").format(R, W, err))
        self.template_manager.on_exit()
        self.fw.on_exit()

        if os.path.isfile('/tmp/wifiphisher-webserver.tmp'):
            os.remove('/tmp/wifiphisher-webserver.tmp')

        print('[' + R + '!' + W + '] Closing')
        sys.exit(0)

    def start(self):

        today = time.strftime("%Y-%m-%d %H:%M")
        print('[' + T + '*' + W + '] Starting Wifiphisher %s ( %s ) at %s' %
              (VERSION, WEBSITE, today))

        # Show some emotions.
        if BIRTHDAY in today:
            print('[' + T + '*' + W + \
            '] Wifiphisher was first released on this day in 2015! ' \
            'Happy birthday!')

# Path: wifiphisher/common/constants.py
# BIRTHDAY = "01-05"
# 
# CHANNEL = 6
# 
# DEAUTH_EXTENSION = "deauth"
# 
# DEFAULT_EXTENSIONS = [DEAUTH_EXTENSION]
# 
# DEV = 1
# 
# DN = open(os.devnull, 'w')
# 
# G = '\033[32m'  # green
# 
# HANDSHAKE_VALIDATE_EXTENSION = "handshakeverify"
# 
# INTERFERING_PROCS = [
#     "wpa_action", "wpa_supplicant", "wpa_cli", "dhclient", "ifplugd", "dhcdbd",
#     "dhcpcd", "udhcpc", "avahi-autoipd", "avahi-daemon", "wlassistant",
#     "wifibox", "NetworkManager", "knetworkmanager"
# ]
# 
# KNOWN_BEACONS_EXTENSION = "knownbeacons"
# 
# LOGGING_CONFIG = {
#     'version': 1,
#     # Defined the handlers
#     'handlers': {
#         'file': {
#             'class': 'logging.handlers.RotatingFileHandler',
#             'level': LOG_LEVEL,
#             'formatter': 'detailed',
#             'filename': LOG_FILEPATH,
#             'backupCount': 3,
#         },
#     },
#     # fomatters for the handlers
#     'formatters': {
#         'detailed': {
#             'format': '%(asctime)s - %(name) 32s - %(levelname)s - %(message)s'
#         },
#     },
#     'root': {
#         'level': 'DEBUG',
#         'handlers': [
#             'file',
#         ],
#     },
#     "loggers": {},
#     'disable_existing_loggers': False
# }
# 
# LURE10_EXTENSION = "lure10"
# 
# MAC_PREFIX_FILE = dir_of_data + "wifiphisher-mac-prefixes"
# 
# NETWORK_GW_IP = "10.0.0.1"
# 
# NEW_YEAR = "01-01"
# 
# O = '\033[33m'  # orange
# 
# PORT = 8080
# 
# R = '\033[31m'  # red
# 
# ROGUEHOSTAPDINFO = "roguehostapdinfo"
# 
# SSL_PORT = 443
# 
# T = '\033[93m'  # tan
# 
# W = '\033[0m'  # white (normal)
# 
# WEBSITE = "https://wifiphisher.org"
# 
# WPSPBC = "wpspbc"


# Path: wifiphisher/pywifiphisher.py
import argparse
import curses
import fcntl
import logging
import logging.config
import os
import signal
import socket
import struct
import subprocess
import sys
import time
import wifiphisher.common.accesspoint as accesspoint
import wifiphisher.common.extensions as extensions
import wifiphisher.common.firewall as firewall
import wifiphisher.common.globals as universal
import wifiphisher.common.interfaces as interfaces
import wifiphisher.common.macmatcher as macmatcher
import wifiphisher.common.opmode as opmode
import wifiphisher.common.phishinghttp as phishinghttp
import wifiphisher.common.phishingpage as phishingpage
import wifiphisher.common.recon as recon
import wifiphisher.common.tui as tui
import wifiphisher.common.victim as victim
from shutil import copyfile
from subprocess import PIPE, Popen, check_output
from threading import Thread
from six.moves import range, input
from wifiphisher.common.constants import (BIRTHDAY, CHANNEL, DEAUTH_EXTENSION, DEFAULT_EXTENSIONS,
                                          DEV, DN, G, HANDSHAKE_VALIDATE_EXTENSION,
                                          INTERFERING_PROCS, KNOWN_BEACONS_EXTENSION,
                                          LOGGING_CONFIG, LURE10_EXTENSION, MAC_PREFIX_FILE,
                                          NETWORK_GW_IP, NEW_YEAR, O, PORT, R, ROGUEHOSTAPDINFO,
                                          SSL_PORT, T, W, WEBSITE, WPSPBC)


        # EM depends on Network Manager.
        # It has to shutdown first.
        self.em.on_exit()
        # AP depends on NM too.
        self.access_point.on_exit()
        try:
             self.network_manager.on_exit()
        except interfaces.InvalidMacAddressError as err:
            print(("[{0}!{1}] {2}").format(R, W, err))
        self.template_manager.on_exit()
        self.fw.on_exit()

        if os.path.isfile('/tmp/wifiphisher-webserver.tmp'):
            os.remove('/tmp/wifiphisher-webserver.tmp')

        print('[' + R + '!' + W + '] Closing')
        sys.exit(0)

    def start(self):

        today = time.strftime("%Y-%m-%d %H:%M")
        print('[' + T + '*' + W + '] Starting Wifiphisher %s ( %s ) at %s' %
              (VERSION, WEBSITE, today))

        # Show some emotions.
        if BIRTHDAY in today:
            print('[' + T + '*' + W + \
            '] Wifiphisher was first released on this day in 2015! ' \
            'Happy birthday!')

        if NEW_YEAR in today: