EXTREMEXPLOIT

Simulation

Jan 8th, 2023
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. from src.main.User import *
  2. from src.netw.InternetPacket import Packet, cleanData
  3. from src.netw.LocalSockets import WebSocketConnection
  4. import threading
  5.  
  6. K1 = DiffieHellmanKey()
  7. K2 = DiffieHellmanKey()
  8. K3 = DiffieHellmanKey()
  9. K4 = DiffieHellmanKey()
  10.  
  11. K1.generateSharedKey(K2.publicKey)
  12. K2.generateSharedKey(K1.publicKey)
  13. K3.generateSharedKey(K4.publicKey)
  14. K4.generateSharedKey(K3.publicKey)
  15.  
  16. N1 = Node("127.0.0.1", K1)
  17. N2 = Node("127.0.0.2", K2)
  18. N3 = Node("127.0.0.3", K3)
  19. N4 = Node("127.0.0.4", K4)
  20.  
  21. Circuit1 = Circuit("CIRCUIT1", [N1, N2])
  22. Circuit2 = Circuit("CIRCUIT1", [N3, N4])
  23.  
  24. ExampleTable = ForwardingTable()
  25. ExampleTable.addEntry("CIRCUIT1", N1)
  26. ExampleTable.addEntry("CIRCUIT2", N2)
  27. ExampleTable.addEntry("CIRCUIT3", N3)
  28. ExampleTable.addEntry("CIRCUIT4", N4)
  29.  
  30. User1 = User(
  31.     1,
  32.     "User1",
  33.     [RSAKeys(fileName="TestKey1"), RSAKeys(fileName="TestKey1")],
  34.     "d8cd7bae-0b80-4a71-a7e5-22f728016311",
  35.     ForwardingTable(),
  36.     Queue(),
  37.     Contacts(),
  38.     MessagesDB(),
  39. )
  40. User1Public = PublicUser(
  41.     1, "User1", [User1.encryptionKeys.publicKey, User1.signingKeys.publicKey], Circuit()
  42. )
  43.  
  44. User2 = User(
  45.     2,
  46.     "User2",
  47.     [RSAKeys(fileName="TestKey2"), RSAKeys(fileName="TestKey2")],
  48.     "9dba0a1d-352d-4f46-bf05-aae7836add60",
  49.     ForwardingTable(),
  50.     Queue(),
  51.     Contacts(),
  52.     MessagesDB(),
  53. )
  54. User2Public = PublicUser(
  55.     2, "User2", [User2.encryptionKeys.publicKey, User2.signingKeys.publicKey], Circuit()
  56. )
  57.  
  58. User1.contacts.addContact(User2Public)
  59. User2.contacts.addContact(User1Public)
  60.  
  61. MSG = User1.createMessageToSent("Hello World!", User2.userName)
  62. ntwMSG = MSG.toNetworkMessage().asJSON().encode()
  63.  
  64. intPacket = Packet(ntwMSG, User1.IP, User2.IP)
  65. intPacket.toNetworkLayer()
  66.  
  67. toRead = []
  68. messagesReceived = WebSocketConnection()
  69.  
  70. # Run messagesReceived.startreceive(toRead) in a separate thread.
  71. threading.Thread(target=messagesReceived.startreceive, args=(toRead,)).start()
  72.  
  73. while True:
  74.     if len(toRead) > 0:
  75.         # Base64 decode the data.
  76.         data = base64.b64decode(toRead.pop(0)).decode()
  77.         cleanData = cleanData(data)
  78.  
  79.         MSG = User2.createMessageToReceive(cleanData)
  80.         print(MSG.content)
  81.  
  82. """
  83. $ node openWebSocket.js
  84. HTML
  85. $ python3 Simulation.py
  86. """
  87.  
Add Comment
Please, Sign In to add comment