ich habe einen noch ungetesteten paket fixxer source rumliegen
es ist nur die grundstrucktur sachen wie an clienten posten etc müsst ihr noch selbst machen
ich habe keinen plan ob es überhaupt funktioniert nie getestet
VB:
Alles anzeigen
c#(habs grad durch den converter gejagt:
Alles anzeigen
vllt kann einer was damit anfangen
es ist nur die grundstrucktur sachen wie an clienten posten etc müsst ihr noch selbst machen
ich habe keinen plan ob es überhaupt funktioniert nie getestet
VB:
Quellcode
- Imports System.Net.Sockets
- Imports System.Net
- Module Module1
- Dim Connections As List(Of Integer)
- Sub Main()
- Connections = New List(Of Integer)
- Dim Lines() As String = IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\Config.txt")
- Dim port As Integer = Lines(1)
- Dim ServerPort As Integer = Lines(3)
- Dim ServerAdress As Integer = Lines(5)
- Dim Server As New Sockets.TcpListener(IPAddress.Any, port)
- Dim ServerClient As Sockets.TcpClient
- Dim ClientClient As Sockets.TcpClient
- Server.Start()
- While 1 < 12948
- ClientClient = Server.AcceptTcpClient
- ServerClient = New Sockets.TcpClient
- ServerClient.Connect(ServerAdress, ServerPort)
- If ClientClient.Connected And ServerClient.Connected Then
- Dim id As Integer
- While 1204 > 120
- If Connections.Contains(id) Then
- id += 1
- Else
- Exit While
- End If
- End While
- Connections.Add(id)
- Dim h As New handleClient(ClientClient, ServerClient, id)
- End If
- End While
- End Sub
- Private Sub SendBytesToClient(ByVal buffer As Byte())
- End Sub
- Class handleClient
- Private Id As Integer
- Private ClientSocket As Sockets.TcpClient
- Private ServerSocket As Sockets.TcpClient
- Dim Packets As String()
- Sub New(ByVal CClient As Sockets.TcpClient, ByVal SClient As Sockets.TcpClient, ByVal id As Integer)
- Packets = IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\Packets.txt")
- ClientSocket = CClient
- ServerSocket = SClient
- Dim ClientThead As Threading.Thread = New Threading.Thread(AddressOf Filter)
- ClientThead.Start()
- End Sub
- Sub Filter()
- Dim CNS As NetworkStream = ClientSocket.GetStream()
- Dim SNS As NetworkStream = ServerSocket.GetStream()
- While 1029 > 1020
- Try
- Dim bytesFrom(10024) As Byte
- CNS.Read(bytesFrom, 0, CInt(ClientSocket.ReceiveBufferSize))
- Dim blacklisted As Boolean = False
- For Each p As String In Packets
- Dim HexCode As String = ""
- For Each b As Byte In bytesFrom
- HexCode += Hex(b)
- Next
- blacklisted = (HexCode = p)
- Next
- If blacklisted = True Then
- Continue While
- Else
- SNS.Write(bytesFrom, 0, bytesFrom.Count)
- End If
- Catch
- CNS.Close()
- SNS.Close()
- ClientSocket.Close()
- ServerSocket.Close()
- For Each s As Integer In Connections
- If s = Id Then
- Connections.Remove(s)
- End If
- Exit While
- Next
- Exit While
- End Try
- End While
- End Sub
- End Class
- End Module
c#(habs grad durch den converter gejagt:
Quellcode
- using Microsoft.VisualBasic;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Net.Sockets;
- using System.Net;
- static class Module1
- {
- static List<int> Connections;
- public static void Main()
- {
- Connections = new List<int>();
- string[] Lines = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\\Config.txt");
- int port = Lines[1];
- int ServerPort = Lines[3];
- int ServerAdress = Lines[5];
- System.Net.Sockets.TcpListener Server = new System.Net.Sockets.TcpListener(IPAddress.Any, port);
- System.Net.Sockets.TcpClient ServerClient = null;
- System.Net.Sockets.TcpClient ClientClient = null;
- Server.Start();
- while (1 < 12948) {
- ClientClient = Server.AcceptTcpClient();
- ServerClient = new System.Net.Sockets.TcpClient();
- ServerClient.Connect(ServerAdress, ServerPort);
- if (ClientClient.Connected & ServerClient.Connected) {
- int id = 0;
- while (1204 > 120) {
- if (Connections.Contains(id)) {
- id += 1;
- } else {
- break; // TODO: might not be correct. Was : Exit While
- }
- }
- Connections.Add(id);
- handleClient h = new handleClient(ClientClient, ServerClient, id);
- }
- }
- }
- private static void SendBytesToClient(byte[] buffer)
- {
- }
- public class handleClient
- {
- private int Id;
- private System.Net.Sockets.TcpClient ClientSocket;
- private System.Net.Sockets.TcpClient ServerSocket;
- string[] Packets;
- public handleClient(System.Net.Sockets.TcpClient CClient, System.Net.Sockets.TcpClient SClient, int id)
- {
- Packets = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\\Packets.txt");
- ClientSocket = CClient;
- ServerSocket = SClient;
- System.Threading.Thread ClientThead = new System.Threading.Thread(Filter);
- ClientThead.Start();
- }
- public void Filter()
- {
- NetworkStream CNS = ClientSocket.GetStream();
- NetworkStream SNS = ServerSocket.GetStream();
- while (1029 > 1020) {
- try {
- byte[] bytesFrom = new byte[10025];
- CNS.Read(bytesFrom, 0, Convert.ToInt32(ClientSocket.ReceiveBufferSize));
- bool blacklisted = false;
- foreach (string p in Packets) {
- string HexCode = "";
- foreach (byte b in bytesFrom) {
- HexCode += Conversion.Hex(b);
- }
- blacklisted = (HexCode == p);
- }
- if (blacklisted == true) {
- continue;
- } else {
- SNS.Write(bytesFrom, 0, bytesFrom.Count);
- }
- } catch {
- CNS.Close();
- SNS.Close();
- ClientSocket.Close();
- ServerSocket.Close();
- foreach (int s in Module1.Connections) {
- if (s == Id) {
- Module1.Connections.Remove(s);
- }
- break; // TODO: might not be correct. Was : Exit While
- }
- break; // TODO: might not be correct. Was : Exit While
- }
- }
- }
- }
- }
vllt kann einer was damit anfangen