Beispiel #1
0
 def csv_mbr(self):
     """Extract MBR and BootLoader"""
     informations = DiskAnalysis(self.output_dir)
     partition = Partitions(self.output_dir, self.logger)
     disk = Disks()
     operatingSystem = OperatingSystem()
     envVar = EnvironmentVariable()
     mbr = Mbr(self.output_dir)
     informations.os = operatingSystem.os_information(
         informations.currentMachine)
     informations.listDisks = disk.get_disk_information(
         informations.currentMachine)
     self.logger.info('MBR Extracting')
     for d in informations.listDisks:
         informations.mbrDisk = mbr.mbr_parsing(d.deviceID)
         mbr.boot_loader_disassembly()
         for p in informations.mbrDisk.partitions:
             if p.state == "ACTIVE":
                 vbr = Vbr(d.deviceID, p.sector_offset, self.output_dir)
                 self.logger.info('VBR Extracting')
                 vbr.extract_vbr()
                 vbr.vbrDisassembly()
     self.logger.info('BootLoader Extracting')
     informations.envVarList = os.environ
     informations.listPartitions = partition.partition_information(
         informations.currentMachine)
     informations.save_informations()
Beispiel #2
0
 def csv_mbr(self):
     """Extract MBR and BootLoader"""
     informations = DiskAnalysis(self.output_dir)
     partition = Partitions(self.output_dir, self.logger)
     disk = Disks()
     operatingSystem = OperatingSystem()
     envVar = EnvironmentVariable()
     mbr = Mbr(self.output_dir)
     informations.os = operatingSystem.os_information(informations.currentMachine)
     informations.listDisks = disk.get_disk_information(informations.currentMachine)
     self.logger.info('MBR Extracting')
     for d in informations.listDisks:
         informations.mbrDisk = mbr.mbr_parsing(d.deviceID)
         mbr.boot_loader_disassembly()
     self.logger.info('BootLoader Extracting')
     informations.envVarList = os.environ
     informations.listPartitions = partition.partition_information(informations.currentMachine)
     informations.save_informations()
Beispiel #3
0
	def csv_mbr(self):
		''' Extract MBR and BootLoader '''
		informations = DiskAnalysis(self.output_dir)
		partition = Partitions(self.output_dir,self.logger)
		disk = Disks()
		operatingSystem = OperatingSystem()
		envVar = EnvironmentVariable()
		mbr = Mbr(self.output_dir)
		informations.os = operatingSystem.os_informations(informations.currentMachine)
		informations.listDisks = disk.getDiskInformations(informations.currentMachine)
		self.logger.info('MBR Extracting')
		for d in informations.listDisks:
			informations.mbrDisk = mbr.mbr_parsing(d.deviceID)
			mbr.bootLoaderDisassembly()
		self.logger.info('BootLoader Extracting')
		informations.envVarList = os.environ
		informations.listPartitions = partition.partitionInformations(informations.currentMachine)
		informations.saveInformations()
Beispiel #4
0
def main():
    if len(sys.argv) < 2:
        usage()

    notsupParts = [0x05, 0x0f, 0x85, 0x91, 0x9b, 0xc5, 0xe4, 0xee]
    swapParts = [0x42, 0x82, 0xb8, 0xc3, 0xfc]

    # read first sector
    if not os.path.isfile(sys.argv[1]):
        print("File " + sys.argv[1] + " cannot be openned for reading")
        exit(1)

    with open(sys.argv[1], 'rb') as f:
        sector = f.read(512)

    mbr = Mbr(sector)  # create MBR object

    if mbr.validSignature():
        print("Looks like a MBR or VBR")
        mbr.prettyPrint()

        for i in range(1, 5):
            if not mbr.isEmpty(i):
                if mbr.partitionType(i) in notsupParts:
                    print(
                        "Sorry GPT and extended partitions are not supported by this script!"
                    )
                else:
                    if mbr.partitionType(i) in swapParts:
                        print("Skipping swap partition")
                    else:
                        # let's try and read the VBR
                        with open(sys.argv[1], 'rb') as f:
                            f.seek(mbr.reservedSectors(i) * 512)
                            sector = f.read(512)
                            vbr = Vbr(sector)
                            if vbr.validSignature():
                                print('Found Volume with type',
                                      vbr.filesystemType())
                                print('Volume label:', vbr.volumeLabel())
                                print('Total sectors:', vbr.totalSectors())
                                s = vbr.sectorFromCluster(14)
                                print('Cluster 14:', s)
                                print('Sector:', vbr.clusterFromSector(s))
    else:
        print("Doesn't appear to contain valid MBR")
def best_sentence(sentences):
    sentence_id, sentence_probs = sentence_parsing(sentences)
    mbr = Mbr(sentence_probs)
    return sentence_id, mbr.mbr_calc()
Beispiel #6
0
 def get(self):
     mbr = Mbr(open('/dev/sda', 'rb').read(512))
     self.response.body = "<html><body>"
     self.response.body += mbr.partition1.get_type()
     self.response.body += "</body></html>"
     return self.response(self.request.environ, self.start_response)