Ejemplo n.º 1
0
def runRoot(funcion):

    #funcion()
    if not admin.isUserAdmin():
        #admin.runAsAdmin(cmdLine=funcion())
        admin.runAsAdmin(cmdLine=funcion())
    funcion()
Ejemplo n.º 2
0
 def renameComp(self, name):
     rename_cmd = r'wmic computersystem where name="%computername%" call rename name={0}'.format(name)
     windows_version = getWinV()
     print u'Версия ОС: Windows '+windows_version
     print u'Переименовываем комьютер'
     if windows_version == 'XP':
         self.callBatchFile('\\\\192.168.1.20\\1c_bd\AIDA64\\rename_xp.bat %s' % str(name))
     else:
         if not admin.isUserAdmin():
             admin.runAsAdmin(['\\\\192.168.1.20\\1c_bd\AIDA64\\rename.bat', ' '+str(name)])
Ejemplo n.º 3
0
def test():
    rc = 0
    if not admin.isUserAdmin():
        print(f'You\'re not an admin. {os.getpid()}, params: {sys.argv}')
        #rc = runAsAdmin(["c:\\Windows\\notepad.exe"])
        rc = admin.runAsAdmin()
    else:
        print(f'You are an admin! {os.getpid()} params: {sys.argv}')
        rc = 0
    x = input('Press Enter to exit.')
    return rc
Ejemplo n.º 4
0
    def __init__(self, fileName=None, parent=None):
        super(UnlockDialog, self).__init__(parent)
        if not admin.isUserAdmin():
            admin.runAsAdmin()
            # end the current instance of the program because it isn't uac. Results in two app windows otherwise.
            sys.exit(0)
        self.setupUi(self)
        # print psutil.Process(os.getpid()).parent
        fileArgPos = self._getRelevantCmdArgument(sys.argv)
        if fileArgPos != None:
            self.fileName = sys.argv[fileArgPos]
            self.stackedWidget.setCurrentIndex(0)
            self.setUnlockTextLabel(self.fileName)
            self.sameLocation = False
        # elif self._checkScriptNameInFolder():
        #     parentProcessName = psutil.Process(os.getpid()).parent().exe()
        #     if parentProcessName != "python.exe":
        #         scriptName = os.path.basename(parentProcessName)
        #     else:
        #         scriptName = os.path.basename(__file__)
        #     # get the script name without file extension
        #     scriptName = os.path.splitext(scriptName)[0] + ".exelocker"
        #     self.fileName = os.path.basename(scriptName)
        #     self.sameLocation = False
        #     self.setUnlockTextLabel(self.fileName)
        #     self.stackedWidget.setCurrentIndex(0)
        else:
            self.fileName = None
            self.sameLocation = True
            self.stackedWidget.setCurrentIndex(1)
            if self._argsHasDirectory():
                index = self._getRelevantDirectoryArg()
                self.fillListWidget(sys.argv[index])
            else:
                self.fillListWidget()

        self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
        self.setFixedSize(self.width(), self.height())

        # connect the unlock button
        self.unlockButton.clicked.connect(self.unlockFile)
        # self.passwordLineEdit.returnPressed.connect(self.unlockFile) # <-- This line of code ruined my whole f*****g day
        # The above line made two events fire when the exelocker filename is same as the script name. I don't f*****g understand it. F**K
        self.browseButton.clicked.connect(self.browseFiles)
        self.listWidgetUnlockButton.clicked.connect(self.listWidgetSelectedEvent)





        # connect with the thread
        self.signal.connect(self.fileUnlockedEvent)
