-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHostBehaviour.py
More file actions
67 lines (43 loc) · 1.15 KB
/
Copy pathHostBehaviour.py
File metadata and controls
67 lines (43 loc) · 1.15 KB
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
#! /usr/bin/env python
from scapy.all import send,sr1,IP,ICMP,UDP,Ether
from random import randint
import time
import socket
from thread import start_new_thread
import SocketServer
class HostBehvaiour(object):
modules = {}
# this is a class users will create to be there modules
class HostModule(object):
def __init__(self, IPAddr, port):
self.IPAddr = IPAddr;
self.port = port;
def sendRaw(packet):
send(packet)
def sendAndReceiveRaw(packet):
return sr1(packet)
def receiveApplicationFull(self, bytes, timeout):
if (timeout != False):
self.sock.settimeout(timeout)
data, addr = sock.recvfrom(bytes)
return (data, addr)
# This gets called by client host
def clientExecute(self):
while True:
self.clientBehaviour()
print "AYY"
return
# This get called by serve rhost
def serverExecute(self):
HOST, PORT = self.IPAddr, self.port
print PORT
server = self.Server((HOST, PORT), self.RequestHandler)
# Should put a shutdown timer in here at some point
while True:
server.handle_request()
# This gets overwritten
def serverBehvaiour():
return
# This gets overwritten
def clientBehaviour(conn):
return