`

[译]用python来玩转Volume Shadow copies

阅读更多
原文地址:http://pen-testing.sans.org/blog/pen-testing/2013/04/12/using-volume-shadow-copies-from-python

Volume Shadow copies 提供管理员工具来访问Windows,包含最新删除的的文件,带锁的文件等。他们就像通道一样直达Windows文件系统,用来挖掘各种有价值的信息。
Volume Shadow copies对于渗透测试来说价值无限,他们包含很多有价值的信息。加入域管理员知道渗透测试要进行测试,删除password.txt怎么办?没问题。密码文件还存在Volume Shadow copies中等你挖掘。类似NTDS.DIT(AD数据库)这类文件会被系统锁住所以你没法获得他们。使用Volume Shadow copies可以解决问题。你可以创建一个新的Volume Shadow copies,然后抓取文件的copy,然后就可以掠夺域中的users了。
可以使用win32com模块和COM来和WIN32_ShadowCopy服务进行交互来做你想做的。参数在python中使用COM很麻烦,但是有现成的库了。
获得某个系统的Volume Shadow copies列表很简单。可以使用vssown.vbs,查询对应的python语句,然后转换成python代码。(vssown.vbs可以从这里下载http://ptscripts.googlecode.com/svn/trunk/windows/vssown.vbs)。然后创建一个object,连接到服务器,使用ExecQuery来获得系统的所有Volume Shadow Copies列表。然后可以使用循环来遍历每一个shadow copy,获得"DeviceObject"属性。需要使用"DeviceObject"属性来访问Volume Shadow Copies中的数据。

可以参考的一些例子:http://www.activexperts.com/admin/scripts/wmi/python/0274/
创建一个Volume Shadow Copy很难,所以我们必须调用Win32_ShadowCopy Com对象。首先,我们导入必须的模块,然后创建一个叫"wmi"的对象,该对象指向一个Win32_ShadowCopy Com的对象。可以使用下面两行代码实现:
import win32com.client
wmi=win32com.client.GetObject("winmgmts:\\\\.\\root\\cimv2:Win32_ShadowCopy")

我们需要为这个Win32_ShadowCopy对象调用"create"方法。执行一个模块需要使用wmi对象的ExecMethod()方法。例如 "wmi.ExecMethod(<method name> , <com object parameters>)"。第一个参数是目标方法名,第二个参数是一个含有目标方法名的COM对象。
首先,创建一个叫“createmethod”的对象指向“Create”方法。然后创建一个叫createparams的对象指向create方法的参数。然后使用createparams对象来检查参数设值。

CreateMethodCreateMethod指向Win32_ShadowCopy对象的create方法。CreateParams指向create方法的参数。可以看到create方法需要叫“Context”和“Volume”的参数。“Context”是第一个参数,“Volume”是第二个参数。然后我使用list来检查这些参数的当前值。可以看到"Context"的值是"ClientAccessible","Volume"的值是"None"。根据MSDN,我们必须为“Volume”参数设置一个盘符:

现在可以调用ExecMethod。结果将会在COM对象列表的Properties_属性中。第一项的“.value”是响应值。可以参考http://msdn.microsoft.com/en-us/library/windows/desktop/aa394428%28v=vs.85%29.aspx来了解响应码。
如果响应码是0,那么第二项将会含有新Volume Shadow Copy的ID。

我的shadow copy ID是4CDDDE4F-4B00-49FE-BF07-1D89B3325AD,现在检查VSSADMIN来看看它是否被创建了。
可以使用vssadmin list shadows命令来查看存在的volume。我们可以看到已经创建的shadow copy 4CDDDE4F-4B00-49FE-BF07-1D89B3325ADD

结合上面的代码,我们使用下面的代码来创建一个volume shadow copy:

现在可以像读系统文件一样读取Volume Shadow copies数据。注意:Volume Shadow copies只可以读,不可以写。
可以使用python文件系统接口来检查一个文件是否存在。

可与你想打开一个文件,读取内容,如下:

关于Volume Shadow copies,我需要做的只是vss_list()和vss_create()这两个函数。如果你需要其他东西,这两个函数可以变更成你需要的样子。代码下载地址
http://counterhack.net/vssown.py.txt
代码:

  • 大小: 33.8 KB
  • 大小: 62.6 KB
  • 大小: 15.4 KB
  • 大小: 17.6 KB
  • 大小: 158.2 KB
  • 大小: 43.1 KB
  • 大小: 11.2 KB
  • 大小: 29.3 KB
  • 大小: 163.8 KB
分享到:
评论

相关推荐

    强制迁移Python的虚拟环境

    Window平台实现迁移Python虚拟环境 采用: python -m venv --copies venv 此脚本只在 window上测试 venv 修改, 运行前请备份

    python numpy库的使用 python基础,演示了numpy库的使用,提供python2例程代码,适合初学者

    python numpy库的使用 python基础,演示了numpy库的使用,提供python2例程代码,适合初学者 Numpy Numpy是Python的一个科学计算的库 高效的向量和矩阵计算 很多函数都是C语言实现的 import numpy as np 用法:np.###...

    python3.6的venv模块使用详解

    主要介绍了python3.6的venv模块使用详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    Python高级编程.pdf

    Python高级编程,适用于有一定基础,经典python教程。

    Invent Your Own Computer Games with Python (2008).pdf

    make as many copies of it as you like, as long as credit to the author is left in. The Python programming language software this book teaches is also freely available from www.python.org. Table of ...

    Windows Forensic Analysis Toolkit

    Organized into eight chapters, the book discusses Volume Shadow Copies (VSCs) in the context of digital forensics and explains how analysts can access the wealth of information available in VSCs ...

    Charles Severance-Python for Informatics

    You can think of Python as your tool to solve problems that are far beyond the capability of a spreadsheet. It is an easy-to-use and easy-to learn programming language that is freely available on ...

    Mac必备免费好用之 快贴copies

    国内首款端对端加密的工具类app! 除了您自己, 没人可以解密你的数据! 非凡的功能 快贴© 可以足够快的让您在您的多台设备之间无缝的链接。

    Hardware Acceleration for Memory to Memory Copies-2017.pdf

    Hardware Acceleration for Memory to Memory Copies,关于加速内存拷贝的资料。University of California at Berkeley, Electrical Engineering and Computer Sciences出品。

    (快贴)copies_2_1_7.zip

    (快贴)copies_2_1_7.zip

    core_servlets_and_javaserver_pages_advanced_technologies_volume_2_2nd_edition

    wildest expectations, selling approximately 100,000 copies, getting translated into Bulgarian, Chinese simplified script, Chinese traditional script, Czech, French, Ger- man, Hebrew, Japanese, Korean,...

    Windows Forensics Cookbook

    Extract and analyze data from Windows file systems, shadow copies and the registry Understand the main Windows system artifacts and learn how to parse data from them using forensic tools See a ...

    mesh:MPI-IS网格处理库

    您可以编译自己的本地版本,也可以直接在Linux上运行$ sudo apt-get install libboost-dev 或在macOS上$ brew install boost安装首先,创建一个专用的Python虚拟环境并激活它: $ python3 -m venv --copies my_venv...

    aws-alfred:适用于Alfred2的AWS Workflow

    奥尔斯·阿尔弗雷德适用于Alfred2的AWS Workflow要求使用python boto模块。 您只需要python,或者至少需要。 所有必需的python模块都应存在于工作流程中。 无需安装它们。 但是,您必须设置crss文件: 〜/ .boto ...

    smartsvn-windows-setup-11_0_4.zip

    SmartSVN是一个功能多且易于使用的Subversion 客户端,可运行在Linux、Mac OS X、OS/2、Unix以及Windows。...使用者无需安装额外的工具来处理SVN working copies,SmartSVN用起来类似命令列SVN client或档案比对工具

    smartsvn安装包

    SmartSVN是一个功能多且易于使用的Subversion 客户端,可运行在Linux、Mac OS X、OS/2、Unix以及Windows。...使用者无需安装额外的工具来处理SVN working copies,SmartSVN用起来类似命令列SVN client或档案比对工具

    smartsvn for mac

    SmartSVN是一个功能多且易于使用的Subversion 客户端,可运行在Linux、Mac OS X、OS/2、Unix以及Windows。...使用者无需安装额外的工具来处理SVN working copies,SmartSVN用起来类似命令列SVN client或档案比对工具

    GDB调技术教程

    1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006... Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom.”

    On Writing Well 2006 (30th Anniversary Edition)

    "On Writing Well" has been praised for its sound advice, ... With more than a million copies sold, this volume has stood the test of time and remains a valuable resource for writers and would-be writers.

Global site tag (gtag.js) - Google Analytics