Ejemplo n.º 5
0
    def __init__(self, fileName=None, parent=None):
        super(UnlockDialog, self).__init__(parent)
        if not admin.isUserAdmin():
            admin.runAsAdmin()
            # end the current instance of the program because it isn't uac. Results in two app windows otherwise.
            sys.exit(0)
        self.setupUi(self)
        # print psutil.Process(os.getpid()).parent
        fileArgPos = self._getRelevantCmdArgument(sys.argv)
        if fileArgPos != None:
            self.fileName = sys.argv[fileArgPos]
            self.stackedWidget.setCurrentIndex(0)
            self.setUnlockTextLabel(self.fileName)
            self.sameLocation = False
        # elif self._checkScriptNameInFolder():
        #     parentProcessName = psutil.Process(os.getpid()).parent().exe()
        #     if parentProcessName != "python.exe":
        #         scriptName = os.path.basename(parentProcessName)
        #     else:
        #         scriptName = os.path.basename(__file__)
        #     # get the script name without file extension
        #     scriptName = os.path.splitext(scriptName)[0] + ".exelocker"
        #     self.fileName = os.path.basename(scriptName)
        #     self.sameLocation = False
        #     self.setUnlockTextLabel(self.fileName)
        #     self.stackedWidget.setCurrentIndex(0)
        else:
            self.fileName = None
            self.sameLocation = True
            self.stackedWidget.setCurrentIndex(1)
            if self._argsHasDirectory():
                index = self._getRelevantDirectoryArg()
                self.fillListWidget(sys.argv[index])
            else:
                self.fillListWidget()

        self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint
                            | QtCore.Qt.WindowTitleHint)
        self.setFixedSize(self.width(), self.height())

        # connect the unlock button
        self.unlockButton.clicked.connect(self.unlockFile)
        # self.passwordLineEdit.returnPressed.connect(self.unlockFile) # <-- This line of code ruined my whole f*****g day
        # The above line made two events fire when the exelocker filename is same as the script name. I don't f*****g understand it. F**K
        self.browseButton.clicked.connect(self.browseFiles)
        self.listWidgetUnlockButton.clicked.connect(
            self.listWidgetSelectedEvent)

        # connect with the thread
        self.signal.connect(self.fileUnlockedEvent)
Ejemplo n.º 6
0
 def __init__(self, parent=None):
     super(LockerDialog, self).__init__(parent)
     if _ISPRODUCTION_:
         if not admin.isUserAdmin():
           admin.runAsAdmin()
           sys.exit(0)
     self.setupUi(self)
     self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
     self.setFixedSize(self.width(), self.height())
     self.lockButton.setEnabled(False)  # lock the exe button still password is set
     self.pickFileButton.clicked.connect(self.showFileDialog)
     self.passwordLineEdit.textChanged.connect(self.checkPasswordMatch)
     self.passwordAgainLineEdit.textChanged.connect(self.checkPasswordMatch)
     self.lockButton.clicked.connect(self._lockFile)
     # Connect to threadDone event
     self.signal.connect(self.fileLockedEvent)
Ejemplo n.º 7
0
    def setup(self):
        """ Adds 'Create Tabs' and 'Save' buttons to frame
                
            Establishes a dictionary with keys consisting of the available
            variables

            Each variable key maps to that variable's radiobutton and
            string variable

            If the user is running the program as admin then the radiobutton
            will display global "variable" if not then local "variable"

            The radiobutton will also decide if the user wishes to change
            the variable at all"""

        admin = isUserAdmin()
        
        self.bttn1 = self.button(self, "Create Tabs", self.create)
        self.bttn2 = self.button(self, "Save", self.save)
        
        self.bttn1.grid(row=0, column=0, sticky="nesw")
        self.bttn2.grid(row=0, column=1, sticky="nesw")

        self.vars = {}
        variables = available_variables()
        rows = range(1, len(variables)+1)
        
        for var, row in zip(variables, rows):

            varlist = self.vars[var] = [tk.StringVar(),]
            strvar = varlist[0]

            loc = "local"
            glo = "global"
            
            if admin: priviledges = glo
            else: priviledges = loc

            txt = "{}{}{}".format(priviledges, " ", var)
            
            event = "<Button-3>"

            varlist.append(self.radiobutton(self, txt, strvar, priviledges))
            varlist[1].bind(event, lambda e: e.widget.deselect())
            
            varlist[1].grid(row=row, column=0, columnspan=2, sticky="ew")
