How do you edit a text file after gaining low priv shell

I have tried editing files on certain boxes here using vi and its absolutely a pain. Currently i am working on friendzoned and trying to write to a file and i just cant do that. Would like to know how you guys do it.

if you watch some of the ippsec video he uses a python command to enable a upgraded shell.

see below

python -c ‘import pty;pty.spawn("/bin/bash")’;
hit ctrl z to background
then
type
stty raw -echo
type
fg to foreground

hit enter twice , now you have an upgraded shell. up down keys, etc work and vi should work ok in that shell

if python doesnt work, maybe try python3 depending on what version is running.
Otherwise, you could just create the file on your own machine and bring it across nuking the new target

okay will try that. thanks a lot bro.

There is a problem, tried that not working exactly on ssh.

i have ssh credentials to the box.

I literally copy pasted the commands, even tried python3, but still it doesnt work. If i hit enter, the consective prompt go accross the screen making a diagonal line of prompts.

If you enter through ssh you should already have a tty shell, so there’s no need to run those commands.

In friendzone you have vi installed so you can just go with it, if you don’t know how to use it I recommend you to search for a basic tutorial because it will help you on future boxes as well.

In the case you didn’t have any text editor you could simply use echo and redirect your output to the target file, for example.

Just use vi or ed or vim if you have an ssh connection ?

I know how to use vi, I already use it on my local kali linux machine. Will try to edit the file again.

press esc and then :w to write and :wq to save and exit right? It would be great if someone could confirm if I am doing it right it would be great. Pm me if you can assist me.

was able to use nano to write to the file, thanks guys.