郁金香 fs寄存器

为什么我们在追eax要挂主线程呢,这是因为它的数据来源在fs中

 

 

004D1000 为什么是这个呢
$ ==>    0392FFDC  指向SEH链表指针
$+4      03930000  线程堆栈顶部(地址最小) esp
$+8      038E6000  程堆栈底部(地址最大)   ebp
$+C      00000000  SubSystemTib
$+10     0134F3A0  FiberData
$+14     00000000  ArbitraryUserPointer
$+18     7EFDD000  FS段寄存器在内存中的映射地址
$+1C     00000000  EnvironmentPointer : Ptr32 Void
$+20     00002298  进程ID _CLIENT_ID={tid,pid}
$+24     00002AC4  线程ID
$+28     00000000  RpcHandle
$+2C     01282D80  指向线程局部存储的指针 004D4DB3   | 64:8B0D 2C000000 | mov ecx,dword ptr fs:[2C]  
$+30     7EFDE000  PEB结构地址(进程结构)
$+34     00000000  上一个错误(LastError) GetLastError

 

 

从FS寄存器获取当前进程ID
int GetCurrentProcessId()
{
 int iProcess = 0;
 _asm{
    xor esi , esi
    mov eax, fs:[esi+18h]//获取TEB
    mov ecx, [eax+ 20h]    ///获取进程ID  
    mov dword ptr[iProcess ], ecx///传递进程
 }
 return iProcess ;
}

 

posted @ 2022-10-26 09:26  逆向狗  阅读(54)  评论(0)    收藏  举报