Ejemplo n.º 8
0
 def __init__(self, parent=None):
     super(LockerDialog, self).__init__(parent)
     if _ISPRODUCTION_:
         if not admin.isUserAdmin():
             admin.runAsAdmin()
             sys.exit(0)
     self.setupUi(self)
     self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint
                         | QtCore.Qt.WindowTitleHint)
     self.setFixedSize(self.width(), self.height())
     self.lockButton.setEnabled(
         False)  # lock the exe button still password is set
     self.pickFileButton.clicked.connect(self.showFileDialog)
     self.passwordLineEdit.textChanged.connect(self.checkPasswordMatch)
     self.passwordAgainLineEdit.textChanged.connect(self.checkPasswordMatch)
     self.lockButton.clicked.connect(self._lockFile)
     # Connect to threadDone event
     self.signal.connect(self.fileLockedEvent)
Ejemplo n.º 9
0
def Install_VLC(VLC_PATH):

    if not admin.isUserAdmin():
        admin.runAsAdmin()

    print 'VLC 설치 시작'
    try:
        os.chdir(os.path.join(os.getcwd(), os.path.dirname((sys.argv[0]))))
        app = application.Application()
        app.Start(VLC_PATH)
        app.WaitCPUUsageLower()
    except application.AppStartError as er:
        print str(er)

    try :
        language_window = app.Connect(title=u'Installer Language', class_name='#32770').Dialog
        print 'Choose Language'
        language_window[u'OK'].Click()
    except findwindows.WindowNotFoundError as er:
        InstallWindow =  app.Connect(title=u'VLC media player \uc124\uce58', class_name='#32770').Dialog
        InstallWindow[u'\ucde8\uc18cButton'].Click()
        time.sleep(0.5)
        InstallWindow[u'\uc608(&Y)Button'].Click()
        print 'Already Installed'
        exit(1)

    print 'Choose Install or Not'
    language_window[u'\ub2e4\uc74c >'].Click()

    print 'Confirm License'
    language_window[u'\ub2e4\uc74c >'].Click()

    print 'Check Component'
    language_window[u'\ub2e4\uc74c >'].Click()

    print 'Choose Install Location'
    language_window[u'\uc124\uce58'].Click()
    app.WaitCPUUsageLower()

    print 'Install End Dialog'
    language_window[u'\ub9c8\uce68'].Click()

    print 'Compelete Install'
Ejemplo n.º 10
0
def csharp_symlinks(args):
    dirname = os.path.dirname(args.project_file)
    engine_path = get_engine_path()

    symlinks = []
    SymlinkFileName = os.path.join(dirname, 'Code', 'CryManaged', 'CESharp')
    TargetFileName = os.path.join(engine_path, 'Code', 'CryManaged', 'CESharp')
    symlinks.append((SymlinkFileName, TargetFileName))

    SymlinkFileName = os.path.join(dirname, 'bin', args.platform,
                                   'CryEngine.Common.dll')
    TargetFileName = os.path.join(engine_path, 'bin', args.platform,
                                  'CryEngine.Common.dll')
    symlinks.append((SymlinkFileName, TargetFileName))

    create_symlinks = []
    for (SymlinkFileName, TargetFileName) in symlinks:
        if os.path.islink(SymlinkFileName):
            if os.path.samefile(SymlinkFileName, TargetFileName):
                continue
        elif os.path.exists(SymlinkFileName):
            error_unable_to_replace_file(SymlinkFileName)

        create_symlinks.append((SymlinkFileName, TargetFileName))

    if create_symlinks and not admin.isUserAdmin():
        cmdline = getattr(sys, 'frozen', False) and sys.argv or None
        rc = admin.runAsAdmin(cmdline)
        sys.exit(rc)

    for (SymlinkFileName, TargetFileName) in create_symlinks:
        if os.path.islink(SymlinkFileName):
            os.remove(SymlinkFileName)

        sym_dirname = os.path.dirname(SymlinkFileName)
        if not os.path.isdir(sym_dirname):
            os.makedirs(sym_dirname)

        SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
        dwFlags = os.path.isdir(
            TargetFileName) and SYMBOLIC_LINK_FLAG_DIRECTORY or 0x0
        win32file.CreateSymbolicLink(SymlinkFileName, TargetFileName, dwFlags)
