shellcode技术积累

1.  kernel32.ExpandEnvironmentStringsA可以把"%USERPROFILE%\a.exe"扩展成用户的目录如 "C:\Documents and Settings\Administrator\a.exe",这个有可能会在一些shellcode当中见到。

2.获取当前地址:

    00122528     E8 00000000       call 0012252D
    0012252D     58                pop eax

3. 一段精彩的修改IAT地址表的代码:

int __cdecl sub_402369()
{
  int result; // eax@1
  int pIID; // ebx@1
  HMODULE hmodule2; // esi@1
  HMODULE hModule; // eax@1
  int OrigianlFirstThunk; // edi@3
  void *FirstThunk; // esi@3
  HMODULE i; // [sp+8h] [bp-8h]@1
  DWORD flOldProtect; // [sp+Ch] [bp-4h]@5

  hModule = GetModuleHandleW(0);
  hmodule2 = hModule;
  pIID = (int)((char *)hModule + *(_DWORD *)((char *)hModule + *((_DWORD *)hModule + 15) + 128));// 输入表 IID数组指针
  result = *(_DWORD *)(pIID + 0xC);
  for ( i = hmodule2; result; pIID += 0x14u )
  {
    if ( !stricmp((const char *)hmodule2 + result, "user32.dll") )
    {
      OrigianlFirstThunk = (int)((char *)hmodule2 + *(_DWORD *)pIID);
      FirstThunk = (char *)i + *(_DWORD *)(pIID + 16);
      while ( *(_DWORD *)OrigianlFirstThunk )
      {
        if ( !stricmp((const char *)i + *(_DWORD *)OrigianlFirstThunk + 2, "RegisterClassExW") )
        {
          VirtualProtect(FirstThunk, 4u, 0x40u, &flOldProtect);// 修改内存属性
          *(_DWORD *)FirstThunk = sub_4019EF;   // 修改IAT
          VirtualProtect(FirstThunk, 4u, flOldProtect, &flOldProtect);// 恢复原内存属性
        }
        if ( !stricmp((const char *)i + *(_DWORD *)OrigianlFirstThunk + 2, "CreateWindowExW") )
        {
          VirtualProtect(FirstThunk, 4u, 0x40u, &flOldProtect);
          *(_DWORD *)FirstThunk = sub_402228;
          VirtualProtect(FirstThunk, 4u, flOldProtect, &flOldProtect);
        }
        OrigianlFirstThunk += 4;
        FirstThunk = (char *)FirstThunk + 4;
      }
      hmodule2 = i;
    }
    result = *(_DWORD *)(pIID + 0x20);
  }
  return result;
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值