美文网首页
cha03_回收站文件

cha03_回收站文件

作者: HOtMI1k | 来源:发表于2019-06-10 21:06 被阅读0次

    这个代码基本没什么问题
    win10
    python2

    import os
    import _winreg
    def returnDir():
        dirs = ['C:\\Recycler\\','C:\\Recycled\\','C:\\$Recycle.Bin']
        for recycledDir in dirs:
            if os.path.isdir(recycledDir):
                return recycledDir
        return None
    
    # ok = returnDir()
    # print ok
    def siduser(sid):   
        try:
            net = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\\' + sid
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,net)
            (value,type) = _winreg.QueryValueEx(key,'ProfileImagePath')
            user = value.split('\\')[-1]
            return user
            _winreg.CloseKey()
        except:
            return sid
    
    
    def findRecycled(recycledDir):
        dirList = os.listdir(recycledDir)
        for sid in dirList:
            # print sid
            files = os.listdir(recycledDir + '\\' + sid)
            user = siduser(sid)
            print '\n[*] Listing file for user ' + str(user)
            for file in files:
                print '[+] Found File ' + str(file)
        print '\n'
    def main():
        recycledDir = returnDir()
        # print type(recycledDir)
        findRecycled(recycledDir)
    
    if __name__ == '__main__':
        main()
    

    相关文章

      网友评论

          本文标题:cha03_回收站文件

          本文链接:https://www.haomeiwen.com/subject/wmntfctx.html