コード例 #1
0
ファイル: client.py プロジェクト: saggarwal96/netsec_fall2017
def basicUnitTest():
    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)

    loop = asyncio.get_event_loop()
    coro = playground.getConnector('passthrough').create_playground_connection(
        lambda: StudentClient(), '20174.1.1.1', 8000)

    transport, protocol = loop.run_until_complete(coro)
    protocol.request(stdInCallback)
    loop.close()
コード例 #2
0
def server_run(): 

		f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
		ptConnector = playground.Connector(protocolStack=f)
		playground.setConnector("passthrough", ptConnector)	

		loop = asyncio.get_event_loop()
		coro = playground.getConnector('passthrough').create_playground_server(lambda: ServerProtocol(), 101)
		server = loop.run_until_complete(coro)
		print("Echo Server Started at {}".format(server.sockets[0].gethostname()))
		loop.run_forever()
		loop.close()
コード例 #3
0
def lab_1e_test():
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    f = StackingProtocolFactory(lambda: higherProtocol1(), lambda: higherProtocol2())

    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)
    coro = playground.getConnector('passthrough').create_playground_server(lambda:MyServerProtocol(), 46427)
    server = loop.run_until_complete(coro)
    print('Serving on {}'.format(server.sockets[0].gethostname()))
    loop.run_forever()
    server.close()
    loop.close()
コード例 #4
0
def basicUnitTest():
    echoArgs = {}

    args = sys.argv[1:]
    i = 0
    for arg in args:
        if arg.startswith("-"):
            k, v = arg.split("=")
            echoArgs[k] = v
        else:
            echoArgs[i] = arg
            i += 1

    if not 0 in echoArgs:
        sys.exit("1")

    fclient = StackingProtocolFactory(lambda: PassThroughc1(),
                                      lambda: PassThroughc2())
    ptConnectorclient = playground.Connector(protocolStack=fclient)
    playground.setConnector("passthroughclient", ptConnectorclient)

    fserver = StackingProtocolFactory(lambda: PassThroughs1(),
                                      lambda: PassThroughs2())
    ptConnectorserver = playground.Connector(protocolStack=fserver)
    playground.setConnector("passthroughserver", ptConnectorserver)

    mode = echoArgs[0]
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)

    if mode.lower() == "server":
        coro = playground.getConnector(
            'passthroughserver').create_playground_server(
                lambda: MyProtocolServer(), 101)
        server = loop.run_until_complete(coro)
        print("my Server Started at {}".format(
            server.sockets[0].gethostname()))
        loop.run_forever()
        loop.close()

    else:
        address = mode
        coro = playground.getConnector(
            'passthroughclient').create_playground_connection(
                lambda: MyProtocolClient("hello", loop), address, 101)
        loop.run_until_complete(coro)
        loop.run_forever()
        loop.close()
コード例 #5
0
def lab_1e_test():
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    f = StackingProtocolFactory(lambda: higherProtocol1(),
                                lambda: higherProtocol2())

    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)
    #message = 'Hello World!'
    myconnect = playground.getConnector(
        'passthrough').create_playground_connection(lambda: MyClientProtocol(),
                                                    '20174.1.1.1', 46427)
    transport, client = loop.run_until_complete(myconnect)
    pktCR = ConnectionRequest()
    client.send(pktCR)
    loop.run_forever()
    loop.close()
コード例 #6
0
def protocolController():
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    client = Protocol.ForgotPasswordClientProtocol()
    server = Protocol.ForgotPasswordServerProtocol()
    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)
    serv = playground.getConnector('passthrough').create_playground_server(
        lambda: server, 8080)
    s = loop.run_until_complete(serv)
    print("Echo server running at {}".format(s.sockets[0].gethostname()))
    cli = playground.getConnector('passthrough').create_playground_connection(
        lambda: client, "20174.1.1.1", 8080)
    transport, protocol = loop.run_until_complete(cli)
    print("Echo client running with t:{}. p:{}".format(transport, protocol))
    loop.run_forever()
    loop.close()
