Python Reverse Shell Tutorial - 3 - Sending Commands to the Client

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Its giving me this error :(
socket binding error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
Retrying...

shrikantsawarkar
Автор

The issue with the cd command was actually easier to fix than I thought. Using os.system() will just make the system call without returning the output. So the cd command will default the user's home directory and cd - will return the previous working directory as intended.
if data[:2].decode("utf-8") == 'cd':
cdr=data[:].decode("utf-8")
cd=cdr.strip()
os.system(cd)

infosecemporium
Автор

Hey bucky great tutorial, may I have the sample source code for this?

kennethdean
Автор

#thenewboston Getting this error: TypeError: descriptor 'encode' requires a 'str' object but received a 'builtin_function_or_method'
Any ideas??

lucaslambert
Автор

Hi. I have issue with clint_response=str(conn.recv(1024), 'utf-8'). The program runs till this line, if I print out hallo before this line it works but after that line does not. What can be wrong here?

elikelik
Автор

thanks Bucky
I didn't get something tho
conn.close() is written twice in send_commands(conn) and socket_accept(), ,, it's useless in socket_accept(), right ?!

osamansr
Автор

i got this error ... line 14, in socket_cteate
except socket.error as msg:
AttributeError: type object 'socket' has no attribute 'error'

mohamedezat
Автор

It does not work: line 25, in socket_bind
s.bind((host, port))
NameError: name 'host' is not defined

hoangtruong
Автор

error line 25  s.bind((host, port)) unindent does not mach any outer indentation level

ponturix
Автор

Why can't we use struct.pack in place of str.encode()

ashishsharma-gwbg
Автор

man if this works it will be really cool

cuprum
Автор

Error on line 14
except socket.error as msg

davidonijagbe
Автор

i dont understand why i get this error :

print(client_response, end="")

SyntaxError: invalid syntax

if i remove end=" "

it works fine ?

martinled
Автор

Getting a syntax error on the _print(client_response, end="")_ line. Are you using python 3 or something?

ParticleJesus
Автор

what command should I use in linux instead of dir

katrix
Автор

Is this code on the Github? I didn't see it anywhere

black_squall
Автор

import socket
import sys

# Creanto sockets
def socket_create():
try:
global host
global port
global s
host = ''
port = 9999
s = socket.socket()
except socket.error as msj:
print('Error de creación de socket: ' + str(msj))
# bind el socket al puerto y esperar conexión del cliente
def socket_bind():
try:
global host
global port
global s
print('Bindding socket al puerto: ' + str(port))
s.bind((host, port))
s.listen(5)
except socket.error as msj:
print('error de binding en el socket: ' + str(msg) + '/n' + 'reintentando...')

# Establecer conexion con el cliente (el socket debe estar escuchando)

def socket_accept():
conn, address = s.accept()
print('conexion establecida | ' + 'IP' + address[0] + '| puerto' + str(address[1]))
send_commands(conn)
conn.close()

# Envair comandos al objetivo
def send_commands(conn):
while True:
cmd = input()
if cmd == 'quit':
conn.close()
s.close()
sys.exit()
if len(str.encode(cmd)) > 0:

cliente_response = str(conn.recv(1024), 'utf-8')
print(cliente_response, end='')

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

main()

urieeel