这个代码基本没什么问题
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()
网友评论