from PyQt4.QtGui import *
from PyQt4.QtCore import *
from shutil import move
from time import sleep
from platform import dist
from re import search
from os import geteuid,mkdir,system,path,getcwd,chdir,remove,popen
from sys import argv
if search("/usr/share/",argv[0]):
    chdir("/usr/share/PEH-wifi-attack/")
from Modules.DHCPstarvation import frm_dhcp_Attack,frm_dhcp_main
from Modules.deauth_func import frm_window
from Modules.mac_change_func import frm_mac_generator
from Modules.Probe_func import frm_PMonitor
from Modules.Dns_Func import frm_dnsspoof
from Modules.networksdisc import frm_GetIP
from Modules.AttackUp import frm_update_attack
from Core.check import check_dependencies
from Core.check_privilege import frm_privelege
from Core.Settings import frm_Settings
from Modules.AttackUp import frm_WinSoftUp
from Core.update import frm_Update
from Modules.arps_Posion import frm_Arp_Poison
__author__= "@mh4x0f P0cl4bs Team"
__version__= "0.5.9"
__date_create__= "18/01/2015"
__update__="07/06/2015"
__edited_by__= "h@ck3rb0lt freelancer"
__edited_version__= "0.6.0"
__edited_date__= "25/06/2015"
__edited_update__= "soon as possible"

class frmControl(QMainWindow):
    def __init__(self, parent=None):
        super(frmControl, self).__init__(parent)
        self.form_widget = frm_main(self)
        self.setCentralWidget(self.form_widget)
        self.setWindowTitle("PEH-wifi-attack  " + __edited_version__)
        self.config = frm_Settings()
        self.loadtheme(self.config.XmlThemeSelected())


    def loadtheme(self,theme):
        if theme != "theme2":
            sshFile=("Core/%s.css"%(theme))
            with open(sshFile,"r") as fh:
                self.setStyleSheet(fh.read())
        else:
            sshFile=("Core/%s.css"%(theme))
            with open(sshFile,"r") as fh:
                self.setStyleSheet(fh.read())

    def center(self):
        frameGm = self.frameGeometry()
        centerPoint = QDesktopWidget().availableGeometry().center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())


class frm_main(QWidget):
    def __init__(self, parent = None):
        super(frm_main, self).__init__(parent)
        self.create_sys_tray()
        self.Main = QVBoxLayout()
        self.config = frm_Settings()
        self.module_arp = frm_Arp_Poison()
        self.intGUI()
        self.setGeometry(0, 0, 300, 400)
        self.interface = "wlan"


    def intGUI(self):
        self.myQMenuBar = QMenuBar(self)
        self.myQMenuBar.setFixedWidth(400)
        Menu_file = self.myQMenuBar.addMenu('&File')
        action_settings = QAction('Settings',self)
        action_settings.setShortcut("Ctrl+X")
        action_settings.triggered.connect(self.show_settings)
        exitAction = QAction('Exit', self)
        exitAction.triggered.connect(exit)
        Menu_file.addAction(exitAction)
        Menu_tools =
 self.myQMenuBar.addMenu('&Tools')

        etter_conf = QAction("Edit Etter.dns", self)
        etter_conf.setShortcut("Ctrl+U")
        dns_spoof = QAction("Active Dns Spoof", self)
        dns_spoof.setShortcut("Ctrl+D")
        ettercap = QAction("Active Ettercap", self)
        ettercap.setShortcut("Ctrl+E")
        ssl = QAction("Active Sslstrip ", self)
        ssl.setShortcut("Ctrl+S")
        
