예제 #1
0
def accept_connection(conn):
    try:
        sconn = StealthConn(conn, server=True)
        # The sender is either going to chat to us or send a file
        cmd, flag = sconn.recv()
        if cmd == b'ECHO':
            echo_server(sconn)
        elif cmd == b'FILE':
            p2p_download_file(sconn)
    except socket.error:
        print("Connection closed unexpectedly")
예제 #2
0
def accept_connection(conn):
    try:
        sconn = StealthConn(conn, server=True)
        # The sender is either going to chat to us or send a file
        cmd = sconn.recv()
        if cmd == b'ECHO':
            echo_server(sconn)
        elif cmd == b'FILE':
            p2p_download_file(sconn)
    except socket.error:
        print("Connection closed unexpectedly")
예제 #3
0
def accept_connection(conn):
    try:
        sconn = StealthConn(conn, server=True)
        cmd = sconn.recv()
        if cmd == b'ECHO':  #Echo
            echo_server(sconn)
        elif cmd == b'FILE':  #File download
            p2p_download_file(sconn)
    except socket.error:
        print(Fore.CYAN + "[-] Connection closed unexpectedly\n" +
              Style.RESET_ALL)  #Something went wrong
예제 #4
0
def accept_connection(conn):
    try:
        sconn = StealthConn(conn, server=True)
        # The sender is either going to chat to us or send a file
        cmd = sconn.recv()
        if cmd == b'ECHO':
            echo_server(sconn)
        elif cmd == b'FILE':
            p2p_download_file(sconn)
        else:
            raise RuntimeError("Invalid command: {}".format(cmd))
    except socket.error:
        print("Connection closed unexpectedly")
예제 #5
0
def accept_connection(conn):
    try:
        sconn = StealthConn(conn, rsa_key, server=True)
        # The sender is either going to chat to us or send a file
        cmd = sconn.recv()
        if cmd == b'ECHO':
            echo_server(sconn)
        elif cmd == b'FILE':
            p2p_download_file(sconn)
    except socket.error:
        print("Connection closed unexpectedly")
    except RuntimeError:
        traceback.print_exc()
        print("Authentication Failed")
예제 #6
0
def accept_connection(conn):
    try:
        f = open("serverPublic.pem", 'r')
        rsaKey = RSA.importKey(f.read())
        f.close()
        sconn = StealthConn(conn, rsaKey, server=True)
        # The sender is either going to chat to us or send a file
        cmd = sconn.recv()
        if cmd == b'ECHO':
            echo_server(sconn)
        elif cmd == b'FILE':
            p2p_download_file(sconn)
    except socket.error:
        print("Connection closed unexpectedly")
    except RuntimeError:
        traceback.print_exc()
        print("Authentication Failed")