Skip to content
This repository was archived by the owner on Aug 6, 2024. It is now read-only.

Commit 2c6e6b0

Browse files
committed
Initial implementation for SSL sniffing.
Based on code from NetRipper (@NytroRST)
1 parent 2c479bc commit 2c6e6b0

29 files changed

+2379
-581
lines changed

DLL/DebugFunctions.cpp

-104
This file was deleted.

DLL/Defines.h

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ enum Functions
3939
CODE_WSASENDTO,
4040
CODE_WSARECV,
4141
CODE_WSARECVFROM,
42+
CODE_PR_READ,
43+
CODE_PR_WRITE,
44+
CODE_PR_RECV,
45+
CODE_PR_SEND,
46+
CODE_SSLENCRYPTPACKET,
47+
CODE_SSLDECRYPTPACKET,
48+
CODE_ENCRYPTMESSAGE,
49+
CODE_DECRYPTMESSAGE,
50+
CODE_SSL_WRITE,
51+
CODE_SSL_READ
4252
};
4353

4454
enum ServerCodes

DLL/DllCommunication.cpp

+24-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "OspeDll.h"
2222
#include "FilterManager.h"
2323
#include <sstream>
24-
24+
#include "Utils.h"
2525

2626
//#define DBG_BLOCKPKT // para debuggear packets bloqueados
2727
#define DBG_SENDPACKETDATA // para debuggear data de los packets
@@ -41,10 +41,10 @@ void SetInfo(SOCKET socket, Functions functionId, int length, PacketInfo* info)
4141
socklen_t addr_len = sizeof(struct sockaddr_storage);
4242

4343
if (getsockname(socket, (struct sockaddr*)&addrLocal, &addr_len) == SOCKET_ERROR)
44-
errorLog(strm(2, "getsockname: ", itos(WSAGetLastError())));
44+
Utils::errorLog(Utils::strm(2, "getsockname: ", Utils::IntToString(WSAGetLastError())));
4545

4646
if (getpeername(socket, (struct sockaddr*)&addrRemote, &addr_len) == SOCKET_ERROR)
47-
errorLog(strm(2, "getpeername: ", itos(WSAGetLastError())));
47+
Utils::errorLog(Utils::strm(2, "getpeername: ", Utils::IntToString(WSAGetLastError())));
4848

4949
// deal with both IPv4 and IPv6:
5050
if (addrLocal.ss_family == AF_INET)
@@ -59,7 +59,7 @@ void SetInfo(SOCKET socket, Functions functionId, int length, PacketInfo* info)
5959
else
6060
{ // AF_INET6
6161
//Falta implementar
62-
errorLog("CRASH ALERT: IPv6 SOCKET NOT IMPLEMENTED");
62+
Utils::errorLog("CRASH ALERT: IPv6 SOCKET NOT IMPLEMENTED");
6363
//struct sockaddr_in6 *sock_addr = (struct sockaddr_in6 *)&addrFrom;
6464
//info->portFrom = ntohs(sock_addr->sin6_port);
6565
//inet_ntop(AF_INET6, &sock_addr->sin6_addr, ipstr, sizeof ipstr);
@@ -83,14 +83,24 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
8383
if (!client.IsOk())
8484
{
8585
#ifdef DBG_SENDPACKETDATA
86-
errorLog("Fail to open MMF!!", 1);
86+
Utils::errorLog("Fail to open MMF!!", 1);
8787
#endif
8888
return;
8989
}
9090

9191
// Set needed packet info (ip, port, Function, Size)
9292
PacketInfo info;
93-
SetInfo(socket, functionId, (int)length, &info);
93+
if (socket != NULL)
94+
SetInfo(socket, functionId, (int)length, &info);
95+
else {
96+
info.functionId = functionId;
97+
info.localIp = 0;
98+
info.localPort = 0;
99+
info.remoteIp = 0;
100+
info.remotePort = 0;
101+
info.size = length;
102+
info.socketId = 0;
103+
}
94104

95105
// Set data
96106

@@ -99,7 +109,7 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
99109
std::stringstream sinfo;
100110
sinfo << "GOT Info - FunctionID=" << info.functionId << " LocalIp=" << info.localIp << " LocalPort=" << info.localPort << " RemoteIp="
101111
<< info.remoteIp << " RemotePort=" << info.remotePort << " Size=" << info.size;
102-
errorLog((char*)sinfo.str().c_str(), 2);
112+
Utils::errorLog((char*)sinfo.str().c_str(), 2);
103113
#endif
104114

105115
char* pBuff = (char *) malloc(sizeof(info) + length);
@@ -137,6 +147,12 @@ void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET sock
137147
free(pBuff);
138148
}
139149

150+
void ProcessPacket(Functions functionId, char*& buffer, int& length)
151+
{
152+
bool blocked = false;
153+
ProcessPacket(functionId, buffer, length, NULL, blocked);
154+
}
155+
140156
void InjectPacket()
141157
{
142158
SOCKET s = (((UINT8)readData[2] << 8) | (UINT8)readData[1]);
@@ -184,7 +200,7 @@ DWORD WINAPI Command_Reader(LPVOID context)
184200
UnLoadDllEx();
185201
break;
186202
default:
187-
errorLog("UNKNOWN SERVER CODE!");
203+
Utils::errorLog("UNKNOWN SERVER CODE!");
188204
}
189205

190206
}

DLL/DllCommunication.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#ifndef DLLCOMMUNICATION_H
20+
#define DLLCOMMUNICATION_H
21+
1922
#include <ws2tcpip.h>
2023
#include "Defines.h"
2124

@@ -26,5 +29,9 @@
2629

2730

2831
void SetInfo(SOCKET socket, Functions functionId, int length, PacketInfo* info);
29-
void ProcessPacket(Functions functionId, char* &buffer, int &length, SOCKET socket, bool &blocked);
30-
DWORD WINAPI Command_Reader(LPVOID context);
32+
void ProcessPacket(Functions functionId, char*& buffer, int& length, SOCKET socket, bool& blocked);
33+
void ProcessPacket(Functions functionId, char*& buffer, int& length);
34+
35+
DWORD WINAPI Command_Reader(LPVOID context);
36+
37+
#endif // DLLCOMMUNICATION_H

DLL/FilterManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ bool DoFilteringForPacket(char * data, UINT16 size, FilterCaptureFuncs functionF
7878
bool CheckPacketBlock(char * data, UINT16 size, FilterCaptureFuncs functionFlag);
7979
bool CheckPacketBreak(char * data, UINT16 size, FilterCaptureFuncs functionFlag);
8080

81-
#endif
81+
#endif // FILTERMANAGER_H

0 commit comments

Comments
 (0)