# 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)
                'roguehostapd': self.access_point.hostapd_object,
                'APs': APs_context,
                'args': args
            }

            self.network_manager.up_interface(mon_iface)
            self.em.set_interface(mon_iface)
            extensions = DEFAULT_EXTENSIONS
            if args.lure10_exploit:
                extensions.append(LURE10_EXTENSION)
            if args.handshake_capture:
                extensions.append(HANDSHAKE_VALIDATE_EXTENSION)
            if args.nodeauth:
                extensions.remove(DEAUTH_EXTENSION)
            if args.wps_pbc:
                extensions.append(WPSPBC)
            if args.known_beacons:
                extensions.append(KNOWN_BEACONS_EXTENSION)
            if not args.force_hostapd:
                extensions.append(ROGUEHOSTAPDINFO)
            self.em.set_extensions(extensions)
            self.em.init_extensions(shared_data)
            self.em.start_extensions()
        # With configured DHCP, we may now start the web server
        if not self.opmode.internet_sharing_enabled():
            # Start HTTP server in a background thread
            print('[' + T + '*' + W + '] Starting HTTP/HTTPS server at ports ' + str(
                PORT) + ", " + str(SSL_PORT))
            webserver = Thread(
                target=phishinghttp.runHTTPServer,

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

                'roguehostapd': self.access_point.hostapd_object,
                'APs': APs_context,
                'args': args
            }

            self.network_manager.up_interface(mon_iface)
            self.em.set_interface(mon_iface)
            extensions = DEFAULT_EXTENSIONS
            if args.lure10_exploit:
                extensions.append(LURE10_EXTENSION)
            if args.handshake_capture:
                extensions.append(HANDSHAKE_VALIDATE_EXTENSION)
            if args.nodeauth:
                extensions.remove(DEAUTH_EXTENSION)
            if args.wps_pbc:
                extensions.append(WPSPBC)
            if args.known_beacons:
                extensions.append(KNOWN_BEACONS_EXTENSION)
            if not args.force_hostapd:
                extensions.append(ROGUEHOSTAPDINFO)
            self.em.set_extensions(extensions)
            self.em.init_extensions(shared_data)
            self.em.start_extensions()
        # With configured DHCP, we may now start the web server
        if not self.opmode.internet_sharing_enabled():
            # Start HTTP server in a background thread
            print('[' + T + '*' + W + '] Starting HTTP/HTTPS server at ports ' + str(
                PORT) + ", " + str(SSL_PORT))
            webserver = Thread(
                target=phishinghttp.runHTTPServer,

                args=(NETWORK_GW_IP, PORT, SSL_PORT, template, self.em))