Skip to content

Commit

Permalink
1.0.0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
x-nas committed Apr 11, 2022
1 parent ccfaf6a commit d93991d
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 203 deletions.
2 changes: 1 addition & 1 deletion ProcessInjector/ProcessInjector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PublisherName>X-NAS</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>24</ApplicationRevision>
<ApplicationRevision>25</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
Expand Down
27 changes: 0 additions & 27 deletions WPELibrary/Lib/MainClass.cs

This file was deleted.

76 changes: 49 additions & 27 deletions WPELibrary/Lib/Socket_Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public static void SocketToQueue(int iSocket, IntPtr ipBuff, int iLen, Socket_Pa
private static void SocketToQueue_Thread(object ob)
{
Socket_Packet sp = (Socket_Packet)ob;
qSocket_Packet.Enqueue(sp);

lock (qSocket_Packet)
{
qSocket_Packet.Enqueue(sp);
}
}

#endregion
Expand Down Expand Up @@ -102,31 +106,45 @@ public static void SocketToList(int iMax_DataLen)

string sIP_From = "", sIP_To = "";

if (sType.Equals(Socket_Packet.SocketType.Recv))
{
sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
}
else if (sType.Equals(Socket_Packet.SocketType.Send))
{
sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);
}
else if (sType.Equals(Socket_Packet.SocketType.SendTo))
{
sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
sIP_To = Socket_Operation.GetSocketIP(sAddr.sin_addr, sAddr.sin_port);
}
else if (sType.Equals(Socket_Packet.SocketType.RecvFrom))
{
sIP_From = Socket_Operation.GetSocketIP(sAddr.sin_addr, sAddr.sin_port);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
}
else
{
sIP_From = "127.0.0.1";
sIP_To = "127.0.0.1";
}
switch (sType)
{
case Socket_Packet.SocketType.Recv:

sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);

break;
case Socket_Packet.SocketType.WSARecv:

sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);

break;
case Socket_Packet.SocketType.Send:

sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);

break;
case Socket_Packet.SocketType.WSASend:

sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.To);

break;
case Socket_Packet.SocketType.SendTo:

sIP_From = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);
sIP_To = Socket_Operation.GetSocketIP(sAddr.sin_addr, sAddr.sin_port);

break;
case Socket_Packet.SocketType.RecvFrom:

sIP_From = Socket_Operation.GetSocketIP(sAddr.sin_addr, sAddr.sin_port);
sIP_To = Socket_Operation.GetSocketIP(iSocket, Socket_Packet.IPType.From);

break;
}

Socket_Packet_Info si = new Socket_Packet_Info(iIndex, sType, iSocket, sIP_From, sIP_To, iResLen, sData, bBuffer);

Expand Down Expand Up @@ -258,7 +276,11 @@ public static void LogToQueue(string sLogContent)
private static void LogToQueue_Thread(object ob)
{
Socket_Log sl = (Socket_Log)ob;
qSocket_Log.Enqueue(sl);

lock (qSocket_Log)
{
qSocket_Log.Enqueue(sl);
}
}

#endregion
Expand Down
46 changes: 38 additions & 8 deletions WPELibrary/Lib/Socket_Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,36 @@ public static string GetSocketType_CN(Socket_Packet.SocketType stType)
case Socket_Packet.SocketType.Send:
sReturn = "发送";
break;
case Socket_Packet.SocketType.WSASend:
sReturn = "WSA发送";
break;
case Socket_Packet.SocketType.SendTo:
sReturn = "发送到";
break;
case Socket_Packet.SocketType.Recv:
sReturn = "接收";
break;
case Socket_Packet.SocketType.WSARecv:
sReturn = "WSA接收";
break;
case Socket_Packet.SocketType.RecvFrom:
sReturn = "接收自";
break;
case Socket_Packet.SocketType.Send_Interecept:
sReturn = "拦截-发送";
break;
case Socket_Packet.SocketType.WSASend_Interecept:
sReturn = "拦截-WSA发送";
break;
case Socket_Packet.SocketType.SendTo_Interecept:
sReturn = "拦截-发送到";
break;
case Socket_Packet.SocketType.Recv_Interecept:
sReturn = "拦截-接收";
break;
case Socket_Packet.SocketType.WSARecv_Interecept:
sReturn = "拦截-WSA接收";
break;
case Socket_Packet.SocketType.RecvFrom_Interecept:
sReturn = "拦截-接收自";
break;
Expand Down Expand Up @@ -360,20 +372,23 @@ public static bool ISShow_SocketInfo(Socket_Packet s)
bool bISShow_BySize = ISShow_BySize(iResLen);
if (!bISShow_BySize)
{
DoLog("[过滤封包大小] " + iResLen.ToString());
return false;
}

//套接字
bool bISShow_BySocket = ISShow_BySocket(iSocket);
if (!bISShow_BySocket)
{
DoLog("[过滤套接字] " + iSocket.ToString());
return false;
}

//IP地址
bool bISShow_ByIP = ISShow_ByIP(sIP_From, sIP_To);
if (!bISShow_ByIP)
{
DoLog("[过滤IP地址] " + sIP_From + " / " + sIP_To);
return false;
}

Expand All @@ -382,6 +397,7 @@ public static bool ISShow_SocketInfo(Socket_Packet s)
bool bISShow_ByPacket = ISShow_ByPacket(sPacket);
if (!bISShow_ByPacket)
{
DoLog("[过滤封包内容] " + sPacket);
return false;
}

Expand Down Expand Up @@ -780,21 +796,35 @@ public static void ShowMessageBox(string sMessage)
#region//日志
public static void DoLog_HookInfo(Socket_Packet.SocketType sType, int iSocket, int iLen, int iRes)
{
if (bDoLog_Hook)
try
{
string sTypeCN = GetSocketType_CN(sType);
if (bDoLog_Hook)
{
string sTypeCN = GetSocketType_CN(sType);

string sLog = "[" + sTypeCN + "]" + " - " + iSocket.ToString() + "," + iRes.ToString() + " / " + iLen.ToString();
DoLog(sLog);
}
string sLog = "[" + sTypeCN + "]" + " - " + iSocket.ToString() + "," + iRes.ToString() + " / " + iLen.ToString();
DoLog(sLog);
}
}
catch (Exception ex)
{
DoLog(ex.Message);
}
}

public static void DoLog(string sLogContent)
{
if (bDoLog)
try
{
Socket_Cache.LogQueue.LogToQueue(sLogContent);
}
if (bDoLog)
{
Socket_Cache.LogQueue.LogToQueue(sLogContent);
}
}
catch (Exception ex)
{
DoLog(ex.Message);
}
}
#endregion
}
Expand Down
24 changes: 17 additions & 7 deletions WPELibrary/Lib/Socket_Packet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@ public struct sockaddr
public byte[] sin_zero;
}

public unsafe struct WSABUF
{
public Int32 len;
public IntPtr buf;
}

public enum SocketType
{
Send = 1,
SendTo = 2,
Recv = 3,
RecvFrom = 4,
Send_Interecept = 5,
SendTo_Interecept = 6,
Recv_Interecept = 7,
RecvFrom_Interecept = 8,
WSASend = 2,
SendTo = 3,
Recv = 4,
WSARecv = 5,
RecvFrom = 6,
Send_Interecept = 7,
WSASend_Interecept = 8,
SendTo_Interecept = 9,
Recv_Interecept = 10,
WSARecv_Interecept = 11,
RecvFrom_Interecept = 12,
}

public enum IPType
Expand Down
Loading

0 comments on commit d93991d

Please sign in to comment.