Raw Socket

Linux raw socket的总结 介绍相关结构体和常量, 最后实现ICMP接收和响应 创建套接字 int sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); 创建一个IPV4 ICMP原始套接字(IPV4 ICMP raw socket) AF_INET: 代表IPV4协议 SOCK_RAW: 代表原始套接字 IPPROTO_ICMP: 代表ICMP协议 禁用内核自动附加IP头 int on = 1; setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)); 启用IP_HDRINCL选项, 数据包含IP数据头, 发送数据时需要自己构建IP数据头, 内核不再生成 接收数据 char* buf = calloc(1, IPPROTO_MAX); struct sockaddr in; socklen_t in_len = sizeof(in); recvfrom(sock, buf, IPPROTO_MAX, 0, &in, &in_len); 将数据写入buf, 发送方地址将保存在in变量 解析数据段 struct iphdr *ip = (struct iphdr*)buf; struct icmphdr *icmp = (struct icmphdr*)((char*)ip + 4 * ip->ihl); printf("data: %s\n", (char*)icmp + 8); iphdr是ip header的缩写, 表示一个IP数据头结构 IHL(Internet Header Length): IP数据头是不定长的, 所以需要IHL记录IP数据头大小, 以4字节为单位, 所以IP数据头大小等于4 * IHL bytes...

March 8, 2023 · b1n

SharkLoadLibrary

SharkLoadLibrary 是 DarkLoadLibrary 的完整版 在DarkLoadLibrary中的darkloadlibrary.h文件中, 作者定义了一组宏, 用于Control Flags #define LOAD_LOCAL_FILE 0x00000001 #define LOAD_REMOTE_FILE 0x00000002 #define LOAD_MEMORY 0x00000003 #define NO_LINK 0x00010000 可以看到, 作者早就定义好了LOAD_REMOTE_FILE的宏, 只不过在公开项目时删除了相关功能我将功能完善了, 开源在github供大家使用: SharkLoadLibrary 以下是项目介绍: LoadLibrary for Children’s Paradise. :sailboat: Folk From DarkLoadLibrary and thanks. Feature New feature: LOAD_REMOTE_FILE Usage PDARKMODULE DarkModule = DarkLoadLibrary( LOAD_REMOTE_FILE, // control flags "http://xxxx/demo.dll", // remote dll url, if loading from remote NULL, // dll buffer to load from if loading from memory 0, // dll size if loading from memory "Demo" // dll name if loaded from memory and remote ); Build && Test Environmental requirements libcurl Install from vcpkg: ....

December 26, 2022 · b1n