资源简介
可以使用此开源代码去捕获本机数据包,然后自己去分析数据包
代码片段和文件信息
/*
* windivert.c
* (C) 2016 all rights reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation either version 3 of the License or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not see .
*/
#ifndef UNICODE
#define UNICODE
#endif
#include
#include
#include
#include
#include
#include
#define WINDIVERTEXPORT
#include “windivert.h“
#include “windivert_device.h“
#define WINDIVERT_DRIVER_NAME L“WinDivert“
#define WINDIVERT_DRIVER32_SYS L“\\“ WINDIVERT_DRIVER_NAME L“32.sys“
#define WINDIVERT_DRIVER64_SYS L“\\“ WINDIVERT_DRIVER_NAME L“64.sys“
/*
* Definitions to remove (some) external dependencies:
*/
#define BYTESWAP16(x) \
((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00))
#define BYTESWAP32(x) \
((((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) | \
(((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000))
#define ntohs(x) BYTESWAP16(x)
#define htons(x) BYTESWAP16(x)
#define ntohl(x) BYTESWAP32(x)
#define htonl(x) BYTESWAP32(x)
static BOOLEAN WinDivertStrLen(const wchar_t *s size_t maxlen
size_t *lenptr);
static BOOLEAN WinDivertStrCpy(wchar_t *dst size_t dstlen
const wchar_t *src);
static BOOLEAN WinDivertAToI(const char *str char **endptr UINT32 *intptr);
static BOOLEAN WinDivertAToX(const char *str char **endptr UINT32 *intptr);
/*
* IPv4/IPv6 pseudo headers.
*/
typedef struct
{
UINT32 SrcAddr;
UINT32 DstAddr;
UINT8 Zero;
UINT8 Protocol;
UINT16 Length;
} WINDIVERT_PSEUDOHDR *PWINDIVERT_PSEUDOHDR;
typedef struct
{
UINT32 SrcAddr[4];
UINT32 DstAddr[4];
UINT32 Length;
UINT32 Zero:24;
UINT32 NextHdr:8;
} WINDIVERT_PSEUDOV6HDR *PWINDIVERT_PSEUDOV6HDR;
/*
* Misc.
*/
#ifndef UINT8_MAX
#define UINT8_MAX 0xFF
#endif
#ifndef UINT32_MAX
#define UINT32_MAX 0xFFFFFFFF
#endif
/*
* Prototypes.
*/
static BOOLEAN WinDivertUse32Bit(void);
static BOOLEAN WinDivertGetDriverFileName(LPWSTR sys_str);
static SC_HANDLE WinDivertDriverInstall(VOID);
static BOOL WinDivertIoControl(HANDLE handle DWORD code UINT8 arg8
UINT64 arg PVOID buf UINT len UINT *iolen);
static BOOL WinDivertIoControlEx(HANDLE handle DWORD code UINT8 arg8
UINT64 arg PVOID buf UINT len UINT *iolen LPOVERLAPPED overlapped);
static UINT8
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-09-24 08:24 Divert-1.3.0\
文件 4161 2017-09-24 08:24 Divert-1.3.0\CHANGELOG
文件 40154 2017-09-24 08:24 Divert-1.3.0\LICENSE
文件 4921 2017-09-24 08:24 Divert-1.3.0\README
文件 6 2017-09-24 08:24 Divert-1.3.0\VERSION
文件 46 2017-09-24 08:24 Divert-1.3.0\dirs
目录 0 2017-09-24 08:24 Divert-1.3.0\dll\
文件 36 2017-09-24 08:24 Divert-1.3.0\dll\Makefile
文件 1175 2017-09-24 08:24 Divert-1.3.0\dll\sources
文件 27341 2017-09-24 08:24 Divert-1.3.0\dll\windivert.c
文件 419 2017-09-24 08:24 Divert-1.3.0\dll\windivert.def
文件 2572 2017-09-24 08:24 Divert-1.3.0\dll\windivert.vcxproj
文件 72885 2017-09-24 08:24 Divert-1.3.0\dll\windivert_helper.c
目录 0 2017-09-24 08:24 Divert-1.3.0\doc\
文件 52811 2017-09-24 08:24 Divert-1.3.0\doc\windivert.html
目录 0 2017-09-24 08:24 Divert-1.3.0\examples\
文件 95 2017-09-24 08:24 Divert-1.3.0\examples\dirs
目录 0 2017-09-24 08:24 Divert-1.3.0\examples\netdump\
文件 36 2017-09-24 08:24 Divert-1.3.0\examples\netdump\Makefile
文件 9175 2017-09-24 08:24 Divert-1.3.0\examples\netdump\netdump.c
文件 2534 2017-09-24 08:24 Divert-1.3.0\examples\netdump\netdump.vcxproj
文件 1125 2017-09-24 08:24 Divert-1.3.0\examples\netdump\sources
目录 0 2017-09-24 08:24 Divert-1.3.0\examples\netfilter\
文件 36 2017-09-24 08:24 Divert-1.3.0\examples\netfilter\Makefile
文件 14154 2017-09-24 08:24 Divert-1.3.0\examples\netfilter\netfilter.c
文件 2538 2017-09-24 08:24 Divert-1.3.0\examples\netfilter\netfilter.vcxproj
文件 1129 2017-09-24 08:24 Divert-1.3.0\examples\netfilter\sources
目录 0 2017-09-24 08:24 Divert-1.3.0\examples\passthru\
文件 36 2017-09-24 08:24 Divert-1.3.0\examples\passthru\Makefile
文件 3348 2017-09-24 08:24 Divert-1.3.0\examples\passthru\passthru.c
文件 2536 2017-09-24 08:24 Divert-1.3.0\examples\passthru\passthru.vcxproj
............此处省略28个文件信息
评论
共有 条评论