listviewsystemfilterdllredirectfile

目录(?)[-]

  1. Introduction
  2. Background
  3. Disclaimer
  4. Using the code
  5. Theory
  6. DLL injection
  7. Working
  8. Hooking The ListView Procedure
  9. Filter Function
  10. Summary
  11. DrawBacks
  12. FAQ
  13. Authors Notes
  14. History
  15. License
  16. About the Author

原帖:http://www.codeproject.com/KB/threads/Kitkat.aspx

A Very Simple pseudo-RootKit
  • Download Kitkat - 3.89 KB
  • Download DllTester - 2.51 KB

Introduction

The Following Article is About Using Global Hooks and Window Subclassing to create a pseudo-Rootkit capable of hiding files from Explorer,Task Manager,Registry Editor,etc

Background

You must know basic C++. Windows Programming, Global Hooks (for dll injection). You Must ofcourse, Know what a RootKit is?

Disclaimer

Though The program is well tested i have to include this disclaimer. The Following Program Attempts to Modify your Operating System, which may/can make your system unstable. By Executing/Compiling The Program you agree that The author nor the site hosting this article shall not be held responsible for any damages occured due to the this program. This Program Comes with NO WARRANTY. USE AT YOUR OWN RISK!! If this scares you, you probably shouldn't run this Program. The Author Hereby disclaims himself. This article may not be re-published elsewhere without the permission of the author.

Using the code

Compile the VC++ Project to obtain a Dll. You could write your loader. But i have enclosed a Small Dll Tester Written in VB just incase. Once Loaded, the dll will establish a CallWnd Hook.

Theory

Ok, Before i start a flame war or before i get out-ed by Guru's out here, i'll like to state Kitkat is not a "System RootKit". It's More of a "User Rootkit" Not to be confused with "UserMode RootKits (Ring 3)"...

There are 2 Kinds of Rootkits

  1. Kernel Mode Rootkits (Run in Ring0 and Filters Requests at highest level)
  2. UserMode Rootkits (Runs in UserMode, uses API Redirection,IAT hooking to get the job done)

The Most Powerfull Rootkit's are no doubt The Kernel Rootkits. Usermode Rootkits are less desirable it is wellknown not all API calls can be hooked using IAT Patching. (Link to Article)

So Which one of these does KitKat Belong to? Actually, its None of them...

See, Most Rootkits have the following model

Collapse
        OS --->RootKit Filter --->User

Every File that is being stealthed is Hidden from the system itself...which means even if one programmatically tries to locate a file, You'll not be able to...since the filter intercepts such a request....
So effectively stealthing the files/processes from BOTH the SYSTEM and THE USER. If an AntiVirus requested a File that was being stealthed...The AV would've got an "INVALID_FILE_HANDLE"
but Kitkat's Model is based on the Following Model

Collapse
        Windows GUI ---->Kitkat RootKit Filter  ---->User

As You can see, The OS doesn't figure in the diagram...because Kitkat only modifies/affects the GUI of the System. KitKat Does NOT Stealth your Files From The System itself. It Only hides your files from the "User's Sight"....The Files can be read/written upon programmatically by any program.

For eg. Say Kitkat is hiding a file (c:/test.txt) though You won't be able to see the file using explorer.
If You tried to execute "notepad c:/test.txt" this would work fine...since the System can "SEE" the file.
The System remains unaffected, only the GUI is affected. So This Method can be used to

  1. Hide Process Listing (from Task Manager,etc)
  2. Hide Files in Explorer (Folders,Files, Common Dialog Boxes)
  3. Hide Entries in Registry Editor (Regedit)

I Hope Your Getting this...

DLL injection

The Dll injection method is based of Ivo Ivanov's Code. A Million Thanks to Him. Search This Site For it.

Working

Grab your Trusty Spy++ and try to find out "the classname" for the Main Window (where folders and files are displayed) used by

  1. Explorer.exe
  2. Regedit.exe
  3. Taskmgr.exe
  4. Common Dialogs (Open File,Save File)
  5. Etc (Pretty Much Everything on your PC)

You'll Notice all the Main Window (where folders and files are displayed) are of ClassName "SysListView32" which is popularly called a "ListView". Note, Almost Every Control in Windows is a window...They are all Created using "CreateWindow". Windows Differentiates Between a Button and a List by means of a Classname. And also Every Window has a Window Procedure.

For Each Class there are specific procedures...For a Button,The WM_COMMAND may simulate a depressed button. The same Message for a List simply highlights the selection...So you see, every Control have their own in-built default procedures...we are going to redirect this default procedure to our filter.

Kitkat.dll is going to be injected into Every Process that has a Message Queue (Using CallWnd Hook) Once Injected, Using Global Subclassing we are going to "redirect" the default window procedure of ListView to our Filter Function.