Ejemplo n.º 11
0
 def listen(self, binlist):
     """
     Listen for the execution of a list of
     binaries
     """
     if binlist is None or binlist == []:
         print "Empty list of binaries"
         return
     # This module must be executed as administrator
     if not admin.isUserAdmin():
         print "ERROR: Please run uacamola as ADMINISTRATOR"
         return
     registry = Registry()
     self.add_debugger(registry, binlist)
     # Creating a thread that will create the listeners
     create_listeners = Process(target=self._create_listeners, args=())
     create_listeners.start()
     # Waiting for exiting
     raw_input("\n--- Press ENTER for quit mitigate mode ---\n\n")
     self.del_debugger(registry, binlist)
     return
Ejemplo n.º 12
0
    def setAssoc(self):
        if platform.system() == "Linux":
            os.system(
                "xdg-mime default kmtorrent.desktop x-scheme-handler/magnet")
            return

        if not admin.isUserAdmin() and platform.system == "Windows":
            msgBox = QtWidgets.QMessageBox()
            msgBox.setIcon(QtWidgets.QMessageBox.Question)
            msgBox.setText("Set Association")
            msgBox.setInformativeText(
                "This feature requires elevated privilieges\nrun this feature in admin mode?"
            )
            msgBox.setStandardButtons(QtWidgets.QMessageBox.Yes
                                      | QtWidgets.QMessageBox.No)
            msgBox.setDefaultButton(QtWidgets.QMessageBox.No)
            reply = msgBox.exec_()
            if reply == QtWidgets.QMessageBox.Yes:
                admin.runAsAdmin(cmdLine=[sys.argv[0]] + ["ADMIN"])

            elif reply == QtWidgets.QMessageBox.No:
                return
        elif platform.system == "Windows":
            change_regedit()
Ejemplo n.º 13
0
#!/usr/bin/env python
#
# Copyright 2015 Joe Janicki
#
from __future__ import print_function
from __future__ import division
import os
import sys
from tkinter import *
from tkinter import filedialog
from urine_blood import process_single, process_batch
import admin

# Need to run as admin in windows
if os.name == 'nt' and not admin.isUserAdmin():
    admin.runAsAdmin()

# Here, we are creating our class, Window, and inheriting from the Frame
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
class Window(Frame):
    '''Defines main window behavior'''
    def __init__(self, master=None):       
        Frame.__init__(self, master)                   
        self.master = master
        self.init_window()

    def init_window(self):     
        self.master.title("Hematuria Spot Detection")
        # allowing the widget to take the full space of the root window
        self.pack(fill=BOTH, expand=1)
        
Ejemplo n.º 14
0
	def unreg():
		
		if not admin.isUserAdmin():
			admin.runAsAdmin()
		win32com.server.register.UnregisterServer(BasicServer._reg_clsid_, BasicServer._reg_progid_)
Ejemplo n.º 15
0
from collections import Counter
from os import walk
import subprocess
import cleverbot
import pythoncom
import datetime
import random
import pyttsx
import admin
import nltk
import time
import time
if not admin.isUserAdmin(): #Needed to bypass win10's crappy admin system
    print "Running as Administrator..."
    admin.runAsAdmin()
