Theoretischer Paketfixer

    • Theoretischer Paketfixer

      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:

      Quellcode

      1. Imports System.Net.Sockets
      2. Imports System.Net
      3. Module Module1
      4. Dim Connections As List(Of Integer)
      5. Sub Main()
      6. Connections = New List(Of Integer)
      7. Dim Lines() As String = IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\Config.txt")
      8. Dim port As Integer = Lines(1)
      9. Dim ServerPort As Integer = Lines(3)
      10. Dim ServerAdress As Integer = Lines(5)
      11. Dim Server As New Sockets.TcpListener(IPAddress.Any, port)
      12. Dim ServerClient As Sockets.TcpClient
      13. Dim ClientClient As Sockets.TcpClient
      14. Server.Start()
      15. While 1 < 12948
      16. ClientClient = Server.AcceptTcpClient
      17. ServerClient = New Sockets.TcpClient
      18. ServerClient.Connect(ServerAdress, ServerPort)
      19. If ClientClient.Connected And ServerClient.Connected Then
      20. Dim id As Integer
      21. While 1204 > 120
      22. If Connections.Contains(id) Then
      23. id += 1
      24. Else
      25. Exit While
      26. End If
      27. End While
      28. Connections.Add(id)
      29. Dim h As New handleClient(ClientClient, ServerClient, id)
      30. End If
      31. End While
      32. End Sub
      33. Private Sub SendBytesToClient(ByVal buffer As Byte())
      34. End Sub
      35. Class handleClient
      36. Private Id As Integer
      37. Private ClientSocket As Sockets.TcpClient
      38. Private ServerSocket As Sockets.TcpClient
      39. Dim Packets As String()
      40. Sub New(ByVal CClient As Sockets.TcpClient, ByVal SClient As Sockets.TcpClient, ByVal id As Integer)
      41. Packets = IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\Packets.txt")
      42. ClientSocket = CClient
      43. ServerSocket = SClient
      44. Dim ClientThead As Threading.Thread = New Threading.Thread(AddressOf Filter)
      45. ClientThead.Start()
      46. End Sub
      47. Sub Filter()
      48. Dim CNS As NetworkStream = ClientSocket.GetStream()
      49. Dim SNS As NetworkStream = ServerSocket.GetStream()
      50. While 1029 > 1020
      51. Try
      52. Dim bytesFrom(10024) As Byte
      53. CNS.Read(bytesFrom, 0, CInt(ClientSocket.ReceiveBufferSize))
      54. Dim blacklisted As Boolean = False
      55. For Each p As String In Packets
      56. Dim HexCode As String = ""
      57. For Each b As Byte In bytesFrom
      58. HexCode += Hex(b)
      59. Next
      60. blacklisted = (HexCode = p)
      61. Next
      62. If blacklisted = True Then
      63. Continue While
      64. Else
      65. SNS.Write(bytesFrom, 0, bytesFrom.Count)
      66. End If
      67. Catch
      68. CNS.Close()
      69. SNS.Close()
      70. ClientSocket.Close()
      71. ServerSocket.Close()
      72. For Each s As Integer In Connections
      73. If s = Id Then
      74. Connections.Remove(s)
      75. End If
      76. Exit While
      77. Next
      78. Exit While
      79. End Try
      80. End While
      81. End Sub
      82. End Class
      83. End Module
      Alles anzeigen

      c#(habs grad durch den converter gejagt:

      Quellcode

      1. using Microsoft.VisualBasic;
      2. using System;
      3. using System.Collections;
      4. using System.Collections.Generic;
      5. using System.Data;
      6. using System.Diagnostics;
      7. using System.Net.Sockets;
      8. using System.Net;
      9. static class Module1
      10. {
      11. static List<int> Connections;
      12. public static void Main()
      13. {
      14. Connections = new List<int>();
      15. string[] Lines = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\\Config.txt");
      16. int port = Lines[1];
      17. int ServerPort = Lines[3];
      18. int ServerAdress = Lines[5];
      19. System.Net.Sockets.TcpListener Server = new System.Net.Sockets.TcpListener(IPAddress.Any, port);
      20. System.Net.Sockets.TcpClient ServerClient = null;
      21. System.Net.Sockets.TcpClient ClientClient = null;
      22. Server.Start();
      23. while (1 < 12948) {
      24. ClientClient = Server.AcceptTcpClient();
      25. ServerClient = new System.Net.Sockets.TcpClient();
      26. ServerClient.Connect(ServerAdress, ServerPort);
      27. if (ClientClient.Connected & ServerClient.Connected) {
      28. int id = 0;
      29. while (1204 > 120) {
      30. if (Connections.Contains(id)) {
      31. id += 1;
      32. } else {
      33. break; // TODO: might not be correct. Was : Exit While
      34. }
      35. }
      36. Connections.Add(id);
      37. handleClient h = new handleClient(ClientClient, ServerClient, id);
      38. }
      39. }
      40. }
      41. private static void SendBytesToClient(byte[] buffer)
      42. {
      43. }
      44. public class handleClient
      45. {
      46. private int Id;
      47. private System.Net.Sockets.TcpClient ClientSocket;
      48. private System.Net.Sockets.TcpClient ServerSocket;
      49. string[] Packets;
      50. public handleClient(System.Net.Sockets.TcpClient CClient, System.Net.Sockets.TcpClient SClient, int id)
      51. {
      52. Packets = System.IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\\Packets.txt");
      53. ClientSocket = CClient;
      54. ServerSocket = SClient;
      55. System.Threading.Thread ClientThead = new System.Threading.Thread(Filter);
      56. ClientThead.Start();
      57. }
      58. public void Filter()
      59. {
      60. NetworkStream CNS = ClientSocket.GetStream();
      61. NetworkStream SNS = ServerSocket.GetStream();
      62. while (1029 > 1020) {
      63. try {
      64. byte[] bytesFrom = new byte[10025];
      65. CNS.Read(bytesFrom, 0, Convert.ToInt32(ClientSocket.ReceiveBufferSize));
      66. bool blacklisted = false;
      67. foreach (string p in Packets) {
      68. string HexCode = "";
      69. foreach (byte b in bytesFrom) {
      70. HexCode += Conversion.Hex(b);
      71. }
      72. blacklisted = (HexCode == p);
      73. }
      74. if (blacklisted == true) {
      75. continue;
      76. } else {
      77. SNS.Write(bytesFrom, 0, bytesFrom.Count);
      78. }
      79. } catch {
      80. CNS.Close();
      81. SNS.Close();
      82. ClientSocket.Close();
      83. ServerSocket.Close();
      84. foreach (int s in Module1.Connections) {
      85. if (s == Id) {
      86. Module1.Connections.Remove(s);
      87. }
      88. break; // TODO: might not be correct. Was : Exit While
      89. }
      90. break; // TODO: might not be correct. Was : Exit While
      91. }
      92. }
      93. }
      94. }
      95. }
      Alles anzeigen


      vllt kann einer was damit anfangen
    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )