Copy-On-Write機制,全域hook(二)

來源:互聯網
上載者:User

    如果仔細閱讀前一篇文章的話,就知道只要PTE的write(bit 1)位置1,就廢掉了Copy-On-Write機制(解釋一下,因為不可能產生異常了嘛),為了不影響系統的運行,我找了ntdll的檔案頭(7c800000)做實驗:
!process 0 0
.
.
PROCESS 811ae9e0  SessionId: 0  Cid: 015c    Peb: 7ffde000  ParentCid: 036c
    DirBase: 0997f000  ObjectTable: e15114b0  HandleCount: 126.
    Image: svchost.exe
.
.
PROCESS ffa4fd88
  SessionId: 0  Cid: 0258    Peb: 7ffd4000  ParentCid: 0104
    DirBase: 0712c000
  ObjectTable: e104d8e0  HandleCount:  28.
    Image: EzDriverInstaller.exe

kd> !vtop 0712c000
7c800000 (隨便找個進程,EzDriverInstaller.exe)
X86VtoP: Virt 7c800000, pagedir 712c000
X86VtoP: PDE 712c7c8 - 0b237867
X86VtoP: PTE b237000
- 0f7bd025

X86VtoP: Mapped phys f7bd000
Virtual address 7c800000 translates to physical address f7bd000.
kd> !ed b237000
0f7bd027
(關鍵,5改7)
kd> !vtop 0712c000
7c800000
X86VtoP: Virt 7c800000, pagedir 712c000
X86VtoP: PDE 712c7c8 - 0b237867
X86VtoP: PTE b237000 - 0f7bd027
X86VtoP: Mapped phys f7bd000
Virtual address 7c800000 translates to physical address f7bd000.
kd> g

有一個問題必須要注意,這時只有進程EzDriverInstaller.exe的7c800000頁才失去了CopyOnWrite性質,因為各個進程PTE的地址不同,我才改了一個嘛!然後,隨便寫個程式向EzDriverInstaller.exe的7c800003寫入62('b')
(!!注意千萬不要用核心調試器eb 7c800003 62這樣寫,因為KWinDBG本來就是全域的!!還有也千萬不用OD之類的調試器,因為它在修改前會先修改頁的屬性,這樣之前的工作就白搭了!!)

kd> .process /p 811ae9e0
(隨便找個進程,svchost.exe)
Implicit process is now 811ae9e0
.cache forcedecodeuser done
kd> db 7c800000
7c800000  4d 5a 61 62 03 00 00 00-04 00 00 00 ff ff 00 00  MZab............
7c800010  b8 00 00 00 00 00 00 00-40 00 00 00 00 00 00 00  ........@.......
7c800020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
7c800030  00 00 00 00 00 00 00 00-00 00 00 00 d0 00 00 00  ................
7c800040  0e 1f ba 0e 00 b4 09 cd-21 b8 01 4c cd 21 54 68  ........!..L.!Th
7c800050  69 73 20 70 72 6f 67 72-61 6d 20 63 61 6e 6e 6f  is program canno
7c800060  74 20 62 65 20 72 75 6e-20 69 6e 20 44 4f 53 20  t be run in DOS
7c800070  6d 6f 64 65 2e 0d 0d 0a-24 00 00 00 00 00 00 00  mode....$.......
可以看到無論哪個進程,7c800003處多了個'b',當然這時候可以用OD或其它工具驗證!!

如果是修改系統dll代碼的話一定要小心,當修改完成後最好改回唯讀屬性(7改5)。如果你不幸找了個正在調試的進程下手,然後又在那字碼頁中下了個斷點!@#¥%…&* 哈哈,那就不幸了O(∩_∩)O~

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.