-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.py
executable file
·98 lines (75 loc) · 2.04 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python
# TCP UDP ICMP
# | | |
# Layer3(Mux)
# |
# IP ARP
# | |
# Layer2(Mux)
# |
# Ethernet(Protocol)
# |
# Layer1(Mux)
# |
# EthernetDriver(Adapter)
# =[('MSS', 1460), ('SAckOK', ''), ('Timestamp', (1225447751L, 910591087L)), ('NOP', None), ('WScale', 0)]
protocols = {}
import sys
sys.modules["protocols"] = protocols
import sys
from udp import *
from twisted.internet import reactor
from scapyLink import ScapyLink
import io
from random import *
from tools import *
from conduits import *
from driver import *
from ethernet import *
from arp import *
from ip import *
from udp import *
from icmp import *
from tcp import *
class EchoClientProtocol(TCPClientProtocol):
def startProtocol(self):
print "Protocol starting..."
self.state.connect("kybernet.org", 8000)
class EchoServerProtocol(TCPServerProtocol):
# XXX: What happens when the connection has been established?
pass
def main():
# io.linkInputToProtocol(protocol)
global protocols
# Layer 1 - Data Link Layer
driver = EthernetDriver()
protocols["driver"] = driver
ether = EthernetProtocol()
driver.registerHandler("default", ether)
protocols["ether"] = ether
# Layer 2 - Network Layer
ip = IPProtocol()
ether.registerHandler("IP", ip)
protocols["ip"] = ip
arp = ARPProtocol()
ether.registerHandler("ARP", arp)
protocols["arp"] = arp
ether.registerHandler("default", Scream("Ether"))
# Layer 3 - Transport Layer
udp = UDPProtocol()
ip.registerHandler("UDP", udp)
protocols["udp"] = udp
tcp = TCPProtocol()
ip.registerHandler("TCP", tcp)
protocols["tcp"] = tcp
icmp = ICMPProtocol()
ip.registerHandler("ICMP", icmp)
protocols["icmp"] = icmp
# Layer 4 - Application Layer
ip.registerHandler("default", Scream("IP"))
tcp.registerHandler("default", TCPDefaultHandlerAccept( EchoServerProtocol ) )
echo = EchoClientProtocol()
# echo.startProtocol()
reactor.run()
if __name__ == '__main__':
main()