from dragonfly.all import Grammar, CompoundRule, Rule
from pygsr import Pygsr


global curTime
global humanResponse

first = True
humanResponse = None
robotTalk = None


memoryDir = "C:\\Hexobot\\Memory\\Conversations\\database.txt"
databaseDir = "C:\\Hexobot\\Memory\\Database\\credentials.txt"
curTime = datetime.datetime.now().time()
Ejemplo n.º 16
0
def isAdmin():
    if not admin.isUserAdmin():
        admin.runAsAdmin()
Ejemplo n.º 17
0
#copyright
import webbrowser
def openlink():
    webbrowser.open('http://facebook.com/3m.2a.1e', new=2)

copyright = Button(top,
    text="created by Mahmoud Elshobaky",
    fg='#DDD',
    bg='gray',
    width=300,
    bd=0,
    command=openlink)
copyright.pack()

# themes and styles
import ttk
style = ttk.Style()
style.theme_use('classic')
# themes ('winnative', 'clam', 'alt', 'default', 'classic')

#make shure the app runs as adminstrator
import admin
if admin.isUserAdmin():
    top.mainloop()
else:
    admin.runAsAdmin()

     


Ejemplo n.º 18
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        # fix size of window
        self.setFixedSize(self.size())
        #################
        currentTime = strftime("%Y.%m.%d %H:%M:%S", gmtime())
        adminStr = "Default user"
        if admin.isUserAdmin():
            adminStr = "Admin"
        self.setWindowTitle("IPRadar2 [" + currentTime + "] " + adminStr)

        # fill combo-box with tshark interfaces
        self.currentInterface = configuration.INTERFACE
        self.tsharkInterfaces = self.sniffer.getInterfaces()
        interfaceNr = 1
        for interface in self.tsharkInterfaces:
            self.comboBoxInterface.addItem(
                str(interfaceNr) + ". " + self.tsharkInterfaces[interface] +
                " " + interface)
            self.tsharkInterfacesList.append(interface)
            # is config IF? then set
            if self.currentInterface in interface:
                self.comboBoxInterface.setCurrentIndex(interfaceNr)
                self.comboBoxInterface.setCurrentText(
                    str(interfaceNr) + ". " +
                    self.tsharkInterfaces[interface] + " " + interface)
            interfaceNr = interfaceNr + 1

        # select default interface
        ########################
        if configuration.INTERFACE != "":
            # configured interface also selected?
            # if not set in combo-box
            if configuration.INTERFACE in self.comboBoxInterface.currentText():
                pass  # config interface is same as selected
            else:
                index = self.comboBoxInterface.getCurrentIndex()
                self.currentInterface = self.tsharkInterfacesList[index]
        else:
            # default first interface
            self.currentInterface = self.tsharkInterfacesList[0]

        # set colors
        self.listWidgetKilledProcesses.setStyleSheet(
            "background-color: lightGray")
        self.listWidgetKilledProcesses.setSelectionMode(
            self.listWidgetKilledProcesses.SingleSelection)
        self.listWidgetNodes.setStyleSheet("background-color: lightGray")
        self.listWidgetNodes.setSelectionMode(
            self.listWidgetNodes.SingleSelection)
        self.ptSelectedIP.setStyleSheet("background-color: lightGray")
        self.comboShowHost.setStyleSheet("background-color: lightGray")

        # init states
        ########
        self.comboShowHost.addItem("")
        self.pbKill.setEnabled(False)
        self.pbPing.setEnabled(False)
        self.pbToggleBounce.setChecked(configuration.BOUNCE)
        self.pbToggleHeatmap.setChecked(configuration.HEATMAP)
        self.cbShowBad.setChecked(configuration.SHOW_HOST_BAD)
        self.cbShowKilled.setChecked(configuration.SHOW_HOST_KILLED)
        self.cbShowMarkers.setChecked(configuration.SHOW_NODES)
        self.cbShowConnections.setChecked(configuration.SHOW_CONNECTIONS)
        self.cbShowConnectionsActive.setChecked(
            configuration.SHOW_CONNECTIONS_ACTIVE)
        self.cbShowInfo.setChecked(configuration.SHOW_INFO)
        self.cbShowGood.setChecked(configuration.SHOW_HOST_GOOD)
        self.cbShowUnresolved.setChecked(configuration.SHOW_HOST_UNKNOWN)
        self.cbShowBadConn.setChecked(configuration.SHOW_CONNECTION_BAD)
        self.cbShowKilledConn.setChecked(configuration.SHOW_CONNECTION_KILLED)
        self.cbShowGoodConn.setChecked(configuration.SHOW_CONNECTION_GOOD)
        self.cbShowUnresolvedConn.setChecked(
            configuration.SHOW_CONNECTION_UNKNOWN)
        self.cbPlot.setChecked(configuration.PLOT)
        self.cbSound.setChecked(configuration.SOUND)
        self.cbKillBad.setChecked(False)
        self.cbShowPing.setChecked(True)
        self.sniffer.pingAuto(self.cbPingAuto.isChecked())
        self.cbPingIP.setChecked(True)
        self.cbKillIP.setChecked(True)
        self.cbAutoScrollNodes.setChecked(configuration.AUTO_SCROLL_NODE_LIST)
        self.statusHostsFailedOld.setText(
            str(self.sniffer.getHostsFailedPast()))
        self.statusHostsResolvedOld.setText(
            str(self.sniffer.getHostsResolvedPast()))
        self.ptSelectedIP.textCursor().setKeepPositionOnInsert(True)
        self.cbPingRandom.setText(
            str(configuration.NR_OF_RANDOM_IPS_TO_PING) + " random IPs")
        self.cbBlockBadInFirewall.setChecked(
            configuration.ADD_FIREWALL_RULE_BLOCK_BAD_IP)
        # if not Admin we disable firewall rule option
        if configuration.RUN_AS_ADMIN == False:
            self.cbBlockBadInFirewall.setEnabled(False)

        #################
        # to upate GUI perdiodically
        #################
        self._thread = self.MyGuiUpdateThread(self)
        self._thread.updated.connect(self.updateGui)
        self._thread.start()
