Create new FSM for SQL injection tutorial

This commit is contained in:
Bálint Bokros 2017-11-27 18:47:33 +01:00
parent 638c1b96ae
commit 4a810b4229
2 changed files with 34 additions and 1 deletions

View File

@ -3,7 +3,8 @@ import logging
from tornado.websocket import WebSocketHandler
from util import parse_anchor_from_message
from buttons import fsm
# from buttons import fsm
from sql_injection_fsm import fsm
import component_connector

View File

@ -0,0 +1,32 @@
from transitions import Machine
import component_connector
class SQLInjectionFSM:
states = ['start', 'stripped_code', 'sql', 'commented_code', 'sql_with_substitutions', 'sql_output', 'end']
transitions = [
{'trigger': 'anchor_webide', 'source': 'start', 'dest': 'stripped_code'},
{'trigger': 'anchor_login', 'source': 'stripped_code', 'dest': 'sql'},
{'trigger': 'anchor_logger', 'source': 'sql', 'dest': 'commented_code'},
{'trigger': 'anchor_webide', 'source': 'commented_code', 'dest': 'sql_with_substitutions'},
{'trigger': 'anchor_logger', 'source': 'sql_with_substitutions', 'dest': 'sql_output'},
{'trigger': 'anchor_logger', 'source': 'sql_output', 'dest': 'end'},
{'trigger': 'reset', 'source': '*', 'dest': 'start'},
]
def __init__(self):
self.machine = Machine(model=self,
states=SQLInjectionFSM.states,
transitions=SQLInjectionFSM.transitions,
initial='start',
send_event=True,
ignore_invalid_triggers=True,
after_state_change='forward_message')
def forward_message(self, event_data):
message = event_data.kwargs.get('message')
component_connector.send_message(message)
fsm = SQLInjectionFSM()