relab/server/README.md

59 lines
1.8 KiB
Markdown

# Quick Start
## Starting the server
On the server, run the following
```bash
$ python3 -m venv .example
$ activate .example/bin/activate
$ python3 NetGenieSrv.py
```
This opens three sockets:
1. The bridge socket that listens for the phone to connect to.
2. An ``incoming'' socket to read packets sent from the device to the server
3. An ``outgoing'' socket to write packets from the server to the device.
On the phone, connect to the server and port specified by the `-B` and `-b` arguments.
This can be specified by changing the source code or using the following command-line
arguments:
```bash
$ python3 NetGenieSrv.py -h
usage: NetGenieSrv.py [-h] [-B BRIDGE_IP] [-b BRIDGE_PORT] [-I IOIP] [-i INCOMING_PORT] [-o OUTGOING_PORT]
options:
-h, --help show this help message and exit
-B BRIDGE_IP, --bridge_ip BRIDGE_IP
The IP that listens for NetGenie mobile app client connections.
-b BRIDGE_PORT, --bridge_port BRIDGE_PORT
The port that listens for NetGenie mobile app client connections.
-I IOIP, --ioip IOIP The IP that listens on the server for connections from whoever is debugging the phone.
-i INCOMING_PORT, --incoming_port INCOMING_PORT
The port that the person debugging will read packets from the device.
-o OUTGOING_PORT, --outgoing_port OUTGOING_PORT
The port that the person debugging will write packets to the device.
```
## Using the server
```bash
$ ipython3
import NetGenieSrv as ngs
from scapy.all import *
ip = IP(src='10.10.20.1', dst='255.255.4.20')
tcp = TCP(sport=8080, dport=8443)
pkt = ip/tcp
a = pkt.build()
insock, outsock = ngs.connectIO()
pktIn = insock.read(40) # Read a packet send from the phone
outsock.send(a) # Send a packet to the NetGenie client.
```