Пример #1
0
def Scan(stop_event, path):
    client = ipc.mailslot("client")
    exes = Scanner.find_exe(path)
    global flag
    flag = False
    total = len(exes)
    if total == 0:
        return
    percent = 100 / total
    progress = 1
    for exe in exes:
        progress += percent
        if not stop_event.wait(0.1):
            flag = True
            res = Scanner.scan(exe)
            try:
                client.put({
                    'progress': math.ceil(progress),
                    'exe': exe,
                    'infected': res,
                    'marker': 'scan'
                })
            except Exception:
                print('Клиент отключен')
                break
        else:
            break
Пример #2
0
def logger ():
  with ipc.mailslot ("logger") as l:
    while True:
      word = l.get ()
      if word == "STOP":
        break
      else:
        print word
Пример #3
0
def logger():
    with ipc.mailslot("logger") as l:
        while True:
            word = l.get()
            if word == "STOP":
                break
            else:
                print word
Пример #4
0
def Scan(path):
    client_mon = ipc.mailslot("monitoring_client")
    exes = Scanner.find_exe(path)
    total = len(exes)
    if total == 0:
        return
    for exe in exes:
        res = Scanner.scan(exe)
        try:
            client_mon.put({
                'progress': None,
                'exe': exe,
                'infected': res,
                'marker': 'sched'
            })
        except Exception:
            print('Клиент выключен.')
            break
Пример #5
0
def StartMonitoring(path, stop_event):
    global observer
    observer = Observer()
    handler = Monitoring.Handler()
    observer.schedule(handler, path, recursive=True)
    observer.start()
    client_mon = ipc.mailslot("monitoring_client")
    while True:
        if stop_event.isSet():
            observer.stop()
            break
        if handler.flag:
            handler.flag = False
            try:
                client_mon.put({
                    'item': handler.path,
                    'infected': handler.res,
                    'marker': 'mon'
                })
                handler.res = None
            except Exception:
                print('Клиент выключен.')
Пример #6
0
import random

from winsys import ipc

reader = ipc.mailslot("reader")
writer = ipc.mailslot("reader")

message = list(reversed("the quick brown fox jumps over the lazy dog".split()))

while True:
    try:
        data = reader.get(block=False, timeout_ms=1000)
        if data == "STOP":
            break
    except ipc.x_mailslot_empty:
        pass
    else:
        print data

    if random.randint(1, 100) > 95:
        try:
            writer.put(message.pop())
        except IndexError:
            writer.put("STOP")
Пример #7
0
 def put(self, msg):
     ipc.mailslot(self.mailslot_name).put(marshal.dumps(msg))
Пример #8
0
 def put(self, msg):
     ipc.mailslot(self.mailslot_name).put(marshal.dumps(msg))
Пример #9
0
import threading

from winsys import ipc

def logger ():
  with ipc.mailslot ("logger") as l:
    while True:
      word = l.get ()
      if word == "STOP":
        break
      else:
        print word

threading.Thread (target=logger).start ()

with ipc.mailslot (r"\\*\mailslot\logger") as logging_mailslot:
  for word in "the quick brown fox".split ():
    logging_mailslot.put (word)
  logging_mailslot.put ("STOP")
Пример #10
0
import time
from winsys import ipc
import sys
from multiprocessing.connection import Client

from PyQt5 import QtGui
from PyQt5.QtCore import QObject, QThread
from PyQt5.QtWidgets import (QApplication, QLabel, QMainWindow, QPushButton,
                             QFileDialog, QProgressBar, QListWidget, QComboBox)

mail_server = ipc.mailslot("server")
mail_client = ipc.mailslot("client")
client_mon = ipc.mailslot("monitoring_client")
address = ('localhost', 6000)


class ServiceListener(QObject):
    def __init__(self):
        super().__init__()
        self.state = None

    def run(self):
        global pbar, scanned_listbox, infected_listbox
        listener_thread = QThread.currentThread()
        while getattr(listener_thread, "listening", True):
            message = mail_client.get()
            pbar.setValue(message['progress'])
            if message['exe'] is not None:
                if message['marker'] == 'scan':
                    msg = "[СКАНЕР] " + message['exe']
                    scanned_listbox.insertItem(0, msg)
Пример #11
0
import threading

from winsys import ipc

def logger():
    with ipc.mailslot("logger") as l:
        while True:
            word = l.get()
            if word == "STOP":
                break
            else:
                print word

threading.Thread(target=logger).start()

with ipc.mailslot(r"\\*\mailslot\logger") as logging_mailslot:
    for word in "the quick brown fox".split():
        logging_mailslot.put(word)
    logging_mailslot.put("STOP")
Пример #12
0
import math
import time

import schedule
import Scanner
import Monitoring
import Scheduler
import threading
from winsys import ipc
from watchdog.observers import Observer
from multiprocessing.connection import Listener

address = ('localhost', 6000)

serv = ipc.mailslot("server")
serv_mon = ipc.mailslot("monitoring_server")


def thread(func):
    def wrapper(*args, **kwargs):
        current_thread = threading.Thread(target=func,
                                          args=args,
                                          kwargs=kwargs)
        current_thread.start()

    return wrapper


# def Listen() -> dict:
#     conn = listener.accept()
#     msg = conn.recv()