Ejemplo n.º 19
0
def checkAdmin():
    if not admin.isUserAdmin():
      admin.runAsAdmin()
      sys.exit()
Ejemplo n.º 20
0
from matplotlib import cm
from time import localtime

#dependencies
#pywin32
#numpy
#scipy
#python-twitter
#matplotlib
#six
#python-dateutil
#pyparsing
#soundcloud
#PyEphem

if not admin.isUserAdmin():
	admin.runAsAdmin()

callpath = 'C:\\temp\\calls'
imgpath = 'C:\\temp\\imgs'
dirpath = 'C:\\'
existing = os.listdir(callpath)

running = False

checkTime = None

def parse_file_name(file):
	sp = file.split("_")
	lt = localtime()
	tz = ''
Ejemplo n.º 21
0
import winreg
import admin
import os

#print(0)
if not admin.isUserAdmin():
    admin.runAsAdmin(wait=False)
    exit()
#print(0.5)


REG_PATH = r"SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0001"

def set_reg(name, value):
    #try:
    winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, REG_PATH)
    registry_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, REG_PATH, 0, 
                                   winreg.KEY_WRITE)
    winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value)
    winreg.CloseKey(registry_key)
    return True
    #except WindowsError:
    #    return False

def get_reg(name):
    try:
        
        registry_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, REG_PATH, 0,
                                       winreg.KEY_READ)
        
        value, regtype = winreg.QueryValueEx(registry_key, name)
Ejemplo n.º 22
0
def elevate():
    import admin
    if not admin.isUserAdmin():
        # sys.exit()
        admin.runAsAdmin()