【问题标题】:How to make a file filter by hooking kernel32.dll如何通过挂钩 kernel32.dll 来制作文件过滤器
【发布时间】: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 后恢复进程。我想知道两件事:

  1. 如果我可以阻止进程而不是恢复它,为什么不呢。这将阻止应用程序运行。但是我应该调用 kernel32 的哪个函数呢?
  2. 如何在此处实现ntQueryDirectoryfile functionzwQueryDirectoryfile function,以便向文件添加过滤器而不是阻止它。 DLL 是否会对过滤器产生任何影响?

【问题讨论】:

    标签: python file winapi hook hide


    【解决方案1】:

    找到方法了。 我现在猜想 kernel32.dll 需要 kernel mode hooking,这对 python 来说是遥不可及的。

    WINDDKVS(Visual Studio) 提供内核调试器和环境来创建可以调用到exe 中的.sys 文件。

    只需使用WIN32HLP中定义的函数

    现在我只是想知道那个 exe 是否可以用 python 制作(顺便说一句,我更喜欢)/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      • 2019-08-22
      • 2020-01-02
      相关资源
      最近更新 更多