Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
237f48ea1f | |||
2dea531fa4 | |||
1401be98a0 | |||
76a8559005 | |||
a6be8617e7 | |||
e625775088 | |||
3fea4e5ee5 | |||
03e2601714 | |||
8264964353 | |||
5567ffba0f | |||
2bda1c27c4 | |||
39fc9cd8a9 |
@ -1,6 +1,26 @@
|
|||||||
#!/bin/env python3
|
#!/bin/env python3
|
||||||
|
|
||||||
def check_bridge_socket()::
|
import socket;
|
||||||
|
import sys;
|
||||||
|
|
||||||
|
def init_socket():
|
||||||
|
# Creates a TCP/IP socket
|
||||||
|
# socket type .AF_INET is the Internet address family for IPv4.
|
||||||
|
# .SOCK_STREAM is the socket type for TCP.
|
||||||
|
debug_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
|
# Bind the socket to the port 8000
|
||||||
|
debug_server_address = ('localhost', 8000)
|
||||||
|
debug_socket.bind(debug_server_address)
|
||||||
|
|
||||||
|
# Listen for incoming connections
|
||||||
|
debug_socket.listen(1)
|
||||||
|
while True:
|
||||||
|
# Wait for a connection
|
||||||
|
print >>sys.stderr, 'Waiting for a Connection'
|
||||||
|
connection, client_address = debug_socket.accept()
|
||||||
|
|
||||||
|
def check_bridge_socket():
|
||||||
evt = None
|
evt = None
|
||||||
return evt
|
return evt
|
||||||
|
|
||||||
@ -9,7 +29,6 @@ def handle_bridge_evt(evt):
|
|||||||
TODO: Whatever bridge events to handle
|
TODO: Whatever bridge events to handle
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def check_debug_socket():
|
def check_debug_socket():
|
||||||
dbg_evt = None
|
dbg_evt = None
|
||||||
return dbg_evt
|
return dbg_evt
|
||||||
@ -28,6 +47,7 @@ def run_loop():
|
|||||||
if dbg_evt != None:
|
if dbg_evt != None:
|
||||||
handle_debug_evt(dbg_evt)
|
handle_debug_evt(dbg_evt)
|
||||||
def main():
|
def main():
|
||||||
|
init_socket()
|
||||||
"""
|
"""
|
||||||
1. TODO: Open Server port that the device connects to.
|
1. TODO: Open Server port that the device connects to.
|
||||||
2. TODO: Open Server port that an admin connects to, i.e., to test sending packets to
|
2. TODO: Open Server port that an admin connects to, i.e., to test sending packets to
|
||||||
|
3
server/readme.txt
Normal file
3
server/readme.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
The following link maybe helpful.
|
||||||
|
|
||||||
|
https://github.com/davidbombal/red-python-scripts/blob/main/arp_mitm.py
|
22
server/send_first_packet.py
Normal file
22
server/send_first_packet.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Using the source code and instructions from: https://inc0x0.com/tcp-ip-packets-introduction/tcp-ip-packets-3-manually-create-and-send-raw-tcp-ip-packets/
|
||||||
|
|
||||||
|
import socket
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
|
||||||
|
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
|
||||||
|
|
||||||
|
# b converts string into byte format
|
||||||
|
ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length
|
||||||
|
ip_header += b'\xab\xcd\x00\x00' # Identification | Flags, Fragment Offset
|
||||||
|
ip_header += b'\x40\x06\xa6\xec' # TTL, Protocol | Header Checksum
|
||||||
|
ip_header += b'\x0a\x0a\x0a\x02' # Source Address
|
||||||
|
ip_header += b'\x0a\x0a\x0a\x01' # Destination Address
|
||||||
|
|
||||||
|
tcp_header = b'\x30\x39\x00\x50' # Source Port | Destination Port
|
||||||
|
tcp_header += b'\x00\x00\x00\x00' # Sequence Number
|
||||||
|
tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number
|
||||||
|
tcp_header += b'\x50\x02\x71\x10' # Data Offset, Reserved, Flags | Window Size
|
||||||
|
tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer
|
||||||
|
|
||||||
|
packet = ip_header + tcp_header
|
||||||
|
s.sendto(packet, ('10.10.10.1', 0))
|
23
server/sending_raw_packets.py
Normal file
23
server/sending_raw_packets.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import socket
|
||||||
|
|
||||||
|
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
|
||||||
|
s.bind(("wlp1s0", 8000))
|
||||||
|
|
||||||
|
ethernet = b'\x00\x0c\x29\xd3\xbe\xd6' # MAC Address Destination
|
||||||
|
ethernet += b'\x00\x0c\x29\xe0\xc4\xaf' # MAC Address Source
|
||||||
|
ethernet += b'\x08\x00' # Protocol-Type: IPv4
|
||||||
|
|
||||||
|
ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length
|
||||||
|
ip_header += b'\xab\xcd\x00\x00' # Identification | Flags, Fragment Offset
|
||||||
|
ip_header += b'\x40\x06\xa6\xec' # TTL, Protocol | Header Checksum
|
||||||
|
ip_header += b'\x0a\x0a\x0a\x02' # Source Address
|
||||||
|
ip_header += b'\x0a\x0a\x0a\x01' # Destination Address
|
||||||
|
|
||||||
|
tcp_header = b'\x30\x39\x00\x50' # Source Port | Destination Port
|
||||||
|
tcp_header += b'\x00\x00\x00\x00' # Sequence Number
|
||||||
|
tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number
|
||||||
|
tcp_header += b'\x50\x02\x71\x10' # Data Offset, Reserved, Flags | Window Size
|
||||||
|
tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer
|
||||||
|
|
||||||
|
packet = ethernet + ip_header + tcp_header
|
||||||
|
s.send(packet)
|
Loading…
x
Reference in New Issue
Block a user