diff --git a/Orchestrator/Orchestrator.py b/Orchestrator/Orchestrator.py index 124369d7..c34aa1e4 100644 --- a/Orchestrator/Orchestrator.py +++ b/Orchestrator/Orchestrator.py @@ -10,6 +10,7 @@ import Server import Timer import Processor import logging +import copy from Settings import Settings #Создать файл логирования diff --git a/Orchestrator/Processor.py b/Orchestrator/Processor.py index f1eb8034..bb525322 100644 --- a/Orchestrator/Processor.py +++ b/Orchestrator/Processor.py @@ -49,6 +49,13 @@ import importlib # "FunctionName":"", # "ArgList":[], # "ArgDict":{} +# }, +# { +# "Type":"WindowsLogon", +# "Domain":"", +# "User":"", +# "Password":"" +# # Return "Result": True - user is logged on, False - user is not logged on # } # ] ################################## @@ -127,7 +134,6 @@ def Activity(inActivity): if lItem["Type"]=="ProcessStart": #Вид активности - запуск процесса #Запись в массив отработанных активностей - lDaemonActivityLogDict[(lItem["activityType"],lActivityDateTime,lItem["processPath"])]={"ActivityStartDateTime":lCurrentDateTime} #Лог mGlobalDict["Processor"]["LogList"].append({"activityType":lItem["activityType"], "activityDateTime":str(lActivityDateTime), "processPath":lItem["processPath"], "activityStartDateTime":str(lCurrentDateTime)}) #Запустить процесс @@ -140,8 +146,6 @@ def Activity(inActivity): if lItem["Type"]=="ProcessStop": #Вид активности - остановка процесса #часовой пояс пока не учитываем - #Запись в массив отработанных активностей - lDaemonActivityLogDict[(lItem["Type"],lActivityDateTime,lItem["Name"])]={"ActivityStartDateTime":lCurrentDateTime} #Сформировать команду на завершение lActivityCloseCommand='taskkill /im '+lItem["processName"] #TODO Сделать безопасную обработку,если параметра нет в конфигурации @@ -166,6 +170,24 @@ def Activity(inActivity): lItem["Result"]=lFunction(*lItem.get("ArgList",[]),**lItem.get("ArgDict",{})) except Exception as e: logging.exception("Loop activity error: module/function not founded") + ################################# + # Windows logon + ################################# + if lItem["Type"] == "WindowsLogon": + import win32security + try: + hUser = win32security.LogonUser( + lItem["User"], + lItem["Domain"], + lItem["Password"], + win32security.LOGON32_LOGON_NETWORK, + win32security.LOGON32_PROVIDER_DEFAULT + ) + except win32security.error: + lItem["Result"] = False + else: + lItem["Result"] = True + ################################### #Set datetime stop lItem["DateTimeUTCStringStop"] = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") ################## diff --git a/Orchestrator/Server.py b/Orchestrator/Server.py index e3f4b52d..dfc4b316 100644 --- a/Orchestrator/Server.py +++ b/Orchestrator/Server.py @@ -1,17 +1,9 @@ from http.server import BaseHTTPRequestHandler, HTTPServer -import pywinauto import json -import subprocess -import time -import zlib -import os -import PIL -from PIL import ImageGrab from threading import Thread import Processor import importlib import pdb -import imp from desktopmagic.screengrab_win32 import ( getDisplayRects, saveScreenToBmp, saveRectToBmp, getScreenAsImage, getRectAsImage, getDisplaysAsImages) @@ -134,6 +126,31 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler): # check if file in FileURL - File Path Mapping Dict if lFileURL.lower() in mGlobalDict["FileManager"]["FileURLFilePathDict"]: self.SendResponseContentTypeFile('application/octet-stream',mGlobalDict["FileManager"]["FileURLFilePathDict"][lFileURL]) + # Auth function + if self.path.lower().startswith('/auth'): + # Send response status code + self.send_response(401) + # Send headers + self.send_header('Content-type','text/html') + self.send_header('WWW-Authenticate', 'Basic') #Always ask login pass + lFlagIsKerberos=False + lHeaderAuthorization = self.headers.get("Authorization","").split(" ") + import base64 + if len(lHeaderAuthorization) == 2: + llHeaderAuthorizationDecodedUserPasswordList = base64.b64decode(lHeaderAuthorization[1]).decode("utf-8").split(":") + lUser = llHeaderAuthorizationDecodedUserPasswordList[0] + lPassword = llHeaderAuthorizationDecodedUserPasswordList[1] + lDomain = None + if "\\" in lUser: + lDomain = lUser.split("\\")[0] + lUser = lUser.split("\\")[1] + #print(f"Header Authorization, domain: {lDomain}, login: {lUser}, password: {lPassword}") + #self.send_header('Vary', 'negotiative') + #self.send_header('TCN', 'choice') + self.end_headers() + # Write content as utf-8 data + self.wfile.write(bytes("", "utf8")) + #pdb.set_trace() # POST def do_POST(self): #Централизованная функция получения запросов/отправки diff --git a/Orchestrator/Web/Index.xhtml b/Orchestrator/Web/Index.xhtml index 982507d4..b7d04abe 100644 --- a/Orchestrator/Web/Index.xhtml +++ b/Orchestrator/Web/Index.xhtml @@ -480,7 +480,7 @@ lElementParentElement.insertAdjacentHTML("beforeend",lHTMLCode); } ///Test - lTestData = { + lTestDataTable = { "Title":"Test", "Columns":["Дата/Время","Статус","Клиент","Файл"], "Rows":[ @@ -515,7 +515,7 @@ {"Header":"Head 09","Description":"Test 21.02.2019"} ] } - //mGlobal.Modal.ListFilter.Show(lTestData) + mGlobal.Modal.ListFilter.Show(lTestData) }) ;