btn_drift = QAction("Active DriftNet", self)
        btn_drift.setShortcut("Ctrl+Y")

        etter_conf.triggered.connect(self.Edit_etter)
        dns_spoof.triggered.connect(self.start_dns)
        ettercap.triggered.connect(self.start_etter)
        ssl.triggered.connect(self.start_ssl)
        btn_drift.triggered.connect(self.start_dift)

        Menu_tools.addAction(etter_conf)
        Menu_tools.addAction(dns_spoof)
        Menu_tools.addAction(ettercap)
        Menu_tools.addAction(ssl)
        Menu_tools.addAction(btn_drift)

        Menu_module = self.myQMenuBar.addMenu("&Modules")
        btn_deauth = QAction("Deauth Attack", self)
        btn_deauth.setShortcut("Ctrl+W")
        btn_probe = QAction("Probe Request",self)
        btn_probe.setShortcut("Ctrl+K")
        btn_mac = QAction("Mac Changer", self)
        btn_mac.setShortcut("Ctrl+M")
        btn_ip_list = QAction("Device FingerPrint", self)
        btn_ip_list.setShortcut("Ctrl+G")
        btn_dhcpStar = QAction("DHCP S. Attack",self)
        btn_dhcpStar.setShortcut("Ctrl+H")
        btn_dns = QAction("DNS Spoof M.",self)
        btn_dns.setShortcut("Ctrl+T")
        btn_winup = QAction("Windows Update Attack ",self)
        btn_winup.setShortcut("Ctrl+N")
        btn_arp = QAction("Arp Posion Attack",self)
        btn_arp.setShortcut("ctrl+Q")


        #icons Modules
        action_settings.setIcon(QIcon("rsc/setting.png"))
        btn_arp.setIcon(QIcon("rsc/arp_.png"))
        btn_winup.setIcon(QIcon("rsc/arp.png"))
        btn_dns.setIcon(QIcon("rsc/dns.png"))
        btn_dhcpStar.setIcon(QIcon("rsc/dhcp.png"))
        btn_ip_list.setIcon(QIcon("rsc/scan.png"))
        btn_mac.setIcon(QIcon("rsc/mac.png"))
        btn_probe.setIcon(QIcon("rsc/probe.png"))
        btn_deauth.setIcon(QIcon("rsc/deauth.png"))
        # icons tools
        dns_spoof.setIcon(QIcon("rsc/dns_spoof.png"))
        ettercap.setIcon(QIcon("rsc/ettercap.png"))
        ssl.setIcon(QIcon("rsc/ssl.png"))
        etter_conf.setIcon(QIcon("rsc/etter.png"))
        btn_drift.setIcon(QIcon("rsc/capture.png"))

        btn_probe.triggered.connect(self.showProbe)
        btn_deauth.triggered.connect(self.newwindow)
        btn_mac.triggered.connect(self.form_mac)
        btn_ip_list.triggered.connect(self.form_list)
        btn_dhcpStar.triggered.connect(self.show_dhcpDOS)
        btn_dns.triggered.connect(self.show_dnsManager)
        btn_winup.triggered.connect(self.show_windows_update)
        btn_arp.triggered.connect(self.show_arp_posion)

        Menu_module.addAction(btn_deauth)
        Menu_module.addAction(btn_probe)
        Menu_module.addAction(btn_mac)
        Menu_module.addAction(btn_ip_list)
        Menu_module.addAction(btn_dhcpStar)
        Menu_module.addAction(btn_dns)
        Menu_module.addAction(btn_winup)
        Menu_module.addAction(btn_arp)
        Menu_module.addAction(action_settings)


        Menu_peh_toolkit = self.myQMenuBar.addMenu("&PEH-toolkit")
	btn_tutorial = QAction("PEH-toolkit-Tutorial", self)
        btn_ping = QAction("Start a ping your target", self)
        btn_whois = QAction("Start a whois search",self)
        btn_dork3r = QAction("Dork3r vuln analizer", self)
        btn_sqlmap = QAction("SQLMAP", self)
        btn_hackfacebook = QAction("Hack a facebook account",self)
        btn_wifite = QAction("Hack wpe/wpa wifi",self)
        btn_apf = QAction("Find the admin page control",self)
        btn_nmap = QAction("Launched a scan whit NMAP",self)
        btn_theharvester = QAction("Identify different domain and different emails",self)
        btn_fierce = QAction("Retrieve information about the dns",self)
        btn_footprint = QAction("<<<<Hackerbolt Ultimate Footprint>>>>>",self)
        btn_xerxes = QAction("Shutdown a web site / xerxes tool",self)

	btn_tutorial.triggered.connect(self.start_tutorial)
	btn_ping.triggered.connect(self.start_ping)
	btn_whois.triggered.connect(self.start_whois)
	btn_dork3r.triggered.connect(self.start_dork3r)
	btn_sqlmap.triggered.connect(self.start_sqlmap)
	btn_hackfacebook.triggered.connect(self.start_hackfacebook)
	btn_wifite.triggered.connect(self.start_wifite)
	btn_apf.triggered.connect(self.start_apf)
	btn_nmap.triggered.connect(self.start_nmap)
	btn_theharvester.triggered.connect(self.start_theharvester)
	btn_fierce.triggered.connect(self.start_fierce)
	btn_footprint.triggered.connect(self.start_footprint)
	btn_xerxes.triggered.connect(self.start_xerxes)

	Menu_peh_toolkit.addAction(btn_tutorial)
	Menu_peh_toolkit.addAction(btn_ping)
	Menu_peh_toolkit.addAction(btn_whois)
	Menu_peh_toolkit.addAction(btn_dork3r)
	Menu_peh_toolkit.addAction(btn_sqlmap)
	Menu_peh_toolkit.addAction(btn_hackfacebook)
	Menu_peh_toolkit.addAction(btn_wifite)
	Menu_peh_toolkit.addAction(btn_apf)
	Menu_peh_toolkit.addAction(btn_nmap)
	Menu_peh_toolkit.addAction(btn_theharvester)
	Menu_peh_toolkit.addAct