# -*- coding: utf-8 -*-
from logging import getLogger, ERROR

getLogger("scapy.runtime").setLevel(ERROR)
import argparse
import sys
from PyQt5 import QtCore
from wifipumpkin3 import PumpkinShell
from wifipumpkin3.core.utility.printer import (
    banner,
    setcolor,
    display_messages,
    set_nocolors,
)
from wifipumpkin3.core.utility.collection import SettingsINI
from wifipumpkin3._version import __version__, __codename__
from wifipumpkin3._author import __author__
import wifipumpkin3.core.utility.constants as C
from os import getuid


def parser_args_func(parse_args):
    if parse_args.nocolors:
        set_nocolors()

    if parse_args.wireless_mode:
        if parse_args.wireless_mode in conf.get_all_childname("ap_mode"):
            conf.set_one("ap_mode", parse_args.wireless_mode, True)
            print(
                display_messages(
                    "Wireless Mode: {}".format(
                        setcolor(parse_args.wireless_mode, color="ciano")
                    ),
                    info=True,
                )
            )


def main():

    app = QtCore.QCoreApplication(sys.argv)
    conf = SettingsINI.getInstance()
    parser = argparse.ArgumentParser(
        description="WiFi-Pumpkin - pure line-oriented command"
    )
    parser.add_argument(
        "-i", dest="interface", help="set interface for create AP", default=""
    )
    parser.add_argument(
        "-s", dest="session", help="set session for continue attack", default=None
    )
    parser.add_argument(
        "-p",
        "--pulp",
        dest="pulp",
        help="interactive sessions can be scripted with .pulp file",
        default="",
    )
    parser.add_argument(
        "-x",
        "--xpulp",
        dest="xpulp",
        help='interactive sessions can be string with ";" as the separator',
        default="",
    )
    parser.add_argument(
        "-m",
        "--wireless-mode",
        dest="wireless_mode",
        help="set wireless mode settings",
        default=None,
    )
    parser.add_argument(
        "--no-colors",
        dest="nocolors",
        help="disable terminal colors and effects.",
        action="store_true",
        default=False,
    )
    parser.add_argument(
        "-v",
        "--version",
        action="version",
        dest="version",
        version="%(prog)s v{}".format(__version__),
    )

    parse_args = parser.parse_args()
    parser_args_func(parse_args)

    # check is rootuser
    if not getuid() == 0:
        sys.exit("[!] Wp3 must be run as root.")

    _author = "{}".format(setcolor(__author__, color="yellow"))
    _version = setcolor(__version__, color="yellow")
    _codename = setcolor(__codename__, color="ciano")

    banner(_codename)
    print("Made by: {} - P0cL4bs Team | {} dev".format(_author, _version))
    prompt = PumpkinShell(parse_args)
    prompt.cmdloop("Starting prompt...")
    sys.exit(app.exec_())

# -*- coding: utf-8 -*-
from logging import getLogger, ERROR

getLogger("scapy.runtime").setLevel(ERROR)
import argparse
import sys
from PyQt5 import QtCore
from wifipumpkin3 import PumpkinShell
from wifipumpkin3.core.utility.printer import (
    banner,
    setcolor,
    display_messages,
    set_nocolors,
)
from wifipumpkin3.core.utility.collection import SettingsINI
from wifipumpkin3._version import __version__, __codename__
from wifipumpkin3._author import __author__
import wifipumpkin3.core.utility.constants as C
from os import getuid


def parser_args_func(parse_args):
    if parse_args.nocolors:
        set_nocolors()

    if parse_args.wireless_mode:
        if parse_args.wireless_mode in conf.get_all_childname("ap_mode"):
            conf.set_one("ap_mode", parse_args.wireless_mode, True)
            print(
                display_messages(
                    "Wireless Mode: {}".format(
                        setcolor(parse_args.wireless_mode, color="ciano")
                    ),
                    info=True,
                )
            )


def main():

    app = QtCore.QCoreApplication(sys.argv)
    conf = SettingsINI.getInstance()
    parser = argparse.ArgumentParser(
        description="WiFi-Pumpkin - pure line-oriented command"
    )
    parser.add_argument(
        "-i", dest="interface", help="set interface for create AP", default=""
    )
    parser.add_argument(
        "-s", dest="session", help="set session for continue attack", default=None
    )
    parser.add_argument(
        "-p",
        "--pulp",
        dest="pulp",
        help="interactive sessions can be scripted with .pulp file",
        default="",
    )
    parser.add_argument(
        "-x",
        "--xpulp",
        dest="xpulp",
        help='interactive sessions can be string with ";" as the separator',
        default="",
    )
    parser.add_argument(
        "-m",
        "--wireless-mode",
        dest="wireless_mode",
        help="set wireless mode settings",
        default=None,
    )
    parser.add_argument(
        "--no-colors",
        dest="nocolors",
        help="disable terminal colors and effects.",
        action="store_true",
        default=False,
    )
    parser.add_argument(
        "-v",
        "--version",
        action="version",
        dest="version",
        version="%(prog)s v{}".format(__version__),
    )

    parse_args = parser.parse_args()
    parser_args_func(parse_args)

    # check is rootuser
    if not getuid() == 0:
        sys.exit("[!] Wp3 must be run as root.")

    _author = "{}".format(setcolor(__author__, color="yellow"))
    _version = setcolor(__version__, color="yellow")
    _codename = setcolor(__codename__, color="ciano")

    banner(_codename)
    print("Made by: {} - P0cL4bs Team | {} dev".format(_author, _version))
    prompt = PumpkinShell(parse_args)
    prompt.cmdloop("Starting prompt...")
    sys.exit(app.exec_())

# -*- coding: utf-8 -*- # check is rootuser