def main(argv): parser = setup_parser() args = parser.parse_args(argv[1:]) config = dict(default_config, **parse_config(args.config)) print json.dumps(config, indent=2) image = download(config['download']) config[config['download']['result']] = image if config.get('expand', None): expand.expand(config['expand'], image) for m in config.get('mounts', []): mount.mount(m, image) for entry in config.get('operations', []): if entry['operation'] == 'append': append.append(entry) elif entry['operation'] == 'hostname': hostname.hostname(entry) elif entry['operation'] == 'chroot': chroot.chroot(entry) for m in config.get('mounts', [])[::-1]: mount.unmount(m)
def applyRequest(self): pt = self.partitionType() if not pt.mountpoint: # do nothing return source = self.partition().getPath() target = consts.target_dir + pt.mountpoint filesystem = pt.filesystem.name() if not os.path.isdir(target): os.mkdir(target) # first umount! mount.umount(target) mount.mount(source, target, filesystem) mtab_entry = "%s %s %s rw 0 0\n" % (source, target, filesystem) open("/etc/mtab", "a").write(mtab_entry) #FIXME: use logging system print mtab_entry PartRequest.applyRequest(self)
def main(): try: signal.signal(signal.SIGINT, close) args = parseInput() if args.mode == 'all' or args.mode == 'mount': socket = mount.init( args.host, args.port ) # wait for connection, before creating child process. jobs.append( Process(target=lambda: mount.mount(socket, args.driver, args. install)) ) # mount will block thread, it need to be handled by child process. if args.mode == 'all' or args.mode == 'dump': jobs.append( Process(target=lambda: physmem2minidump.dump(args.label))) for job in jobs: job.start() jobs[-1].join() # wait only for last child. close() # when last child joined, rest can be terminated. except Exception as e: print(e)
def is_windows_boot(partition_path, file_system): m_dir = "/tmp/pcheck" if not os.path.isdir(m_dir): os.makedirs(m_dir) try: mount.mount(partition_path, m_dir, file_system) except: return False if os.path.exists(os.path.join(m_dir, 'boot.ini')): mount.umount(m_dir) return True else: mount.umount(m_dir) return False
def copia_su_chiavetta(self, devices, logger): device = devices[0] path_chiavetta = get_media_path(device) mount(device) # monta la chiavetta print("DEVICE EXISTS") if is_mounted(device): # controlla se e' montata la usb print("Salvataggio su chiavetta") now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") now = now.replace(":", "").replace(" ", "T") new_file = os.path.join(path_chiavetta, now) shutil.copy2(file_local_path, new_file) # copia il file da locale a chiavetta time.sleep(2) os.remove(file_local_path ) # dove va messo, cancellerebbe il file da locale
def mount_shadow_volumes(vssvolume_mnt, outfile, folder_path, temp_time, parsers): print("Vssvolume_mnt: " + vssvolume_mnt) # disable auto-mount in nautilis - this stops a nautilis window from popping up everytime the mount command # is executed cmd_false = "sudo gsettings set org.gnome.desktop.media-handling automount false && " \ "sudo gsettings set org.gnome.desktop.media-handling automount-open false && " \ "sudo gsettings set org.gnome.desktop.media-handling autorun-never true" try: subprocess.call([cmd_false], shell=True) except: print("Autmount false failed") #check for existence of folder vss_mount = check_for_folder("/mnt/vss_mount", outfile) vss_volumes = os.listdir(vssvolume_mnt) print(vss_volumes) for item in vss_volumes: print("Currently processing vss volume: " + item) #call parted function partition_info_dict, temp_time = parted(outfile, vssvolume_mnt + "/" + item) block_size = get_block_size_parted(outfile, temp_time) for key, value in partition_info_dict.items(): print("About to process Google Analytic Cookies from: " + item) mount.mount(value, key, vssvolume_mnt + "/" + item, outfile, vss_mount) os.makedirs(folder_path + "/" + item) process_dir(vss_mount, folder_path + "/" + item, parsers, item) #unmounting vss volume if (vssvolume_mnt != "NULL"): try: print("Unmounting: " + vssvolume_mnt) outfile.write("Unmounting: " + vssvolume_mnt + "\n") subprocess.call(['sudo umount -f ' + vssvolume_mnt], shell=True) os.rmdir(vssvolume_mnt) except: print("Unable to unmount: " + vssvolume_mnt) outfile.write("Unable to unmount: " + vssvolume_mnt)
def is_windows_boot(partition_path, file_system): m_dir = "/tmp/pcheck" if not os.path.isdir(m_dir): os.makedirs(m_dir) try: if file_system == "fat32": mount.mount(partition_path, m_dir, "vfat") else: mount.mount(partition_path, m_dir, file_system) except: return False exist = lambda f: os.path.exists(os.path.join(m_dir, f)) if exist("boot.ini") or exist("command.com"): mount.umount(m_dir) return True else: mount.umount(m_dir) return False
def mount_shadow_volumes(vssvolume_mnt, outfile, folder_path, temp_time, parsers): print("Vssvolume_mnt: " + vssvolume_mnt) # disable auto-mount in nautilis - this stops a nautilis window from popping up everytime the mount command # is executed cmd_false = "sudo gsettings set org.gnome.desktop.media-handling automount false && " \ "sudo gsettings set org.gnome.desktop.media-handling automount-open false && " \ "sudo gsettings set org.gnome.desktop.media-handling autorun-never true" try: subprocess.call([cmd_false], shell=True) except: print("Autmount false failed") #check for existence of folder vss_mount = check_for_folder("/mnt/vss_mount", outfile) vss_volumes = os.listdir(vssvolume_mnt) print(vss_volumes) for item in vss_volumes: print("Currently processing vss volume: " + item) #call parted function partition_info_dict, temp_time = parted(outfile, vssvolume_mnt + "/"+item) block_size = get_block_size_parted(outfile, temp_time) for key,value in partition_info_dict.items(): print("About to process Google Analytic Cookies from: " + item) mount.mount(value,key,vssvolume_mnt+"/"+item,outfile,vss_mount) os.makedirs(folder_path+"/"+item) process_dir(vss_mount, folder_path+"/"+item, parsers,item) #unmounting vss volume if(vssvolume_mnt != "NULL"): try: print("Unmounting: " + vssvolume_mnt) outfile.write("Unmounting: " + vssvolume_mnt + "\n") subprocess.call(['sudo umount -f ' + vssvolume_mnt], shell=True) os.rmdir(vssvolume_mnt) except: print("Unable to unmount: " + vssvolume_mnt) outfile.write("Unable to unmount: " + vssvolume_mnt)
def mount_command(): global mounted global mount_obj if buckets_loaded == False: messagebox.showinfo("AWS Keys needed" , "Please enter your AWS keys and select bucket to mount to proceed!") return if mounted == False: mount_button_text.set("Mounting...Wait up to 1 min.") root.config(cursor="wait") root.update() try: mount_obj = mount.mount(key_var.get() , secret_var.get() , bucket_var.get() , drive_var.get()) check_interval = 3 max_time_wait = 30 time_waited = 0 while 1: if mount.mount_alive(mount_obj): #TODO: disable all inputs mount_button_text.set("Unmount") mounted = True show_message("Mount Success" , "Bucket {0} mounted to drive {1}".format(bucket_var.get() , drive_var.get())); break else: time.sleep(check_interval) time_waited += check_interval if time_waited > max_time_wait: messagebox.showwarning("Failed to mount!" , "Failed to mount!\nPlease check {0}\\fs.log for more info".format(os.getcwd())) break except Exception as e: error.show_exception("Failed to mount!" , e) if not mounted: mount_button_text.set("Mount") else: #TODO: windows-only subprocess.Popen(r'explorer /select,"'+drive_var.get()+'"') root.config(cursor="") root.update() else: root.config(cursor="wait") root.update() mount.unmount(mount_obj) time.sleep(8) if not mount.mount_alive(mount_obj): #TODO: enable all inputs mount_button_text.set("Mount") mounted = False else: #TODO: more descriptive errors messagebox.showwarning("Failed to unmount!" , "Please check fs.log for more info") root.config(cursor="") root.update()
def mount(self): device, mountpoint = self.pv.get_sel_values() mount(self, device)
#!/usr/bin/python3.6 import os import mount import crypt if __name__ == "__main__": user = mount.getuser() key = crypt.hash((os.environ['TOKEN']).encode()) if os.path.exists("/home/osboxes/algebra/Disks/{}.img.enc".format(user)): crypt.decrypt_file( key, '/home/osboxes/algebra/Disks/{}.img.enc'.format(user)) mount.mount('/home/osboxes/algebra/Disks/{}.img'.format(user)) else: vhd = mount.createVHD(user) VHD_MOUNT_POINT = mount.mount(vhd) exit()
if len(devices) <= 0: tala.message("Failure", "Couldn't detect any USB drives.") elif len(devices) == 1: tala.popup("Update", "Only 1 drive found, using that one.") time.sleep(2) device = devices[0] else: tala.popup(body="Select a drive to save to") time.sleep(2) tala.menu(devices) if device is not None: logger.info("Using device " + device) mount.mount(device) if mount.is_mounted(device): files = [] for filename in os.listdir(mount.get_media_path(device)): path = os.path.join(mount.get_media_path(device), filename) if os.path.isfile(path): files.append(filename) tala.popup("Copying...", "Copying log file...") logger.info("Copying file from " + LOG_FILENAME + " to " + os.path.join(mount.get_media_path(device), LOG_NAME) + "...") shutil.copy(LOG_FILENAME, os.path.join(mount.get_media_path(device), LOG_NAME)) logger.info("Copy complete!") tala.popup("Copyied", "Copy complete!") time.sleep(2)
def volumeSync(self): import os import keyring from rsyncVolume import rsync from files import GetFiles from files import ReadFilesRsync from mount import mount get = GetFiles() #Setting variables user = ReadFilesRsync(get.GetUser()) server = (ReadFilesRsync(get.GetServer())) mode = ReadFilesRsync(get.GetMode()) mountpoint = ReadFilesRsync(get.GetMountpoint()) proto = ReadFilesRsync(get.GetProto()) #Setting constructor x = keyring.get_password("PySync", "Py") y = proto.ReadFile() z = server.ReadFile() u = user.ReadFile() m = mountpoint.ReadFile() #Start mount class mount = mount(y, z, u, x, m) mount.mountVolume() #Get directories print "Hole Verzeichnisse" directory = [] i = 0 fobj = open(get.GetDir()) for line in fobj: directory.append(line.rstrip()) i = i + 1 fobj.close() SRC = [] DST = [] check = mode.ReadFile() if check == "-p": for i in range(len(directory)): tmp = directory[i].split(":") tmp1 = tmp[0] tmp2 = tmp1.split("/") tmp3 = "/%s" % tmp2[-1] tmp4 = tmp[1] tmp2.pop() tmpSRC = ("/").join(tmp2) tmpDST = tmp[1] + tmp3 DST.append(tmpDST) SRC.append(tmpSRC) else: for i in range(len(directory)): tmp = directory[i].split(":") SRC.append(tmp[0]) DST.append(tmp[1]) #Starting Sync print "Starte Sync..." for i in range(len(SRC)): print "DST: %s SRC: %s" % (SRC[i], DST[i]) sync = rsync(SRC[i], DST[i], mode.ReadFile()) sync.Sync() volume = "/Volumes/" + m os.system("umount " + volume) exit()
def main(input_file, output_directory, parsers, input_type): now = datetime.datetime.now() Image_Path = input_file mount_point = "/mnt/" + now.strftime("%Y-%m-%d_%H_%M_%S_%f") folder_path = output_directory print("Inside GA Cookies module the input type is: input_type") #process_file(input_file,folder_path,parsers,type="Overt", threads) if not os.path.exists(output_directory): os.makedirs(output_directory) outfile = open((output_directory+"/GA_Cookie_Logfile.txt"),'w') if input_type == "Single File" or input_type == "Memory Image": print("Processing Memory Image") process_file(input_file,output_directory, parsers) elif input_type == "Directory": process_dir(input_file, output_directory, parsers, "overt") elif input_type == "EnCase Logical Evidence File": mntpt = mount_encase_v6_l01.mount_encase_v6_l01(case_name='none', l01_file="'"+input_file+"'", outfile=outfile) process_dir(mntpt, output_directory, parsers, "overt") elif input_type == "Bit-Stream Image": # Analyze 100 Megabytes chunks of any raw file or EWF file # Process overt & deleted #process_file(input_file,output_directory,parsers) ## Start check for Shadow Volumes # check if Image file is in Encase format if re.search(".E01", input_file): #set mount point Image_Path = mount_ewf('\"' + Image_Path + '\"', outfile, mount_point) # call mmls function partition_info_dict, temp_time = mmls(outfile, Image_Path) partition_info_dict_temp = partition_info_dict #get filesize of mmls_output.txt file_size = os.path.getsize("/tmp/mmls_output_" + temp_time +".txt") #if filesize of mmls output is 0 then run parted if file_size == 0: print("mmls output was empty, running parted\n") outfile.write("mmls output was empty, running parted\n") #call parted function partition_info_dict, temp_time = parted(outfile, "'"+Image_Path+"'") block_size = get_block_size_parted(outfile, temp_time) else: #get block_size since mmls was successful block_size = get_block_size_mmls(Image_Path, outfile, temp_time) #read through the mmls output and look for GUID Partition Tables (used on MACS) mmls_output_file = open("/tmp/mmls_output_" + temp_time + ".txt", 'r') for line in mmls_output_file: if re.search("GUID Partition Table", line): print("We found a GUID partition table, need to use parted") outfile.write("We found a GUID partition table, need to use parted\n") #call parted function partition_info_dict, temp_time_junk = parted(outfile, Image_Path) mmls_output_file.close() #loop through the dictionary containing the partition info (filesystem is VALUE, offset is KEY) for key, value in partition_info_dict.items(): #process overt images if(value == "ntfs") or (value == "fat32"): if not os.path.exists(folder_path + "/Partition_" + str(key)): os.makedirs(folder_path + "/Partition_" + str(key)) #print("Just created output folder: " + folder_path + "/Partition_" + str(key)) outfile.write("Just created output folder: " + folder_path + "/Partition_" + str(key) + "\n\n") else: print("Output folder: " + folder_path + "/Partition_" + str(key) + " already exists") outfile.write("Output folder: " + folder_path + "/Partition_" + str(key) + " already exists\n\n") # Process Deleted, and Unallocated # input("Image Name: "+ Image_Path + "\nFolder Path: " +folder_path+"/Partition_"+str(key)) tmp_mnt = mount_point+"_"+str(key)+"_"+value mount.mount(value, key, Image_Path, outfile, tmp_mnt) # process_file(Image_Path, folder_path+"/Partition_"+str(key), parsers) # Process the mounted filesystem. parsers.append('sigs') process_dir(tmp_mnt, folder_path+"/Partition_"+str(key), parsers, "Overt") # Processes Shadow Volumes vss_mount = check_for_shadow_volumes(Image_Path, key, block_size, outfile, folder_path, temp_time) if not vss_mount == "NULL": mount_shadow_volumes(vss_mount, outfile, folder_path, now, parsers) else: print("This partition is not formatted NTFS or FAT32") outfile.write("This partition is not formatted NTFS or FAT32\n\n")
gluster_setup.setup(export,server_ip,client_ip,confile) def run_tests(list): # os.chdir("./test-dir") for test in list: if test == "pynfs_tests.py": thread1 = myThread("python %s %s %s %d %s " %('tests/test-dir/'+test,server_ip,export,known_failures,lfile)) else: thread1 = myThread("python %s %s %s %s" %('tests/test-dir/'+test,lfile,server_ip,export)) thread1.start() thread1.join() if (version == "4" or version==""): call('umount /mnt/ganesha-mnt',shell=True) mount(export,server_ip,"4") if os.path.ismount('/mnt/ganesha-mnt') == False: if version == "4": print "v4 mount failed,exiting." sys.exit(1) else: print "v4 mount failed, skipping v4 tests" else: nfs4_total = len(test_list) print "==============================Running v4 tests==============================" counter.reset(); run_tests(test_list) print_results(nfs4_total); if (version == "3" or version==""): call('umount /mnt/ganesha-mnt',shell=True) mount(export,server_ip,"3")
def volumeSync(self): import os import keyring from rsyncVolume import rsync from files import GetFiles from files import ReadFilesRsync from mount import mount get = GetFiles() #Setting variables user = ReadFilesRsync(get.GetUser()) server = (ReadFilesRsync(get.GetServer())) mode = ReadFilesRsync(get.GetMode()) mountpoint = ReadFilesRsync(get.GetMountpoint()) proto = ReadFilesRsync(get.GetProto()) #Setting constructor x = keyring.get_password("PySync","Py") y = proto.ReadFile() z = server.ReadFile() u = user.ReadFile() m = mountpoint.ReadFile() #Start mount class mount = mount(y,z,u,x,m) mount.mountVolume() #Get directories print"Hole Verzeichnisse" directory = [] i = 0 fobj = open(get.GetDir()) for line in fobj: directory.append(line.rstrip()) i = i+1 fobj.close() SRC = [] DST = [] check = mode.ReadFile() if check == "-p": for i in range (len(directory)): tmp = directory[i].split(":") tmp1 = tmp[0] tmp2 = tmp1.split("/") tmp3 = "/%s" % tmp2[-1] tmp4 = tmp[1] tmp2.pop() tmpSRC = ("/").join(tmp2) tmpDST = tmp[1] + tmp3 DST.append(tmpDST) SRC.append(tmpSRC) else: for i in range (len(directory)): tmp = directory[i].split(":") SRC.append(tmp[0]) DST.append(tmp[1]) #Starting Sync print "Starte Sync..." for i in range (len(SRC)): print "DST: %s SRC: %s" % (SRC[i], DST[i]) sync = rsync(SRC[i], DST[i], mode.ReadFile()) sync.Sync() volume = "/Volumes/" + m os.system("umount " + volume) exit()
def test_mount(self): mount.mount(self.source, self.target, "auto", mount.MS_BIND) self.assertTrue(os.path.exists(os.path.join(self.target, self.test_file)))
from mount import mount from mode import run_mode mount() run_mode()
def make_bootable_iso(self, device, filename, filesystem, partition_table, target, bootloader, label, clustersize, badblocks_passes, badblocks_file, syslinux, syslinux_modules, grldr): # Requires: parted, mkfs.*, bootloader(grub2, syslinux, grub4dos, systemd-boot) self.signal_set_enabled.emit(False) self.signal_set_progress.emit(0) # Unmount partitions before continuing. mount.unmount_all_partitions(device) self.signal_set_status.emit('Creating the partition table...') # Partition the usb drive. partitioning.create_partition_table(device, partition_table) self.signal_set_status.emit('Creating the partition...') self.signal_set_progress.emit(5) partitioning.create_partition_wrapper(device, filesystem) if partition_table == 'gpt': partitioning.change_partition_name(device, label) if badblocks_passes > 0: self.signal_set_status.emit('Checking for bad blocks...') if clustersize == -1: formatting.check_badblocks(device, str(badblocks_passes), badblocks_file) else: formatting.check_badblocks(device, str(badblocks_passes), badblocks_file, str(clustersize)) # Show message box informing the user of the badblocks check. self.signal_show_badblocks_messagebox.emit(badblocks_file) self.signal_set_status.emit('Creating the filesystem...') self.signal_set_progress.emit(10) # Create the filesystem. if badblocks_passes > 0: formatting.create_filesystem(device, '1', filesystem, str(clustersize), label, badblocks_file) else: formatting.create_filesystem(device, '1', filesystem, str(clustersize), label) self.signal_set_status.emit('Copying files...') self.signal_set_progress.emit(25) # Mount the usb and the iso file. usb_mountpoint = '/tmp/usbmaker' + str(os.getpid()) + '-usb' iso_mountpoint = '/tmp/usbmaker' + str(os.getpid()) + '-iso' mount.mount(device + '1', usb_mountpoint) mount.mount_iso(filename, iso_mountpoint) # Copy the iso contents to the usb drive. iso.copy_iso_contents(iso_mountpoint, usb_mountpoint) # Unmount the iso file. mount.unmount(iso_mountpoint) self.signal_set_status.emit('Installing the bootloader...') self.signal_set_progress.emit(80) # Make the usb bootable. iso.create_bootable_usb(device, usb_mountpoint, bootloader, target, partition_table, syslinux, syslinux_modules, grldr) # Unmount the usb drive. mount.unmount(usb_mountpoint) if target == 'both': partitioning.mark_bootable(device, partition_table) self.signal_set_status.emit('Completed.') self.signal_set_progress.emit(100) self.signal_set_enabled.emit(True)
# os.chdir("./test-dir") for test in list: if test == "pynfs_tests.py": thread1 = myThread( "python %s %s %s %d %s " % ('test-dir/' + test, server_ip, export, known_failures, lfile)) else: thread1 = myThread("python %s %s %s " % ('test-dir/' + test, lfile, server_ip)) thread1.start() thread1.join() if (version == "4" or version == ""): call('umount /mnt/ganesha-mnt', shell=True) mount(export, server_ip, "4") if os.path.ismount('/mnt/ganesha-mnt') == False: if version == "4": print "v4 mount failed,exiting." sys.exit(1) else: print "v4 mount failed, skipping v4 tests" else: nfs4_total = len(test_list) print "==============================Running v4 tests==============================" counter.reset() run_tests(test_list) print_results(nfs4_total) if (version == "3" or version == ""): call('umount /mnt/ganesha-mnt', shell=True) mount(export, server_ip, "3")
def mountiscsi(conf): for c in conf: mount.mount(c)
def mount_if_necessary(folder): if folder.strip() != '': return mount(folder) return True