예제 #1
0
 def handleNewDevice(self, newDevice, full=True):
     '''
     Adds to self.partitions and processes all partitions 
     of device in loop
     '''
     if not newDevice['disc']:
         logger.info(msg.DISC_NOT_FOUND)
     else:
         disc = getDeviceName(newDevice['disc'])
         self.discHead = self.scanDiscHead(disc)
     if len(newDevice) > 1:
         num = 1
         for partition in newDevice['partitions']:
             device = getDeviceName(partition)
             self.addPartition(device)
             logger.info(msg.partitionNumber(num, len(newDevice['partitions']), device))
             num += 1
             if not full:
                 return
             self.processPartition(device)
             time.sleep(2)
     else:
         device = getDeviceName(newDevice['partitions'][0])
         self.addPartition(device)
         if not full:
             return
         self.processPartition(device)
예제 #2
0
파일: gui.py 프로젝트: mcyprian/checkpoint
 def infectedResults(self):
     """
     State machine handling function, shows infedted files
     summary and delete them.
     """
     print("State infectedResults")
     self.newEvent(showWidget, widget=self.app.message)
     self.shared.buttonPushed.clear()
     self.newEvent(showWidget, widget=self.app.mainButton)
     self.newEvent(self.app.mainButton.config, text=msg.DELETE_BUTTON)
     if SELECT_FILES:
         self.newEvent(showWidget, widget=self.app.specialStateButton)
     self.newEvent(self.app.specialStateButton.config, text=msg.REMOVE_SELECTED_BUTTON)
     self.newEvent(self.app.message.config, fg="red")
     part = getDeviceName(self.detector.detectedDevice["partitions"][0])
     infected = self.scanner.getScanSummary()
     self.newEvent(
         self.app.setLabelMsg, label=self.app.message, text=msg.INFECTED_FILES + "\n".join([x[1] for x in infected])
     )
     self.shared.buttonPushed.wait()
     self.newEvent(self.app.message.config, fg="black")
     if self.shared.specialState.isSet():
         self.newEvent(hideWidget, widget=self.app.mainButton)
         self.newEvent(hideWidget, widget=self.app.specialStateButton)
         return States.REMOVE_SELECTED
     self.newEvent(self.app.setLabelMsg, label=self.app.message, text=msg.DELETING)
     try:
         deleteFiles(infected)
     except FileNotFoundError:
         logger.error(msg.REMOVING_ERROR)
         self.errorMsg = msg.REMOVING_ERROR
         return States.ERRORS
     self.newEvent(self.app.setLabelMsg, label=self.app.message, text=msg.DELETED)
     time.sleep(5)
     return States.WAITING
예제 #3
0
def detectionLogEcho(newDevice):
    '''writes detection info log messages'''
    removeLastHandler() # New file for each device
    registerFileLogHandler(sett.LOG_DIR + getLogName())
    if len(newDevice['partitions']) > 1:
        logger.info(msg.MULTIPARTITION)
    else:
        device = getDeviceName(newDevice['partitions'][0])
        logger.info(msg.singlePartition(device))
예제 #4
0
 def getAllFilesOnDevice(self, newDevice):
     '''
     Returns list of all files and directories at top level
     '''
     allFiles = []
     for partition in newDevice['partitions']:
         device = getDeviceName(partition)
         mountPoint = getMountPoint(device)
         listdir = os.listdir(mountPoint)
         allFiles += [(mountPoint + '/', x) for x in listdir]
     return allFiles
예제 #5
0
 def scanSelectedFiles(self, newDevice, files):
     fullPathFiles = [x[0] + x[1] for x in files]
     self.handleNewDevice(newDevice, full=False)
     for partition in newDevice['partitions']:
         device = getDeviceName(partition)
         self.processPartition(device, full=False)
     logger.info(msg.scanningSelected(device))
     files, found = subprocessPipesCall(['clamscan', '-r'] + fullPathFiles, getFiles=True)
     for infectedFile in found:  # finds out to which paritition file belong
         for part in self.partitions.values():
             if part.mountPoint in infectedFile:
                 part.found += [(part.mountPoint + '/', os.path.relpath(infectedFile, part.mountPoint))]
                 part.files = files
                 continue
예제 #6
0
파일: gui.py 프로젝트: mcyprian/checkpoint
 def deviceDetected(self):
     """
     State machine handling function, prints detection message
     and asks user if new device is going to be scanned
     """
     print("State Detected")
     detectionLogEcho(self.detector.detectedDevice)
     if len(self.detector.detectedDevice["partitions"]) > 1:
         self.newEvent(self.app.setLabelMsg, label=self.app.info, text=msg.MULTIPARTITION)
     else:
         device = getDeviceName(self.detector.detectedDevice["partitions"][0])
         self.newEvent(self.app.setLabelMsg, label=self.app.info, text=msg.singlePartition(device))
     self.shared.buttonPushed.clear()
     self.newEvent(showWidget, widget=self.app.mainButton)
     if SELECT_FILES:
         self.newEvent(showWidget, widget=self.app.specialStateButton)
     self.newEvent(self.app.mainButton.config, text=msg.SCAN_BUTTON)
     self.newEvent(self.app.specialStateButton.config, text=msg.SCAN_SELECTED_BUTTON)
     self.shared.buttonPushed.wait()
     self.newEvent(hideWidget, widget=self.app.specialStateButton)
     self.newEvent(hideWidget, widget=self.app.mainButton)
     if self.shared.specialState.isSet():
         return States.SCAN_SELECTED
     return States.SCANNING