To Perform The Redirection we only need One API "SetClassLong".

Hooking The ListView Procedure

Collapse
 //
Create temporary SysListView32 window since you need an instance of that control for SetClassLongHWND hWnd = CreateWindow("
SysListView32"
,"
"
,0
, 0
, 0
, 0
, 0
,NULL, NULL, hInstance, NULL);OldWndProc = SetClassLong(hWnd,GCL_WNDPROC,(LONG)NewWndProc); //
get previous addrDestroyWindow(hWnd); //
destroy it, don't need it anymore

Once This is done, Every ListView Created AFTER the hook was established will be affected...

Note : ListViews Created Before are unaffected...Just One Of the Many Drawbacks of Kitkat Method. Although it can be implemented using SetWindowLong() we'll have to remember The Old Procedure For each one of them. Hey, This is just a demo.

Notice, we Got the OldWndProc. You Need to store this...we'll be needing this to call the real procedure.

Filter Function

Collapse
chartemp[MAX];LONG OldWndProc;LRESULT CALLBACK NewWndProc(HWND Hwnd, UINT Message, WPARAM wParam, LPARAM lParam){switch
(Message){//
Why Hook the WM_PAINT? Because it was the Only Common Message i found that //
 was sent to all "Explorer.exe","Regedit.exe", "taskmgr.exe"caseWM_PAINT://
Find Number of Columns...We'll Search Every ColummnHWND hdr = (HWND)SendMessage(Hwnd,LVM_GETHEADER,0
,0
);intCol = SendMessage(hdr,HDM_GETITEMCOUNT,0
,0
);Col++;inti,j,k,itemCount = ListView_GetItemCount(Hwnd);for
(i=0;i <Col;i++){for
(j=0;j <itemCount;j++){ListView_GetItemText(Hwnd,j,i,temp,MAX);strcpy(temp,_strlwr(temp));for
(k=0;k <UBOUND_PROCLIST;k++){//
substring searchif
(strstr(temp,procList[k])){ListView_DeleteItem(Hwnd,j);itemCount--;j--;}}}}break
;}returnCallWindowProc((WNDPROC)OldWndProc, Hwnd, Message, wParam, lParam);}

Summary

Now, ListView can Have Multiple Colummns...Let's Say I'm this evil malicious hacker dude, those guys at microsoft always seem to talking about, anyways, i have my "backdoor.exe" which has created a Autorun entry in the registry...Now, I want my entry to be hidden...

  1. Inject Dll into Regedit.exe
  2. Subclass SysListView32
  3. Intercept WM_PAINT Message
  4. Search Through ALL Columns and ALL ROWS to find "backdoor.exe"
  5. If found delete that entire Row.
  6. Call Default Procedure.

DrawBacks

  1. Does not Affect Console Programs (coz they don't have Message Queue's)
  2. Any Program can "detect" files, if we are actively looking for it. Assuming the user doesn't know he's been compromised. He'll never look for it.
  3. Controls Created Prior to Hooking are unaffected.

FAQ

Q : Why WM_PAINT?
A : I tried to monitor all Messages that were sent to SysListView32, the only common Message that was sent to Explorer.exe,Taskmgr.exe,Regedit.exe was WM_PAINT. There are others, but they are not consistent with all Applications

Q : In Explorer, There's an Empty Space where the icon (for the stealthed file) was supposed to fall. What's with that?
A : I'm Guessing The positions are assigned before WM_PAINT is called...so when we filter the result...the space is already allocated for the icon. I Guess if we intercept any other message this could be fixed. but i haven't tried any.

Q : What is its Purpose?
A : Unfortunately, The only purpose i can tell you, involves malicious applications. But i hope something good can come out of it.

Q : Hey,I can see the Stealthed files using cmd. Can you Implement a Method that works for them?
A : It can be implemented...We'll have to Redirect "StdIn,StdOut,StdError" using Pipes but that's a story for another time. Who Knows, if i get the time i will...

Q : It Doesn't Work on my System?
A : As of now, i have tested it out on my System which is a Win2k SP4. If It doesn't work on your system please report it. So that the article can be corrected.

Q : It's a DLL, how do i execute it?
A : You could write your loader. But i have enclosed a Small Dll tester Written in VB just incase. Once Loaded, the dll will establish a CallWnd Hook. You can Customize it yourself...

Authors Notes

The Processes to Hide are hardcoded...To make it flexible you can use "ini" files to check filenames.
You can prevent the dll from injecting itself into certain process by matching g_exePath with filename (say "explorer.exe")
More Notes in the Source Code

History

17 Feb 08 : Original Draft

License

This article, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL)

About the Author