コード例 #7
0
ファイル: lab2a.py プロジェクト: Flyy-yu/JHUnetSec
def basicUnitTest():
    echoArgs = {}

    args = sys.argv[1:]
    i = 0
    for arg in args:
        if arg.startswith("-"):
            k, v = arg.split("=")
            echoArgs[k] = v
        else:
            echoArgs[i] = arg
            i += 1

    if 0 not in echoArgs:
        sys.exit("1")

    fclient = StackingProtocolFactory(lambda: PassThroughc1(), lambda: PassThroughc2())
    fserver = StackingProtocolFactory(lambda: PassThroughs1(), lambda: PassThroughs2())

    lab2Connector = playground.Connector(protocolStack=(
        fclient,
        fserver))
    playground.setConnector("lab2_protocol", lab2Connector)

    mode = echoArgs[0]
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)

    if mode.lower() == "server":
        coro = playground.getConnector('lab2_protocol').create_playground_server(lambda: MyProtocolServer(), 101)
        server = loop.run_until_complete(coro)
        print("my Server Started at {}".format(server.sockets[0].gethostname()))
        loop.run_forever()
        loop.close()


    else:
        address = mode
        coro = playground.getConnector('lab2_protocol').create_playground_connection(
            lambda: MyProtocolClient("hello", loop),
            address, 101)
        loop.run_until_complete(coro)
        loop.run_forever()
        loop.close()
コード例 #8
0
def basicUnitTest():

    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)

    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    coro = playground.getConnector('passthrough').create_playground_server(
        lambda: QuizServer(), 8000)
    server = loop.run_until_complete(coro)

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    server.close()
    loop.run_until_complete(server.wait_closed())
    loop.close()
コード例 #9
0
def client_run():

    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)
    control = ClientProtocol()
    loop = asyncio.get_event_loop()
    coro = playground.getConnector().create_playground_connection(
        control.buildProtocol, '20174.1.1.1', 101)
    transport, protocol = loop.run_until_complete(coro)

    print("Client Connected. Starting UI t:{}. p:{}".format(
        transport, protocol))

    #control.connection_made(transport)
    control.setTransport(transport)
    pkt1 = DB_connect()
    control.sendpacket(pkt1)

    loop.run_forever()
    loop.close()
コード例 #10
0
ファイル: client.py プロジェクト: MQIN07/netsec_fall2017
                OneAnswer = packetClass.Answer()
                OneAnswer.answer = "oliy"
                OneAnswer.ID = 1
                self.method(OneAnswer)
            elif isinstance(pkt, packetClass.Result):
                #self.clientstatus = 2
                print("Result packet received")
            else:
                print("finish")

    #method to get skintype
    def method(self,packet):
        self.transport.write(packet.__serialize__())

    def connection_lost(self, exc):
        print("connection lost")

if __name__ == "__main__":
    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector("passthrough", ptConnector)
    loop = asyncio.get_event_loop()
    loop.set_debug(enabled=True)
    logging.getLogger().setLevel(logging.NOTSET)  # this logs *everything*
    logging.getLogger().addHandler(logging.StreamHandler())  # logs to stderr
    coro = playground.getConnector('passthrough').create_playground_connection(lambda:EchoClientProtocol(), '20174.1.1.1', 8888)
    server = loop.run_until_complete(coro)
    loop.run_forever()
    loop.close()

コード例 #11
0
ファイル: __init__.py プロジェクト: TsGanT/Live
import playground
from .protocol import PassthroughClientFactory, PassthroughServerFactory

passthroughConnector = playground.Connector(
    protocolStack=(PassthroughClientFactory(), PassthroughServerFactory()))
playground.setConnector("passthrough", passthroughConnector)
playground.setConnector("mystack", passthroughConnector)
コード例 #12
0
'''
Created on 2017年9月27日

@author: wangweizhou
'''
from playground.network.packet.fieldtypes import UINT32, STRING, BUFFER,BOOL
from playground.network.packet import PacketType
from playground.network.common import StackingProtocol
from playground.network.common import StackingProtocolFactory
from playground.network.common import StackingTransport
import playground
from .HandShakePacket import *
from .ClientPassThrough import *
from .ClientAppProtocol import *
from asyncio import *
from .TranCliProto import TranCliProto

if __name__=='__main__':
    loop = get_event_loop()
    f = StackingProtocolFactory(lambda: ClientPassThrough(), lambda: TranCliProto())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector('ClientStack', ptConnector)
    connect = playground.getConnector('ClientStack').create_playground_connection (lambda:ClientAppProtocol(), '20174.1.1.1', 8998)
    mytransport, myclientprotocol = loop.run_until_complete(connect)
    #myclientprotocol.connection_made(mytransport)
    #myclientprotocol.SentRequest();
    loop.run_forever()
    loop.close()
