-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample.cpp
More file actions
69 lines (65 loc) · 3.13 KB
/
Example.cpp
File metadata and controls
69 lines (65 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <windows.h>
#include <stdexcept>
typedef void __stdcall (*ptr_SetupSniffer)();
typedef void __stdcall (*ptr_SetInterface)(int Interf);
typedef int __stdcall (*ptr_GetInterface)();
typedef bool __stdcall (*ptr_Initialize)();
typedef void __stdcall (*ptr_DeInitialize)();
typedef void __stdcall (*ptr_Start)();
typedef void __stdcall (*ptr_Stop)();
typedef void __stdcall (*ptr_RemoveSourceIP)(std::string OldIP);
typedef void __stdcall (*ptr_RemoveDestinationIP)(std::string OldIP);
typedef void __stdcall (*ptr_AddDestinationIP)(std::string NewIP);
typedef void __stdcall (*ptr_AddSourceIP)(std::string NewIP);
typedef void __stdcall (*ptr_FilterIP)(bool FilterIPs);
typedef void __stdcall (*ptr_ListenSource)(bool Listen);
typedef void __stdcall (*ptr_ListenDestination)(bool Listen);
typedef std::string __stdcall (*ptr_GetIP)(std::string Address);
typedef void __stdcall (*ptr_Test)();
int main()
{
HMODULE SockDll = LoadLibrary("NetworkSniffer.dll");
if (SockDll != NULL)
{
ptr_SetupSniffer SetupSniffer = (ptr_SetupSniffer)GetProcAddress(SockDll, "SetupSniffer");
ptr_SetInterface SetInterface = (ptr_SetInterface)GetProcAddress(SockDll, "SetInterface");
ptr_GetInterface GetInterface = (ptr_GetInterface)GetProcAddress(SockDll, "GetInterface");
ptr_Initialize Initialize = (ptr_Initialize)GetProcAddress(SockDll, "Initialize");
ptr_DeInitialize DeInitialize = (ptr_DeInitialize)GetProcAddress(SockDll, "DeInitialize");
ptr_Start Start = (ptr_Start)GetProcAddress(SockDll, "Start");
ptr_Stop Stop = (ptr_Stop)GetProcAddress(SockDll, "Stop");
ptr_GetIP GetIP = (ptr_GetIP)GetProcAddress(SockDll, "GetIP");
ptr_RemoveSourceIP RemoveSourceIP = (ptr_RemoveSourceIP)GetProcAddress(SockDll, "RemoveSourceIP");
ptr_RemoveDestinationIP RemoveDestinationIP = (ptr_RemoveDestinationIP)GetProcAddress(SockDll, "RemoveDestinationIP");
ptr_AddDestinationIP AddDestinationIP = (ptr_AddDestinationIP)GetProcAddress(SockDll, "AddDestinationIP");
ptr_AddSourceIP AddSourceIP = (ptr_AddSourceIP)GetProcAddress(SockDll, "AddSourceIP");
ptr_FilterIP FilterIP = (ptr_FilterIP)GetProcAddress(SockDll, "FilterIP");
ptr_ListenSource ListenSource = (ptr_ListenSource)GetProcAddress(SockDll, "ListenSource");
ptr_ListenDestination ListenDestination = (ptr_ListenDestination)GetProcAddress(SockDll, "ListenDestination");
if (SetupSniffer != nullptr)
{
try
{
SetupSniffer();
SetInterface(0);
Initialize();
AddSourceIP(GetIP("127.0.0.1"));
AddSourceIP(GetIP("en.wikipedia.org"));
AddDestinationIP(GetIP("en.wikipedia.org"));
AddDestinationIP(GetIP("127.0.0.1"));
ListenSource(true);
ListenDestination(true);
FilterIP(true);
Start();
}
catch (std::exception &e)
{
std::cout<<"\nERROR: "<<e.what();
Stop();
DeInitialize();
}
}
}
return 0;
}