Create PoC of solvable with hardcoded responses

This commit is contained in:
Bálint Bokros 2018-02-09 14:08:14 +01:00
parent eed3006055
commit 28e83de0d7
2 changed files with 17 additions and 1 deletions

View File

@ -15,4 +15,4 @@ class ControllerConnector(ZMQConnectorBase):
self._zmq_rep_socket.connect('tcp://localhost:{}'.format(CONTROLLER_PORT))
self._zmq_rep_stream = ZMQStream(self._zmq_rep_socket)
self.register_callback = self._zmq_rep_stream.on_recv
self.register_callback = self._zmq_rep_stream.on_recv_stream

View File

@ -7,12 +7,28 @@ from tornado.ioloop import IOLoop
from sql_injection_fsm import SQLInjectionFSM
from tfw.config import tfwenv
from tfw.config.logs import logging
from tfw.networking.controller_connector import ControllerConnector
from tfw.networking.serialization import deserialize_all, serialize_all
log = logging.getLogger(__name__)
from tfw.networking.server.zmq_websocket_handler import FSMManagingSocketHandler
def zmq_callback(stream, msg_parts):
key, data = deserialize_all(*msg_parts)
if key == 'test':
stream.send_multipart(serialize_all(key, 'OK'))
if key == 'solution_check':
stream.send_multipart(serialize_all(key, {
'solved': True,
'message': 'solved'
}))
if __name__ == '__main__':
fsm = SQLInjectionFSM()
controller_connector = ControllerConnector()
controller_connector.register_callback(zmq_callback)
routes = [
(r'/ws', FSMManagingSocketHandler, {'fsm': fsm}),
]