首页
社区
课程
招聘
U盘防拷贝组件工程
发表于: 2013-10-12 18:34 18723

U盘防拷贝组件工程

2013-10-12 18:34
18723
[*]引言

最近遇到一道题, 需求: 根据策略配置, 防止向U盘中拷贝文件,要求在R3完成.
非常感谢wu对关键技术点的指点!

[*]工程下载
请见帖子底部附件
srcUDiskCpyManager_V2013_1012_1653.rar

[*]感受
这2个星期都在做这个工程, 细节还是蛮多的, 一个一个的小问题,一个一个的搞定.
我想,5天要搞定这个组件. 如果不是从已经实现的Demo中,迁出相应的功能, 绝对做不完.

[*]防止向U盘拷贝的内容
  文件
  文件夹
  文件夹中任意目录中存在的特定文件后缀的文件

[*]测试
今天经过自己在实体机测试, 得到以下测试结论

在Win7X64下达到了需求的要求.
在WinXpX86Sp3下达到了需求的要求.

Win7X86没有实体机, Vmware中的Windows不认识我的USB3.0U盘, 暂时中断该平台的测试.
用ApiMonitor可以看到, Win7X64和win7X86的文件操作,调用的COM API都是相同的.

[*]软件实现思路
  * WinXp下, Hook Win32API, 实现禁止通过资源管理器向U盘拷贝文件
  * Win7(x86/x64)下, Hook COM API, 实现禁止通过资源管理器向U盘拷贝文件

[*]软件组件构成
* CtrlProg.exe : 控制程序, 负责策略的定制, Hook DLL 的控制(安装, 卸载)
* LsApiHook.dll:  Hook Win32API, 实现在WinXp下U盘 DLP
                                Hook函数列表:     CopyFileExW
                                                                CreateFileW
* LsComHookProxy.dll, Hook COM API, 实现在Win7(x86/x64)下U盘DLP
                                Hook函数列表: CoCreateInstance,
                                                IFileOperation::CopyItems
                                                IFileOperation::MoveItems
                                                IFileOperation::NewItem
                                                IFileOperation::RenameItem

[*]技术点
* COM接口方法地址的取得
* 在C++程序中调用C方式的COM接口方法

[*]策略定制
* 禁止/允许向U盘中拷贝文件夹
* 禁止/允许向U盘中拷贝特定文件后缀的文件
在产品中,随着实际需求的细化, 细化策略,细化文件控制.

[*]备注
  * 在产品中用, 控制程序要由驱动保护, 防止被关掉.
  * 策略的下达, 一般不是由控制程序下发.
  * 产品中, 特定后缀类型的文件的判断,要由PE文件实际内容判定,而不是文件后缀名

[*]软件截图







