Hi
There's a lot of interesting systems information coming out of this rootkit stuff, including the BlackHat papers and SANS conference publications by Hoglund, Rutkowska, etc. Getting a deeper understanding of it all is definitely on my to-do list.
Opcode's interesting article and Volodya's comment on multiprocessor systems allows me to ask a question I've been wondering about for a while. As I recall, each processor sets up its own IVT and when switching from real->protected mode for the first time makes a copy of it with LIDT as an IDT. I was playing with some old IDT hooking code on my new multiprocessor system when I noticed that the SIDT command would somewhat randomly retrieve
either IDT table address, depending it seemed on which processor was currently active.
The second 'processor' is an Intel ICH5R South bridge controller chip that supposedly integrates various I/O functions associated with IDE, APIC, USB, PCI functions etc. I assume the system flip flops from this subsytem processor to the main 82865PE chip as required.
I noticed this behaviour because in my original code (written on an older single processor system), I used the SIDT command to retrieve the IDT in both my hooking AND unhooking code. i.e. I didn't save the "original" address of the IDT that I hooked for later unhooking, instead just blindly assumed SIDT would retrieve the same address. On my new 2 processor system this would sometimes fail and I would end up unhooking a different IDT table than which I orginally hooked. If I used the Softice IDT command at the time, it too would confirm that either one or the other IDT table addresses was active.
So my point/question then is, Opcode's code also uses the SIDT command (as does most generic IDT hooking code), but is it possible that it might retrieve the address of one of multiple IDT tables? Or does it matter and this is of no concern?
On my Win2K system the "main" IDT is at 80036400, which I believe is what most people have. The second IDT is an
almost duplicate at 820A57E8. I say 'almost' because INT1 and INT3 have slightly different addresses when Softice is loaded, but they do lead to the same interrupt handler in Compuware's cpthook.sys driver.
If one were to do a byte search in memory for one of the interrupt addresses listed in the main IDT, one could probably find this second duplicate IDT (assuming you have a 2-processor system). As an example, here are the beginning of my 2 IDT's as listed by Sven Schreiber's w2k_spy:
Code:
Main processor IDT:
80036400..800364FF: 256 valid bytes
Address | 0000 0002-0004 0006 : 0008 000A-000C 000E | 00 02 04 06 08 0A 0C 0E
---------|---------------------:---------------------|------------------------
80036400 | 6CF0 0008-8E00 8046 : 7729 0008-EE00 B3A8 | l= .. ?. ?F w) .. e. ¦¿
80036410 | 7747 0008-8E00 B3A8 : 7765 0008-EE00 B3A8 | wG .. ?. ¦¿ we .. e. ¦¿
80036420 | 7284 0008-EE00 8046 : 73C8 0008-8E00 8046 | r? .. e. ?F s+ .. ?. ?F
...
Subsystem processor IDT (so it seems):
820A57E8..820A58E7: 256 valid bytes
Address | 0008 000A-000C 000E : 0010 0012-0014 0016 | 08 0A 0C 0E 10 12 14 16
---------|---------------------:---------------------|------------------------
820A57E8 | 6CF0 0008-8E00 8046 : 7738 0008-EE00 B3A8 | l= .. ?. ?F w8 .. e. ¦¿
820A57F8 | 7756 0008-8E00 B3A8 : 7774 0008-EE00 B3A8 | wV .. ?. ¦¿ wt .. e. ¦¿
820A5808 | 7284 0008-EE00 8046 : 73C8 0008-8E00 8046 | r? .. e. ?F s+ .. ?. ?F
...
Anyway, I just wanted to bring up this multiple IDT situation and wonder how it fits in to any rootkit scenario where IDT patching is involved.
Cheers,
Kayaker