KitKat - The Lazy/Poor Man's Rootkit相关推荐

  1. 全新版大学英语综合教程第一册学习笔记(原文及全文翻译)——8 - Fable Of The Lazy Teenager(懒散少年的寓言)

    Unit 8 - Fable Of The Lazy Teenager(懒散少年的寓言) Benjamin Stein weaves a tale to bring home to young Ame ...

  2. 单例模式的两种实现方式对比:DCL (double check idiom)双重检查 和 lazy initialization holder class(静态内部类)...

    首先这两种方式都是延迟初始化机制,就是当要用到的时候再去初始化. 但是Effective Java书中说过:除非绝对必要,否则就不要这么做. 1. DCL (double checked lockin ...

  3. uscao 线段树成段更新操作及Lazy思想(POJ3468解题报告)

    线段树成段更新操作及Lazy思想(POJ3468解题报告) 标签: treequerybuildn2cstruct 2011-11-03 20:37 5756人阅读 评论(0) 收藏 举报  分类: ...

  4. HYSBZ - 1798 Seq 维护序列seq 线段树lazy标记

    传送门 这道题属实是线段树的道比刷题,又加又乘的,当然还可能会有乘除,阶乘等等可能的情况. 对于这道题,主要的一个就是怎么记录lazy标记,首先的话一个数组是肯定不行的,设乘的为lazy,加的为add ...

  5. Linux UserSpace Back-Door、Rootkit SSH/PAM Backdoor Attack And Defensive Tchnology

    catalog 0. 引言 1. Pam后门 2. SSH后门 3. Hijacking SSH 4. Hijacking SSH By Setup A Tunnel Which Allows Mul ...

  6. hibernate 全面学习【lazy策略 】

    2019独角兽企业重金招聘Python工程师标准>>> lazy策略可以用在: * <class>标签上:可以取值true/false * <property> ...

  7. scala学习笔记-过程、lazy值和异常(6)

    过程 在Scala中,定义函数时,如果函数体直接包裹在了花括号里面,而没有使用=连接,则函数的返回值类型就是Unit.这样的函数就被称之为过程.过程通常用于不需要返回值的函数. 过程还有一种写法,就是 ...

  8. 怎么确定迭代器后面还有至少两个值_JS Lazy evaluation:可迭代对象与迭代器

    本文已经过原作者 MelkorNemesis 授权翻译. Lazy evaluation Lazy evaluation常被译为"延迟计算"或"惰性计算",指的 ...

  9. Metasploit 使用后门和Rootkit维持访问

    1.内存攻击指的是攻击者利用软件的漏洞,构造恶意的输入导致软件在处理输入数据时出现非预期的错误,将输入数据写入内存中的某些敏感位置,从而劫持软件控制流,转而执行外部的指令代码,造成目标系统获取远程控制 ...

最新文章

  1. 兰州大学计算机考研专硕学费,2018年兰州大学在职硕士研究生学费标准
  2. csi python 摄像头 树莓派_树莓派之摄像头和人脸识别
  3. 怎么提交 checkbox 表单_8. html form表单
  4. c++11测试时间封装
  5. python调整屏幕缩放比例_python实现批量按比例缩放图片效果
  6. GrapeCity Documents for Excel 与 Apache POI 功能对比
  7. android.cat 镜像,Android开发利器之pidcat安装方式
  8. [开源 .NET 跨平台 Crawler 数据采集 爬虫框架: DotnetSpider] [四] JSON数据解析
  9. unity界面按钮的位置
  10. 金蝶KIS专业版V14.1生产任务单|销售单等单据图片打印
  11. JAVA多线程之状态转换图
  12. CLC龍链:致力于打造基于区快链技术的全球跨境支付生态系统
  13. 如何通过github实现个人网页上传
  14. 一、Java虚拟机概述与JVM结构
  15. ps懒人一键智能AI磨皮插件 去除皮肤瑕疵
  16. 2×24全交换开关矩阵方案
  17. FTP电脑间传输文件
  18. Linux操作系统相关资料
  19. GDUFS 2018信息学院程序设计新手赛(正式赛)题解
  20. 淘宝数据分析:利用数据细分目标客户群

热门文章

  1. INLWO-系统调用
  2. 今日金融词汇---品牌溢价
  3. java回收算法学习
  4. Access高效开发视频教程【初级篇】-王宇虹-专题视频课程
  5. h5页面的头部返回箭头或者手势返回到指定的页面
  6. api翻译器在线翻译多语种
  7. nyx(Tor的命令行监视器)的安装与使用
  8. LA3026 Period
  9. 面试:饭局上两领导让你先敬对方咋办?说出4个原则,当场录用
  10. 产品经理培训班大概多少钱