[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

上传的附件:
收藏
免费 5
支持
分享
最新回复 (19)
雪    币: 69
活跃值: (157)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
2
之前写的这个玩意, 也是基于这个几个hook
http://bbs.pediy.com/showthread.php?t=161586
2013-10-12 18:57
0
雪    币: 80
活跃值: (109)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
我测试失败了……
环境:Windows 7 x64,360安全卫士9.2Beta,360杀毒4.2.1(杀软均未提示报毒)

拷贝文件/文件夹都成功。
1.先开软件,按照你的截图的顺序操作,再打开U盘,向U盘拷文件,复制成功。
2.先插入U盘,再打开软件,按照你的截图顺序操作,向U盘拷文件,复制成功。
不过也可以学习。
2013-10-12 21:13
0
雪    币: 112
活跃值: (57)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
4
可能是我测试的不完全吧, 对不住~
您可以理解的,只有专门的测试人员认证过的,程序才能发布。

您设置了策略了么?

您编译成ReleaseX64版本运行了么?
我发布的工程中自带的bin/*.exe, *.dll, 都是x86的,我最后测试的WinXpX86~
你需要根据自己的环境, 重新编译.
如果是X86的您直接可以看效果.

您可以自己跟一下。看看,向U盘拷贝的拷贝的时候,是否进了被Hook的COM API。
如果进入了,您看看,策略比对的时候,是哪有问题?
进了被Hook的COMAPI, 就只剩下策略比对的问题。

我的开发环境和您相同,首先测试的就是Win7X64(数字公司的两款软件).

我建议您编译成Debug X64版,等控制程序启动后,用Vs2010直接Attach到管理器,在Hook后自己的COMAPI函数内下断点,可以单步调试啊.

这个组件细化后,可以在产品中用的...
2013-10-12 21:50
0
雪    币: 80
活跃值: (109)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
5
刚才听您提到编译我才意识到没重新编译。readme.txt没有看,对不起。
由于电脑上没装VS(我一般都用vc6),回头再测试吧。
很感谢楼主。
2013-10-12 22:03
0
雪    币: 90
活跃值: (80)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
6
我感觉要弄成特定U盘有用,,而不是所有U盘都禁止,才有用
2013-10-12 22:42
0
雪    币: 112
活跃值: (57)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
7
您说的是纯逻辑问题: 细化,产品化, 策略判断.
如果并入产品用, 可以再做另外一个Dll, 提供接口,由本组件调用.
本组件在Hook后的函数内部调用接口, 传入文件路径信息, 由接口的返回值来判断是否该禁止特定U盘.

这样将问题解耦之后,本组件就稳定下来,不用再改.
2013-10-13 00:05
0
雪    币: 81
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
mark  ~~~
2013-10-13 23:48
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
楼主的文章中专门提到了资源管理器的拷贝功能。意思是说通过代码的方式照样还是可以复制对吧?   不知道cmd 下面的copy 命令测试如何?
2013-10-14 13:10
0
雪    币: 112
活跃值: (57)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
10
测试过,不行~

我的Hook方式是SetWindowsHookEx, 只能注入有消息循环的UI程序.
您说的Cmd方式下用命令拷贝,我以后有时间会继续做试验.

用程序方式的拷贝, 可以在 LsApiHook.dll 工程中 加入要Hook的Win32Api.
对于没有消息循环的程序, Hook DLL注入方式要改一下. 还没有试验.
2013-10-14 13:37
0
雪    币: 680
活跃值: (68)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
11
下下来看看
2013-10-14 16:58
0
雪    币: 168
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
12
马克思列宁主义
2013-10-15 00:26
0
雪    币: 93
活跃值: (40)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
13
标记一下,感谢楼主分享
2013-10-15 09:15
0
雪    币: 27
活跃值: (90)
能力值: ( LV8,RANK:120 )
在线值:
发帖
回帖
粉丝
14
如果不用资源管理器,而用其他工具..
2013-10-15 10:49
0
雪    币: 11
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
15
回复顶楼主= =!防拷贝 是在 用了你的软件 的电脑才有用?
2013-10-15 11:39
0
雪    币: 185
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
16
用于企业的。 集中化管理。。。。 比如某些杀毒软件就这样做。 不给密码就删不了。
2013-10-16 16:47
0
雪    币: 19
活跃值: (25)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
17
  • introduction
  • Recently encountered a problem and needs: according to the policy configuration, prevent copying files to the usb drive, and requirements in R3.
    Thank you very much for wu on the key technical points of advice!
  • engineering download
  • Attached please see the bottom of the post
    SrcUDiskCpyManager_V2013_1012_1653. Rar
  • feeling
  • This two weeks are doing the project, the details is very much, one by one small problem, one by one.
    I think, five days to get this component. If not from has been achieved in the Demo, out of the corresponding function, is done.
  • prevent to U disk copy of the content
  • file
    folder
    The specific file folder there any directory file suffix
  • test
  • Today after themselves in the real machine test, the following test conclusion
    At the request of the Win7X64 issued by demand.
    At the request of the WinXpX86Sp3 issued by demand.
    Win7X86 no physical machine, Vmware of Windows not know I see U disk, suspended the platform of the test.
    Use ApiMonitor can see Win7X64 and win7X86 file operations, call the COM API is the same.
  • software implementation approach
  • * WinXp, Hook Win32API, banned by the resource manager to U disk copy files
    * Windows 7 (x86 / x64), Hook COM API, banned by the resource manager to U disk copy files
  • software components
  • * CtrlProg. Exe: control procedures, is responsible for the strategy of custom, the control of the Hook DLL (install and uninstall)
    * LsApiHook. DLL: Hook Win32API, the realization of U disk DLP under WinXp
    Hook function list: CopyFileExW
    CreateFileW
    * LsComHookProxy. DLL, Hook COM API, implementation in Windows 7 U disk DLP (x86 / x64)
    Hook function list: CoCreateInstance,
    IFileOperation: : CopyItems
    IFileOperation: : MoveItems
    IFileOperation: : NewItem
    IFileOperation: : RenameItem
  • technical point
  • * COM interface methods address
    * C + + program invokes the C way of COM interface methods
  • strategy custom
  • * disable/enable usb drive to copy folder
    * disable/enable usb drive to copy specific file suffix
    In the product, with the actual demand of refinement, elaboration strategy, refine the document control.
  • note
  • * in the product, control program to protect by the driver, prevent be turned off.
    * policies issued, generally is not issued by a control program.
    * products, specific suffix type of document, to the actual content determination by the PE file, rather than a file suffix
    [*] software screenshots
    2013-10-16 17:31
    0
    雪    币: 112
    活跃值: (57)
    能力值: ( LV12,RANK:200 )
    在线值:
    发帖
    回帖
    粉丝
    18
    您用翻译软件翻译成E文,贴上来的?
    您要表达什么?
    2013-10-16 19:53
    0
    雪    币: 200
    活跃值: (20)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    19
    顶一下,最近在研究防拷贝的工程
    2013-12-4 20:50
    0
    雪    币: 478
    活跃值: (50)
    能力值: ( LV2,RANK:10 )
    在线值:
    发帖
    回帖
    粉丝
    20
    ghost32邪恶的想到了它
    2013-12-4 21:04
    0
    游客
    登录 | 注册 方可回帖
    返回
    //