Created
June 11, 2021 11:27
-
-
Save Inndy/b443c4812284608a7529f95926061216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
client = paramiko.SSHClient() | |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
client.connect('localhost', username='inndy', password='12341234') | |
shell = client.invoke_shell(environment={'LC_ALL': 'en_US.UTF-8', 'LANG': '', 'LANGUAGE': ''}) | |
print('[*] first shell data') | |
print(shell.recv(4096)) | |
print('-'*80) | |
print('[+] exec /bin/sh') | |
shell.send('exec /bin/sh\nexport LANG=\nexport LANGUAGE=\n') | |
def wait_for(socket, signature): | |
data = socket.recv(4096) | |
while signature not in data: | |
data += socket.recv(4096) | |
return data | |
print(wait_for(shell, b'$ $ $ ')) | |
print('[+] su') | |
shell.send('su\n') | |
print(wait_for(shell, b'Password: ')) | |
print('[+] input password') | |
shell.send('567567\n') | |
print(wait_for(shell, b'# ')) | |
shell.send('whoami; echo UID=$UID; echo Am I root now?\n') | |
print(wait_for(shell, b'Am I root now?')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment