Exemplo n.º 1
0
    def handle_session(self, session_path, challenge=None):
        session_params = session_path.split('/')
        session_params = [x for x in session_params if x != '']

        if session_params[0] == "cova_tls_session":
            if session_params[1] == "challenge":
                challenge = json.loads(self.json_data)
                data = self.get_challenge_response(challenge["challenge"])
                json_data = json.dumps(data)
                self.generate_response(self.encrypt(json_data))

            elif session_params[1] == "create":
                new_hand = Handshake(session_db, rsa_key_path, None)
                session_info = new_hand.create_session()
                self.generate_response(json.dumps(session_info))

            else:
                self.generate_response("cova_tls_session error !!")

            return False

        elif session_params[0] == "cova_tls_session_id":
            return self.initiate_session_key(session_params[1])

        else:
            self.generate_response("Session Error !!")
            return False
Exemplo n.º 2
0
 def __perform_handshake__(self, peer, info_hash, peer_id):
     peer.connect()
     if peer.alive:
         handshake = Handshake(info_hash, peer_id)
         peer.send(handshake.serialize())
         handshake_resp = handshake.deserialize(
             peer.receive(Handshake.MSG_LEN))
         if handshake_resp.info_hash != handshake.info_hash:
             raise ConnectionError("info_hash mismatch")
     else:
         raise ConnectionAbortedError("No answer from this client...")
Exemplo n.º 3
0
    def get_challenge_response(self, challenge):
        new_hand = Handshake(session_db, rsa_key_path, None)
        solved_challenge = new_hand.solve_challenge(challenge)
        session_id = new_hand.generate_session_id()

        data = {"challenge": solved_challenge, "session_id": session_id}
        session_db[session_id] = solved_challenge
        self.session_key = solved_challenge

        while len(session_db) > MAX_ALLOWED_SESSION:
            session_db.popitem(last=False)

        if DEBUG:
            print("solved challenge", data)

        return data
Exemplo n.º 4
0
def handshake():
    method = request.args.get("method")

    if method == "hello":
        client_random = request.args.get("client_random")
        if client_random is None:
            abort(400)

        session_id = request.args.get("sessionid")
        if session_id is None:
            session_id = uuid4().hex

        if session_id in OPEN_CONNECTIONS.keys():
            # You would resume normally, but we just redo the handshake
            del OPEN_CONNECTIONS[session_id]

        OPEN_CONNECTIONS[session_id] = Handshake(client_random)
        return jsonify({
            "cert":
            OPEN_CONNECTIONS[session_id].send_request_cert(),
            "sessionid":
            session_id,
            "server_random":
            OPEN_CONNECTIONS[session_id].get_server_random()
        })

    elif method == "key_exchange":
        session_id = request.args.get("sessionid")
        if session_id is None:
            abort(400)

        if session_id not in OPEN_CONNECTIONS.keys():
            abort(400)

        pms = request.args.get("pms")
        if pms is None:
            abort(400)

        status = OPEN_CONNECTIONS[session_id].key_exchange(pms)

        (client_hmac, server_hmac, client_key, server_key
         ), master_secret = OPEN_CONNECTIONS[session_id].get_shared_key()

        del OPEN_CONNECTIONS[session_id]

        OPEN_CONNECTIONS[session_id] = SymmetricEnc(server_hmac, client_hmac,
                                                    server_key, client_key)

        return "Success" if status else "Failure"

    else:
        abort(404)
Exemplo n.º 5
0
from handshake import Handshake

hs = Handshake("api_key")

hs.remove_user("Email", "Account", "First Name", "Last Name")
Exemplo n.º 6
0
def handshake(conn):
    data = conn.recv(1024).decode("ascii")
    handshake = Handshake(data)
    response = handshake.response()
    conn.sendall(response.encode("ascii"))
Exemplo n.º 7
0
from handshake import Handshake

hs = Handshake("api_key")

hs.create_user("Email", "Account", "First Name", "Last Name")
Exemplo n.º 8
0
print('[System] Version: Alpha | 2.0.0')
print('[System] By Ariel University')
print('[Step 1/5] Starting...')
OriginalPcapName = "./MalwareOriginal.pcap"
#OriginalPcapName= input("Please enter path to input pcap")
inputpcap = rdpcap(OriginalPcapName)  #PcapReader
print('[Step 2/5] Loading PCAPS into memory...')
opensession = rdpcap('./pcaps/OpenSessionV2.pcap')
closesession = rdpcap('./pcaps/TerminationV2.pcap')
dohQueryNextDNS = rdpcap('./pcaps/NextDNS/DoHQuery.pcap')
dohQueryQuad9 = rdpcap('./pcaps/Quad9/DoHQuery2.pcap')
dohResponseNextDNS = rdpcap('./pcaps/NextDNS/DoHResponse.pcap')
dohResponseQuad9 = rdpcap('./pcaps/Quad9/DoHResponse.pcap')
#inputpcap    = rdpcap('./pcaps/DNSinput.pcap', count=222)
handshake = Handshake(opensession)
termination = closesession
outputpcap = list()
userDecision = input("Press s for synthatic OR o for original")
doh_proxy = list()
if (userDecision == 's'):
    DoHpcapName = "./MalwareProxy.pcap"
    inputDoHpcap = rdpcap(DoHpcapName)
    doh_proxy = DoHProxy(inputDoHpcap, inputpcap.copy())
    dns_server = doh_proxy.dns_server
    doh_dispatcher = DoHDispatcher(doh_proxy,
                                   handshake, [dohQueryNextDNS, dohQueryQuad9],
                                   [dohResponseNextDNS, dohResponseQuad9],
                                   termination,
                                   userDecision,
                                   doh_server_ip=dns_server)