【发布时间】:2012-11-30 20:03:22
【问题描述】:
我是挂钩的新手。我正在寻找一个 python 程序,它可以通过使用 win API hooking 过滤其中的一些来过滤结果来隐藏文件或阻止它。我读到还有另一种方法可以做到这一点,使用文件系统过滤驱动程序,或者使用内核模式 API 挂钩,我从 here 得到了这个想法。
无论如何,我是 python 人,所以我希望它在 python 中,搜索到 PyBox。这是我可以将某些 DLL 注入应用程序然后运行它的地方。
这是执行此操作的代码:
if kernel32.CreateProcessA(self.exe,
None,
None,
None,
None,
creation_flags,
None,
None,
byref(startupinfo),
byref(process_information)):
self.pid = process_information.dwProcessId
self.tid = process_information.dwThreadId
self.h_process = process_information.hProcess
self.h_thread = process_information.hThread
print "Process successfully launched with PID %d." % self.pid
return True
else:
print "Process could not be launched!"
raise WinError()
return False
这会在挂起模式下创建进程,然后:
def resume(self):
if (kernel32.ResumeThread(self.h_thread) == 0):
print "Process could note be resumed!"
raise WinError()
return False
else:
print "Process resumed."
return True
此函数在注入 DLL 后恢复进程。我想知道两件事:
- 如果我可以阻止进程而不是恢复它,为什么不呢。这将阻止应用程序运行。但是我应该调用 kernel32 的哪个函数呢?
- 如何在此处实现
ntQueryDirectoryfile function或zwQueryDirectoryfile function,以便向文件添加过滤器而不是阻止它。 DLL 是否会对过滤器产生任何影响?
【问题讨论】:
标签: python file winapi hook hide