首页
社区
课程
招聘
[已解决] 如何获取64位程序静态链接的curl_easy_setopt的函数地址 150.00雪花
2023-7-12 16:59 4712

[已解决] 如何获取64位程序静态链接的curl_easy_setopt的函数地址 150.00雪花

2023-7-12 16:59
4712

如何获取64位程序静态链接的curl_easy_setopt的函数地址,后续用于hookapi学习使用。有偿,请留言
64位程序下载地址
https://web.poecdn.com/protected/downloads/PathOfExileInstaller.exe?key=lpKVe-ZJOqVrur8612s8gg
安装后,程序为PathOfExile.exe


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

最后于 2023-7-13 15:19 被yg008编辑 ,原因: 增加雪花
收藏
点赞1
打赏
分享
最新回复 (11)
雪    币: 1520
活跃值: (3295)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
小希希 2023-7-12 17:33
2
0
找个dll,定位到这个函数提取特征,去目标程序搜索
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-12 17:46
3
0
他调用是libcurl库,直接编译到程序中
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-12 17:47
4
0
https://github.com/topics/libcurl 应该是嵌入这个库
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-12 17:54
5
0
dll我也找了一个,然后如何找相对地址
上传的附件:
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-12 17:57
6
0
基地址应该是这样,uint64_t base_addr = (uint64_t)GetModuleHandleA(NULL);
就是后面的对应函数的偏移量是多少
雪    币: 1450
活跃值: (386728)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
一笑人间万事 2023-7-12 18:56
7
1
PathOfExile.exe+0x2125090
雪    币: 1450
活跃值: (386728)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
一笑人间万事 2023-7-12 19:07
8
1

寻找方法有很多,简单说说,抛砖引玉。
1.使用idasdk flair中sig工具制作libcurl静态库的sig文件,使用ida加载sig,函数体比较短的函数特征可能会有冲突。
2.https://github.com/curl/curl/blob/master/lib/setopt.c#L3180 此函数有一分支retrun CURLE_BAD_FUNCTION_ARGUMENT; 这个宏其值是43,通过43慢慢找或用来佐证是此函数。
3.使用ida的lumina符号服务检索函数名,实测可以识别出大量CURL函数。
4.通过其内部调用的函数Curl_vsetopt进行交叉引用查找,前提是定位到Curl_vsetopt,定位方法同理。这个函数内部有一堆字符串("SESS" "FLUSH"之类)。

最后于 2023-7-12 19:36 被一笑人间万事编辑 ,原因:
雪    币: 39
活跃值: (4187)
能力值: ( LV3,RANK:35 )
在线值:
发帖
回帖
粉丝
ookkaa 2023-7-12 19:57
9
0

这种常见的库就整个lumina服务器就可以了。大把人往上传特征。https://github.com/naim94a/lumen

自己配置一下

最后于 2023-7-12 19:57 被ookkaa编辑 ,原因:
雪    币: 1450
活跃值: (386728)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
一笑人间万事 2023-7-12 20:45
10
1
git上两个开源的lumina服务器已经不适用最新的ida8.3了,协议改动了。
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-13 15:25
11
0
感谢各位大神,现在这个地址貌似是对的,但是用delphi代码去验证是否对的时候,64位程序总是不停崩溃,网上查资料说是delphi和c++的fastcall函数调用方式不一致,需要对齐,但是不知道如何对齐,不知道是验证程序问题还是地址可能有错。这个问题属于衍生问题,当一起解决后,我会另外开贴单独补雪花,方才试了下,不能直接编辑雪花值,只能再开新帖后面。代码如下
var curl_easy_setoptCallNext: function(handle : int64; option : int64; params: int64) : Int64;
register;


function curl_easy_setoptWrap(handle : int64; option : int64; params: int64) : Int64;
 register;
begin
   Result := curl_easy_setoptCallNext(handle, option, params);
   Writelog('my.log', 'call option='+inttostr(option);
end;

function curl_easy_setoptCallBack : Int64;
 register;
asm
  MOV EdX,ECX  //网上拷贝的对齐方法,可能是错的
  JMP curl_easy_setoptWrap
end;

var
 p1: Pointer;
 
p1 := Pointer(GetModuleHandleA(nil)+$2125090);
HookCode(p1, @curl_easy_setoptCallBack, @curl_easy_setoptCallNext);
雪    币: 521
活跃值: (108)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
yg008 2023-7-13 21:40
12
0
我先结贴,然后贴个c的代码,大神帮忙看下这个定义对不对, pascal的我另外开贴,先搞c的
#include <stdint.h>
#include "minhook/include/MinHook.h"


typedef uint16_t(__fastcall* curl_easy_setopt_direct_t)(uint64_t handle, uint8_t option, uint64_t param);
curl_easy_setopt_direct_t curl_easy_setopt_direct = NULL;


HMODULE g_hmod = NULL;
uint64_t curl_dedupe_addr = 0;


uint16_t __fastcall curl_easy_setopt_hooked(uint64_t handle, uint8_t option, uint64_t params)
{
       
  return curl_easy_setopt_direct(handle, option,params);
}

void initialize()
{
  // set up function hooks
  uint64_t base_addr = (uint64_t)GetModuleHandleA(NULL);
  curl_dedupe_addr = base_addr + 0x2125090;

  MH_Initialize();
  MH_CreateHook((LPVOID)curl_dedupe_addr, &curl_easy_setopt_hooked, (LPVOID*)&curl_easy_setopt_direct);
  MH_EnableHook((LPVOID)curl_dedupe_addr);

}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReversed)
{
  switch (fdwReason)
  {
  case DLL_PROCESS_ATTACH:
    g_hmod = hinstDLL;
    initialize();

    break;
  case DLL_PROCESS_DETACH:
    MH_Uninitialize();
    break;
  }

  return TRUE;
}
正确定义是

typedef uint64_t(__fastcall* curl_easy_setopt_direct_t)(uint64_t handle, uint64_t option, uint64_t param);?
游客
登录 | 注册 方可回帖
返回