Exemplo n.º 1
0
    def as_text(self):
        t = '--- start share ---\n'
        t += 'Share Name: ' + str(self.get_name()) + '\n'
        t += 'Description: ' + str(self.get_description()) + '\n'
        if self.get_path():
            t += 'Path: ' + str(self.get_path()) + '\n'
        else:
            t += 'Path: None\n'
        t += 'Passwd: ' + str(self.get_passwd()) + '\n'
        t += 'Current Uses: ' + str(self.get_current_uses()) + '\n'
        t += 'Max Uses: ' + str(self.get_max_uses()) + '\n'
        t += 'Permissions: ' + str(self.get_permissions()) + '\n'

        if self.get_path():
            f = File(self.get_path())
            if f.exists():
                if f.get_sd():
                    t += 'Directory Security Descriptor:\n'
                    t += f.get_sd().as_text() + '\n'
                else:
                    t += 'Directory Security Descriptor: None (can\'t read sd)\n'
            else:
                t += 'Directory Security Descriptor: None (path doesn\'t exist)\n'
        else:
            t += 'Directory Security Descriptor: None (no path)\n'

        if self.get_sd():
            t += 'Share Security Descriptor:\n'
            t += self.get_sd().as_text() + '\n'
        else:
            t += 'Share Security Descriptor: None\n'

        t += '--- end share ---\n'
        return t
Exemplo n.º 2
0
    def dumptab_all_files(self):
        # Record info about all directories
        include_dirs = 1

        #  Identify all NTFS drives
        prog_dirs = []
        for d in drives().get_fixed_drives():
            print wpc.utils.tab_line("info", "drive", d.get_name(), d.get_fs())
            if d.get_fs() == 'NTFS':
                prog_dirs.append(d.get_name())

        # Walk the directory tree of each NTFS drive
        for directory in prog_dirs:
            for filename in wpc.utils.dirwalk(directory, '*', include_dirs):
                f = File(filename)
                print f.as_tab()
Exemplo n.º 3
0
 def dump_program_files(self):
     # Record info about all directories
     include_dirs = 1
 
     prog_dirs = []
     if os.getenv('ProgramFiles'):
         prog_dirs.append(os.environ['ProgramFiles'])
 
     if os.getenv('ProgramFiles(x86)'):
         prog_dirs.append(os.environ['ProgramFiles(x86)'])
 
     for directory in prog_dirs:
         # Walk program files directories looking for executables
         for filename in wpc.utils.dirwalk(directory, wpc.conf.executable_file_extensions, include_dirs):
             f = File(filename)
             print f.as_text()
 def dumptab_all_files(self):
     # Record info about all directories
     include_dirs = 1
 
     #  Identify all NTFS drives
     prog_dirs = []
     for d in drives().get_fixed_drives():
         print wpc.utils.tab_line("info", "drive", d.get_name(), d.get_fs())
         if d.get_fs() == 'NTFS':
             prog_dirs.append(d.get_name())
 
     # Walk the directory tree of each NTFS drive
     for directory in prog_dirs:
         for filename in wpc.utils.dirwalk(directory, '*', include_dirs):
             f = File(filename)
             print f.as_tab()
Exemplo n.º 5
0
 def dump_all_files(self):
     # Record info about all directories
     include_dirs = 1
 
     # TODO other drives too
 
     prog_dirs = []
     prog_dirs.append('c:\\')
 
     count = 0
     for dir in prog_dirs:
         # Walk program files directories looking for executables
         for filename in wpc.utils.dirwalk(dir, '*', include_dirs):
             f = File(filename)
             #print "[D] Processing %s" % f.get_name()
             # TODO check file owner, parent paths, etc.  Maybe use is_replaceable instead?
             aces = f.get_dangerous_aces()
             count = count + 1
             for ace in aces:
                 for p in ace.get_perms():
                     print "%s\t%s\t%s\t%s\t%s" % (f.get_type(), f.get_name(), ace.get_type(), ace.get_principal().get_fq_name(), p)