Exemple #1
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()
Exemple #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()
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()
Exemple #4
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()
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()
Exemple #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()
Exemple #7
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()
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()
Exemple #9
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)
Exemple #10
0
import playground
from .pimp import PIMPServerFactory, PIMPClientFactory

pimpConnector = playground.Connector(protocolStack=(PIMPClientFactory(),
                                                    PIMPServerFactory()))
playground.setConnector("pimp", pimpConnector)
playground.setConnector("lab1_GoldenNuggetNetSec2019", pimpConnector)
Exemple #11
0
import playground
from .protocol import PassthroughClientFactory, PassthroughServerFactory

passthroughConnector = playground.Connector(
    protocolStack=(PassthroughClientFactory(), PassthroughServerFactory()))
playground.setConnector("passthrough", passthroughConnector)
playground.setConnector("mystack", passthroughConnector)
Exemple #12
0
"""__init__"""

import playground
from playground.network.common import StackingProtocolFactory
from . import PLSProtocols
lab3ClientFactory = StackingProtocolFactory(
    lambda: PLSProtocols.PLSClientProtocol())
lab3ServerFactory = StackingProtocolFactory(
    lambda: PLSProtocols.PLSServerProtocol())
lab3Connector = playground.Connector(protocolStack=(lab3ClientFactory,
                                                    lab3ServerFactory))
playground.setConnector("lab3_protocol", lab3Connector)
from .ClientProtocol import ClientProtocol
from .ServerProtocol import ServerProtocol
import playground

myPeepConnector = playground.Connector(protocolStack=(ClientProtocol,
                                                      ServerProtocol))
playground.setConnector("lab2_protocol", myPeepConnector)
playground.setConnector("my_team_lab2_protocol", myPeepConnector)
Exemple #14
0
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)
Exemple #15
0
import playground
from .protocol import SecureClientFactory, SecureServerFactory

secureConnector = playground.Connector(protocolStack=(SecureClientFactory(),
                                                      SecureServerFactory()))
playground.setConnector("crap_shan", secureConnector)
playground.setConnector("crap_shan", secureConnector)
Exemple #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()
Exemple #17
0
import playground
from .protocol import CRAPClientFactory, CRAPServerFactory

CRAPConnector = playground.Connector(protocolStack=(CRAPClientFactory(),
                                                    CRAPServerFactory()))
playground.setConnector("lzy_crap", CRAPConnector)
Exemple #18
0
import playground
from .passthrough import pt_client, pt_server

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

playground.setConnector('passthrough', passthrough_connector)
Exemple #19
0
from .Protocols.RIPPClientProtocol import ClientProtocol
from .Protocols.RIPPServerProtocol import ServerProtocol
from playground.network.common import StackingProtocolFactory
from .Protocols.ServerSITHProtocol import ServerSITHProtocol
from .Protocols.ClientSITHProtocol import ClientSITHProtocol

import playground

f_client = StackingProtocolFactory(ClientProtocol, ClientSITHProtocol)
f_server = StackingProtocolFactory(ServerProtocol, ServerSITHProtocol)

ptConnector = playground.Connector(protocolStack=(f_client, f_server))
mySithConnector = playground.Connector(protocolStack=(f_client, f_server))
clientSithConnector = playground.Connector(protocolStack=f_client)
serverSithConnector = playground.Connector(protocolStack=f_server)

playground.setConnector("lab2protocol", mySithConnector)
Exemple #20
0
import playground
from .PLS_Passthrough import clientFactory, serverFactory

lab3Connector = playground.Connector(protocolStack = (clientFactory, serverFactory))
playground.setConnector("pls3", lab3Connector)
Exemple #21
0
def test():
    ptConnector = playground.Connector(
        protocolStack=(PEEPProtocolFactory.get_client_factory(),
                       PEEPProtocolFactory.get_server_factory()))

    playground.setConnector("PT1", ptConnector)
Exemple #22
0
        await self._callback()

    def cancel(self):
        self._task.cancel()


if __name__ == "__main__":

    loop = asyncio.get_event_loop()
    # Each client connection will create a new protocol instance

    logging.getLogger().setLevel(logging.NOTSET)  # this logs *everything*
    logging.getLogger().addHandler(logging.StreamHandler())  # logs to stderr

    Serverfactory = StackingProtocolFactory(lambda: PEEPServerProtocol(loop))
    ptConnector = playground.Connector(protocolStack=Serverfactory)

    playground.setConnector("passthrough", ptConnector)

    coro = playground.getConnector('passthrough').create_playground_server(
        lambda: ShopServerProtocol(loop), 8888)
    server = loop.run_until_complete(coro)

    # Serve requests until Ctrl+C is pressed
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    # Close the server
    server.close()
import playground
from playground.network.common import StackingProtocolFactory

from .server import Serverfactory
from .client import Clientfactory

from .pls_client import PLSClientProtocol
from .pls_server import PLSServerProtocol

ClientFactory = StackingProtocolFactory(lambda: client.PEEPClientProtocol(),
                                        lambda: pls_client.PLSClientProtocol())
ServerFactory = StackingProtocolFactory(lambda: server.PEEPServerProtocol(),
                                        lambda: pls_server.PLSServerProtocol())

lab3_connector = playground.Connector(protocolStack=(ClientFactory,
                                                     ServerFactory))
playground.setConnector("lab3_protocol1", lab3_connector)
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)
Exemple #25
0
import playground
from .lab3a import *

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

playground.setConnector("lab3_protocol", myPeepConnector)
playground.setConnector("my_team_lab3_protocol", myPeepConnector)
Exemple #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)
Exemple #27
0
import playground
from .Server import Serverfactory
from .Client import Clientfactory

lab2Connector = playground.Connector(protocolStack=(Clientfactory,
                                                    Serverfactory))
playground.setConnector("lab2_protocol", lab2Connector)
Exemple #28
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)
Exemple #29
0
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)
def test():
    f = StackingProtocolFactory(lambda: PassThrough1(), lambda: PassThrough2())
    ptConnector = playground.Connector(protocolStack=f)

    playground.setConnector("PT1", ptConnector)