コード例 #13
0
'''
Created on 2017年9月27日

@author: wangweizhou
'''
from playground.network.packet.fieldtypes import UINT32, STRING, BUFFER,BOOL
from playground.network.packet import PacketType
from playground.network.common import StackingProtocol
from playground.network.common import StackingProtocolFactory
from playground.network.common import StackingTransport
import playground
import .HandShakePacket
from .TranSerProto import *
from .ServerPassThrough import *
from .ServerAppProtocol import *
from asyncio import *


if __name__=='__main__':
    loop = get_event_loop()
    f = StackingProtocolFactory(lambda: ServerPassThrough(), lambda: TranSerProto())
    ptConnector = playground.Connector(protocolStack=f)
    playground.setConnector('ServerStack', ptConnector)
    coro = playground.getConnector('ServerStack').create_playground_server(lambda:ServerAppProtocol(),8998)
    myserver= loop.run_until_complete(coro)
    loop.run_forever()
    myserver.close()
    loop.close()
コード例 #14
0
ファイル: __init__.py プロジェクト: minging234/netsec_ming
import playground
from netsec_fall2017.lab_3.factory.ProtocolFactory import get_lab3_client_factory, get_lab3_server_factory

cf = get_lab3_client_factory()
sf = get_lab3_server_factory()
lab3_connector = playground.Connector(protocolStack=(cf, sf))
playground.setConnector('lab3_protocol', lab3_connector)
コード例 #15
0
import playground
from .PLS_Passthrough import clientFactory, serverFactory

lab3Connector = playground.Connector(protocolStack = (clientFactory, serverFactory))
playground.setConnector("pls3", lab3Connector)
コード例 #16
0
		highertransport = StackingTransport(self.transport)
		self.higherProtocol().connection_made(highertransport)

	def data_received(self,data):
		self.higherProtocol().data_received(data)
	
	def connection_lost(self,exc):
		pass
		# self.highertrasnport = None



name = sys.argv[1]
loop = asyncio.get_event_loop()
loop.set_debug(enabled = True)
f = StackingProtocolFactory(lambda:passThrough1(),lambda:passThrough2())
ptConnector = playground.Connector(protocolStack=f)
playground.setConnector("passthrough",ptConnector)

if name == "server":
	coro = playground.getConnector('passthrough').create_playground_server(lambda: ServerProtocol(), 8888)
	server = loop.run_until_complete(coro)
	print("Echo Server Started at {}".format(server.sockets[0].gethostname()))
	loop.run_forever()
	loop.close()
else:
	coro = playground.getConnector('passthrough').create_playground_connection(lambda: ClientProtocol(packet2, loop),"20174.1.1.1",8888)
	transport, protocol = loop.run_until_complete(coro)
	print("Echo Client Connected. Starting UI t:{}. p:{}".format(transport, protocol))
	loop.run_forever()
	loop.close()
コード例 #17
0
import playground
from .passthrough import pt_client, pt_server

passthrough_connector = playground.Connector(protocolStack=(pt_client,
                                                            pt_server))

playground.setConnector('passthrough', passthrough_connector)
コード例 #18
0
import playground
from .protocol import CRAPClientFactory, CRAPServerFactory

CRAPConnector = playground.Connector(protocolStack=(CRAPClientFactory(),
                                                    CRAPServerFactory()))
playground.setConnector("lzy_crap", CRAPConnector)
コード例 #19
0
from .peep import PEEPClient, PEEPServer
import playground
from playground.network.common import StackingProtocol, StackingTransport, StackingProtocolFactory

class PassThrough1(StackingProtocol):
    def connection_made(self, transport):
        print(" - PassThrough1 connection_made")
        self.transport = transport
        higherTransport = StackingTransport(transport)
        self.higherProtocol().connection_made(higherTransport)
    
    def data_received(self, data):
        print(" - PassThrough1 data_received")
        self.higherProtocol().data_received(data)
    
    def connection_lost(self, exc):
        print(" - PassThrough1 connection_lost")
        self.transport = None
        self.higherProtocol().connection_lost(exc)

lab2ClientFactory = StackingProtocolFactory(PassThrough1, PEEPClient)
lab2ServerFactory = StackingProtocolFactory(PassThrough1, PEEPServer)

lab2Connector = playground.Connector(protocolStack=(lab2ClientFactory, lab2ServerFactory))
playground.setConnector("Guoye_protocol", lab2Connector)
#playground.setConnector("team7_alt_peep_protocol", lab2Connector)
コード例 #20
0
from .passProtocol import RIPclient, RIPserver
from .SLT import SithClientProtocol, SithServerProtocol
from playground.network.common import StackingProtocol, StackingTransport, StackingProtocolFactory
import playground

secure_client = StackingProtocolFactory(lambda: RIPclient(),
                                        lambda: SithClientProtocol())
secure_server = StackingProtocolFactory(lambda: RIPserver(),
                                        lambda: SithServerProtocol())

#RIPClientLab = StackingProtocolFactory(lambda: RIPclient())
#RIPServerLab = StackingProtocolFactory(lambda: RIPserver())
#secureRippConnector = playground.Connector(protocolStack=(RIPClientLab, RIPServerLab))
secureRippConnector = playground.Connector(protocolStack=(secure_client,
                                                          secure_server))
playground.setConnector("SLT", secureRippConnector)
コード例 #21
0
import playground
from .protocol import SecureClientFactory, SecureServerFactory

secureConnector = playground.Connector(protocolStack=(SecureClientFactory(),
                                                      SecureServerFactory()))
playground.setConnector("crap_shan", secureConnector)
playground.setConnector("crap_shan", secureConnector)
コード例 #22
0
import playground
from .pimp import PIMPServerFactory, PIMPClientFactory

pimpConnector = playground.Connector(protocolStack=(PIMPClientFactory(),
                                                    PIMPServerFactory()))
playground.setConnector("pimp", pimpConnector)
playground.setConnector("lab1_GoldenNuggetNetSec2019", pimpConnector)
コード例 #23
0
ファイル: __init__.py プロジェクト: Flyy-yu/JHUnetSec
import playground
from .lab3a import *

myPeepConnector = playground.Connector(protocolStack=(
    PeepClientFactory(),
    PeepServerFactory()))

playground.setConnector("lab3_protocol", myPeepConnector)
playground.setConnector("pls", myPeepConnector)
コード例 #24
0
import playground
from playground.network.common import StackingProtocolFactory, StackingProtocol, StackingTransport
from .protocol import PoopClient, PoopServer

PoopClientFactory = StackingProtocolFactory.CreateFactoryType(PoopClient)
PoopServerFactory = StackingProtocolFactory.CreateFactoryType(PoopServer)

connector = playground.Connector(protocolStack=(PoopClientFactory(),
                                                PoopServerFactory()))

playground.setConnector('poop', connector)
コード例 #25
0
def test():
    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)

    playground.setConnector("PT1", ptConnector)
コード例 #26
0
import playground
from .Protocols.ServerProtocol import ServerProtocol
from .Protocols.ClientProtocol import ClientProtocol
from .Protocols.ServerPLSProtocol import ServerPLSProtocol
from .Protocols.ClientPLSProtocol import ClientPLSProtocol
from playground.network.common import StackingProtocolFactory

clientStack = StackingProtocolFactory(ClientProtocol, ClientPLSProtocol)
serverStack = StackingProtocolFactory(ServerProtocol, ServerPLSProtocol)
myPlsConnector = playground.Connector(protocolStack=(clientStack, serverStack))
clientPlsConnector = playground.Connector(protocolStack=clientStack)
serverPlsConnector = playground.Connector(protocolStack=serverStack)
myPeepConnector = playground.Connector(protocolStack=(ClientProtocol,
                                                      ServerProtocol))
clientPeepConnector = playground.Connector(
    protocolStack=StackingProtocolFactory(ClientProtocol))
serverPeepConnector = playground.Connector(
    protocolStack=StackingProtocolFactory(ServerProtocol))

playground.setConnector("lab3_protocol", myPlsConnector)
playground.setConnector("my_team_lab3_protocol", myPlsConnector)
playground.setConnector("lab3_client_protocol", clientPlsConnector)
playground.setConnector("lab3_server_protocol", serverPlsConnector)
playground.setConnector("lab2_protocol", myPeepConnector)
playground.setConnector("lab2_client_protocol", clientPeepConnector)
playground.setConnector("ilab2_protocol", clientPeepConnector)
playground.setConnector("lab2_server_protocol", serverPeepConnector)
コード例 #27
0
def test():
    ptConnector = playground.Connector(
        protocolStack=(PEEPProtocolFactory.get_client_factory(),
                       PEEPProtocolFactory.get_server_factory()))

    playground.setConnector("PT1", ptConnector)
コード例 #28
0
ファイル: __init__.py プロジェクト: linkinlzm/lab3_protocol
import playground
from .lab3a import *

myPeepConnector = playground.Connector(protocolStack=(PeepClientFactory(),
                                                      PeepServerFactory()))

playground.setConnector("lab3_protocol", myPeepConnector)
playground.setConnector("my_team_lab3_protocol", myPeepConnector)
コード例 #29
0
ファイル: __init__.py プロジェクト: alanlinzy/lzy_lab3
import playground
from protocol import CRAPClientFactory, CRAPServerFactory

CRAPConnector = playground.Connector(protocolStack=(CRAPClientFactory(),
                                                    CRAPServerFactory()))
playground.setConnector("lzy_lab3", CRAPConnector)
コード例 #30
0
ファイル: __init__.py プロジェクト: cnoellekb/netsec_fall2017
import playground
from .Server import Serverfactory
from .Client import Clientfactory

lab2Connector = playground.Connector(protocolStack=(Clientfactory,
                                                    Serverfactory))
playground.setConnector("lab2_protocol", lab2Connector)
コード例 #31
0
from ..lab3_protocol.lab2_protocol.src.lab2_protocol.PEEPClientProtocol import PEEPClientProtocol
from ..lab3_protocol.lab2_protocol.src.lab2_protocol.PEEPServerProtocol import PEEPServerProtocol

from ..lab3_protocol.src.lab3_protocol.PLSClientProtocol import PLSClientProtocol
from ..lab3_protocol.src.lab3_protocol.PLSServerProtocol import PLSServerProtocol

from . import VerificationCodeClientProtocol
from . import VerificationCodeServerProtocol

from playground.network.common import StackingProtocolFactory
import playground

# you can turn off the logging of PEEP layer here for a clean logging
# cf = StackingProtocolFactory(lambda: PLSClientProtocol(), lambda: PEEPClientProtocol(logging = False))
# sf = StackingProtocolFactory(lambda: PLSServerProtocol(), lambda: PEEPServerProtocol(logging = False))
'''
cf = StackingProtocolFactory(lambda: PLSClientProtocol(), lambda: PEEPClientProtocol())
sf = StackingProtocolFactory(lambda: PLSServerProtocol(), lambda: PEEPServerProtocol())

lab3_connector = playground.Connector(protocolStack=(cf, sf))
playground.setConnector('lab3_protocol', lab3_connector)
'''
コード例 #32
0
ファイル: __init__.py プロジェクト: ChengHsu/NetworkSecurity
from .RIPPClientProtocol import ClientProtocol
from .RIPPServerProtocol import ServerProtocol
from playground.network.common import StackingProtocol, StackingProtocolFactory, StackingTransport
import playground

f_client = StackingProtocolFactory(lambda: ClientProtocol())
f_server = StackingProtocolFactory(lambda: ServerProtocol())
ptConnector = playground.Connector(protocolStack=(f_client, f_server))
playground.setConnector("lab1protocol", ptConnector)
#playground.setConnector("lab1protocol_cxu", ptConnector)
#playground.setConnector("lab1protocol_ty",ptConnector)
コード例 #33
0
import playground, sys, os
from playground.network.common import StackingProtocolFactory, StackingProtocol, StackingTransport
# sys.path.insert(1,'../crap/')
# from .protocol import CrapClient, CrapServer
from .protocol import CrapClient, CrapServer

sys.path.insert(1, '../crap/')
# print("director",os.getcwd())
from ..poop.protocol import PoopClient, PoopServer

CrapClientFactory = StackingProtocolFactory.CreateFactoryType(
    PoopClient, CrapClient)
CrapServerFactory = StackingProtocolFactory.CreateFactoryType(
    PoopServer, CrapServer)

# CrapClientFactory = StackingProtocolFactory.CreateFactoryType(PoopClient)
# CrapServerFactory = StackingProtocolFactory.CreateFactoryType(PoopServer)
# CrapClientFactory = StackingProtocolFactory.CreateFactoryType(CrapClient)
# CrapServerFactory = StackingProtocolFactory.CreateFactoryType(CrapServer)

CrapConnector = playground.Connector(protocolStack=(CrapClientFactory(),
                                                    CrapServerFactory()))

# connector = playground.Connector(
#     protocolStack=(CrapClientFactory(), CrapServerFactory())
# )

playground.setConnector('crap', CrapConnector)