티스토리 뷰
Useful tools:
WfpReplace - Tool to replace WFP protected files. (x32 and x64)
[C++ source included]
WfpAdmin - Tool to disable WFP on specific
folders. (x32 only)
MoveLater - Console app to replace
in-use files.
PEChksum - Console app to correct PE image
checksums.
Quick links:
Hack
Method 1: Disable WFP for specific folders until
the computer is next rebooted via manual handle manipulation
Hack Method 2: Disable WFP completely until
the computer is next rebooted via undocumented SFC API
Hack Method 3: Disable WFP on a specific
file for 1 minute via undocumented SFC API
Hack Method 4: Disable WFP permanently via
patches and undocumented registry value
Hack Method 5: Disable WFP permanently on
specific files via patching the protected file list
Hacking Windows File Protection
Windows File Protection (WFP) is a mechanism that protects system files from being modified or deleted. Introduced in Windows 2000, Windows File Protection was a leap forward in operating system stability since it protected the core modules from being corrupted or updated except by service packs or hotfixes sent from Microsoft.
A big problem prior to Windows 2000 was 'DLL Hell'. Applications would often update system modules with their own versions, regardless if other applications already installed were depending on a different version of that same module. Although Microsoft recommended that application programmers place modules into the program's folder instead of the system folder, few programmers did. WFP solved DLL Hell, along with many other issues.
In order to protect the integrity of the system, Microsoft did not document a way to disable WFP. If they had, programmers would surely begin to circumvent it and have their application installers overwrite system modules with their own versions. Booting to Safe Mode was the only way Microsoft provided for replacing a protected file. In theory, this was a good idea. However, programmers and power users sometimes desire the power to replace or delete protected modules without the cumbersome process of booting to safe mode and back.
Enter the hacks.
In Windows 2000, a hidden registry value to fully disable WFP existed. Unfortunately, this didn't last long after I discovered and posted it to NTBugTraq. Microsoft soon tweaked their code so that the hidden registry value was neutralized (curiously, it wasn't completely removed from the code). I then created patches to re-enable this undocumented value. Appendix A describes the history of the discovery of the undocumented registry value and creation of the patches to re-enable it.
Since that time, many other techniques to disable or circumvent Windows File
Protection have been discovered.
How the System File Checker monitors files for changes
The executable portion of WFP is called the System File Checker
(SFC). It exists throughout SFC.DLL, SFC_OS.DLL, SFCFILES.DLL, and SFC.EXE.
The contents of SFC.DLL and SFC_OS.DLL have changed between Windows 2000 and Windows XP. In Windows XP, SFC_OS.DLL contains all the core code and SFC.DLL is merely a proxy to it. The exports of SFC.DLL are forwarded on to SFC_OS.DLL. The SFCFILES.DLL module is simply a data holder that contains a list of all files protected by WFP. At startup the winlogon service invokes the unnamed export ordinal 1 of SFC_OS.DLL, SfcInitProt. This API launches a new free thread called the 'SFC Watcher Thread'. This thread creates a series of directory change notification events, one for each folder that contains a protected file. The WaitForMultipleObjects API is then called within loop to wait for any of these events to be signalled. Upon event signaling, the modified file(s) are determined and replaced with copies found in the cache folder, if one exists there. If it doesn't, the user is prompted to insert the Windows installation CD so that the file can be replaced from the copy found on it. Therefore, SFC actually allows for files to be replaced or modified, then overwrites them. A few second delay is incorporated so that time is given for write operations to 'settle down' before the affected file(s) are restored. Knowing how SFC works means that one can easily disable it by terminating the watcher thread or by closing the directory change notification event handles. This leads us to methods 1 and 2: |
|
Hack Method 1: Disable WFP for specific folders until the computer is next rebooted via manual handle manipulation
The first technique to disable WFP is to close the directory change notification handles by enumerating the handles that winlogon has opened, determining which ones correspond to the folder(s) we wish to deprotect by querying and comparing the handle names, then closing those handles via ntdll.NtDuplicateHandle (or kernel32.DuplicateHandle). This method is used by WfpAdmin.
Hack Method 2: Disable WFP completely until the computer is next rebooted via undocumented SFC API
The second technique is to terminate the SFC Watcher Thread that continually waits for and responds to the directory change notification events to be signalled. Doing this manually isn't very practical since it is diffucult to be sure the right thread has been located. Fortunately, the SFC_OS.DLL exposes a nice unnamed export at ordinal 2: SfcTerminateWatcherThread.. This API accepts no parameters and does exactly as its name implies. However, there is one caveat to using this function: It must be invoked in the process that created the SFC Watcher Thread: winlogon. To accomplish this, virtual memory needs to be allocated in the winlogon process space and a thread procedure that invokes SfcTerminateWatcherThread copied into that memory. The thread procedure should then be invoked using kernel32.CreateRemoteThread and WFP will be disabled until the winlogon process restarts (computer is rebooted).
Ordinal 2:
DWORD WINAPI SfcTerminateWatcherThread();
The return value is 0 if success, or 1 if an error occurred .
Hack Method 3: Disable WFP on a specific file for 1 minute via undocumented SFC API
The SFC_OS.DLL module exports another very useful undocumented, unnamed API
at oridinal 5: SfcFileException. This handy API will register a
temporary SFC exception for specific file, allowing the file to be updated. The
period the exception is in place is currently one minute.
Ordinal 5:
DWORD WINAPI SfcFileException(DWORD dwUnknown0, PWCHAR pwszFile,
DWORD dwUnknown1);
dwUnknown0 | Unknown. Set to 0 |
pwszFile | Filename |
dwUnknown1 | Unknown. Set to -1 |
The return value is 0 if success, or 1 if an error occurred (usually that the
file is not protected by WFP).
An example call to this API is:
SetSfcFileException(0, L"c:\\windows\\notepad.exe",-1);
Hack Method 4:
Disable WFP permanently via patches and undocumented registry value
Prior to Windows 2000 SP1 there was an undocumented registry value that would fully disable WFP. This is the famous 0xffffff9d value I discovered while reverse engineering SFC.DLL in Windows2000. Unfortunately, soon after its discovery Microsoft disabled it. Fortunately, the core code to disable WFP was left in SFC.DLL (later moved to SFC_OS.DLL). Therefore, a simple patch to SFC.DLL or SFC_OS.DLL will re-enable this value. I've created patches for 2K and XP and have generalized the patching procedure so the patch may be applied to all current and (hopefully) future versions of the SFC module without having to worry about a specific patch address.
General patch procedure:
For Windows 2000, the patch is applied to SFC.DLL.
For Windows XP and 2003, the patch is applied to SFC_OS.DLL.
Copy the target file to a temporary one.
Search for the bytes '83 F8 9D 75 07 8B C6'.
Replace the '8B C6' with
'90 90'.
You must correct the checksum of the image by using our PEChkSum utility. It can be obtained here.
Now set the temporary file to replace the original at boot-time by using our MoveLatr utility. It can be obtained here.
Set the SFCDisable value described below and then reboot the computer to complete the process.
Undocumented SFCDisable value:
Key: HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Windows File
Protection
Value name: SFCDisable
Value: 0xFFFFFF9D
Hack Method 5: Disable WFP permanently for specific files via patching the protected file list
More simple than patching executable code is simply patching the list of files contained in SFCFILES.DLL. First, copy SFCFILES.DLL to a temporary file. Using a hex editor (i.e. UltraEdit), search for files to disable protection on inside the temporary file. Once found, replacing the first character of the file name with 0 (that is: value 0 NOT ascii '0' character). After completing the modifications, correct the checksum using our PEChkSum utility and set the temporary file to replace the original at boot-time using our MoveLatr utility. Reboot the computer to finish the process.
-Jeremy Collake
jeremy@bitsum.com
Like this article? Please feed me by donating to jeremy@bitsum.com via paypal ;).
The End
'보안 > 악성코드' 카테고리의 다른 글
mscorsvw.exe (0) | 2010.03.03 |
---|---|
[Borland] MIDAS.Dll (0) | 2010.01.13 |
Clubfos 다운로드 매니저 - 설치되는 애드웨어 늘었다 (0) | 2009.10.07 |
클럽포스(clubfos.com) 니네 서비스나 잘했음 싶다. 형은 (0) | 2009.09.19 |
[노트] 랜섬웨어가 이용하는 결제 방식 - SMS, P2P에서도? (0) | 2009.09.12 |
- Total
- Today
- Yesterday
- 지루박멸연구센타
- 열정의 힘을 믿는다
- Le4rN TO Cr4cK
- 디버깅에관한모든것(DebugLab)
- sysinternals
- FoundStone
- hashtab
- 보안-coderant
- 디바이스드라이버 개발자 포럼
- dualpage.muz.ro
- osronline.com - 드라이버 관련 정보 사이트
- NtInternals - NativeAPI Refere…
- pcthreat - spyware 정보 제공
- rootkit.com - 루트킷 관련 정보
- www.ntinternals.net
- WINE CrossRef. - source.winehq…
- tuts4you
- hex-rays
- idapalace
- idefense
- immunityinc
- threatexpert
- hdp.null2root.org
- www.crackstore.com
- crackmes.de
- www.who.is
- www.cracklab.ru
- community.reverse-engineering.…
- video.reverse-engineering.net
- SnD
- 클레이 키위
- reversengineering.wordpress.co…
- www.openrce.org
- www.woodmann.com
- PEID.Plusins.BobSoft
- roxik.com/pictaps/
- regexlib.com
- spyware-browser.com
- www.usboffice.kr
- regulator
- www.txt2re.com
- ietab.mozdev.org
- zesrever.xstone.org
- www.heaventools.com/PE-file-he…
- www.heaventools.com
- www.innomp3.com
- 울지않는벌새
- exetools.com-forum
- exetools.com
- utf8 conv
- robtex - IP trace
- onsamehost - same IP sites
- JpopSuki
- jsunpack.jeek.org
- wepawet.iseclab.org
- www.jswiff.com
- www.hackeroo.com
- winesearcher.co.kr
- khpga.org
- malwareurl.com
- anubis.iseclab.org
- www.crummy.com-eautifulSoup
- malwarebytes.org/forums
- bbs.janmeng.com
- blackip.ustc.edu.cn
- eureka.cyber-ta.org
- exploit-db.com
- 자동트래이딩
- 전세매매지수
- 미국주식
- 레고랜드
- CriticalSection
- 다올저축은행
- INVOICE
- 시스템트래이딩
- 주택구매력지수
- 군함도
- ElasticSearch
- 실시간트래이딩
- ubuntu
- Pivot
- 맥쿼리인프라
- 주식
- 사회간접자본
- ChatGPT
- 매매가격지수
- logrotate
- 공공인프라
- 주식트래이딩
- systemd
- hai
- ROA
- PIR
- 피봇
- SBI저축은행
- O365
- 신한저축은행
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |