Skip to content
Snippets Groups Projects
Commit 6d629d07 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

remove some print for testing

parent 31d3ab85
No related branches found
No related tags found
No related merge requests found
......@@ -12,8 +12,8 @@ def process_packet(new_packet):
pkt = IP(data)
if pkt.haslayer(IP):
print(f"IP Packet: {pkt.summary()}")
pkt.show()
# print(f"IP Packet: {pkt.summary()}")
# pkt.show()
index_custom_option = -1
if pkt.options:
......@@ -26,7 +26,7 @@ def process_packet(new_packet):
# save ip address for later attacker, node_id and interface_num
if entry["cmd"] == Cmd.REGISTER:
print(f"Custom Option from REGISTER found: id = {entry['node_id']}, inter = vmnet{entry['inter_num']}")
print(f"Custom Option from REGISTER found: id = {entry['node_id']}, inter = ens{entry['inter_num']}")
map_IP_with_source_switch[pkt[IP].src] = {"node_id": entry['node_id'], "inter_num": entry['inter_num']}
IP_attacker = "172.16.60.133"
......@@ -50,7 +50,7 @@ def process_packet(new_packet):
del pkt[IP].chksum # Invalidate the checksum
new_packet.set_payload(bytes(pkt))
pkt.show()
# pkt.show()
new_packet.accept()
......
......@@ -14,12 +14,12 @@ my_id = 1
def process_packet(new_packet):
global my_id
global my_id, name_interface
inter_num = new_packet.get_mark()
# Determine the incoming interface based on the mark
interface = MARK_TO_INTERFACE.get(inter_num, 'unknown')
print(interface)
# interface = MARK_TO_INTERFACE.get(inter_num, 'unknown')
# print(interface)
data = new_packet.get_payload()
......@@ -28,8 +28,8 @@ def process_packet(new_packet):
# Check if it's a TCP packet
if pkt.haslayer(IP):
print(f"IP Packet: {pkt.summary()}")
pkt.show()
# print(f"IP Packet: {pkt.summary()}")
# pkt.show()
is_register_me = True
index_custom_option = -1
......@@ -42,7 +42,7 @@ def process_packet(new_packet):
for entry in option.read_all_entry():
if entry["cmd"] == Cmd.DECISION_DROP:
print(
f"Custom Option from DECISION found: id = {entry['node_id']}, inter = vmnet{entry['inter_num']}, cmd = {entry['cmd']}")
f"Custom Option from DECISION found: id = {entry['node_id']}, inter = {name_interface}{entry['inter_num']}, cmd = {entry['cmd']}")
# Do something to deploy firewall
elif entry["cmd"] == Cmd.REGISTER:
is_register_me = False
......@@ -62,7 +62,7 @@ def process_packet(new_packet):
del pkt.ihl
del pkt[IP].chksum # Invalidate the checksum
new_packet.set_payload(bytes(pkt))
pkt.show() # Now this will work correctly
# pkt.show() # Now this will work correctly
new_packet.accept()
......
#!/bin/bash
sudo ip addr add 192.168.1.10/24 dev ens3
sudo nmcli con mod ens3 ipv4.method manual
sudo nmcli con mod ens3 ipv4.addresses 192.168.1.10/24
sudo nmcli con mod ens3 ipv4.gateway 192.168.1.5
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment