Kioptrix1 ルート権限掌握後にやること(ユーザ作成、SSH接続、他)

ルート権限をとりあえず奪取したけど、、、

※というか、OpenFuckで一発とかちょっとあっけなさすぎる・・・

 

なので、その後のバックドアつくりとか、確認

あと、sambaがうまく動いていなかったのでそこも確認したい

 

ユーザの作成

ユーザの作成にあたって、OpenFuckにて権限rootで侵入した状態を考える

ユーザの追加として、useraddを実行したが、見つからない

 

ここで、ダメ元でいくつかのPATHを追加してみる

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

 

sbinは、通常rootであればPATHが通っているものらしいですが・・・

 

 

これで再度試すと、useraddが実行できました

 

useradd kali

passwd kali

 

 

バックドア用のユーザ作成が完了しました

 

SSHの許可

exploitコードを用いてrootでログインできたのですが、

依然としてリバースシェル状態であり、ダイレクトに接続できてません

先ほど作成したユーザに遠隔からSSHでログインしたい・・・

 

 

 

が、エラーではじかれます

 

kali@kali:~/SyachinekoLab/workspace/VulnHub/Kioptrix1$ ssh test@192.168.3.29
Unable to negotiate with 192.168.3.29 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

 

 

ちょっとこのエラーよくわからない・・・

接続先から、鍵交換の手法についていくつか選択支があるけど、それらがない??

 

 

googlingしたところ、以下が見つかりました

https://unix.stackexchange.com/questions/340844/how-to-enable-diffie-hellman-group1-sha1-key-exchange-on-debian-8-0

 

 

サーバ側から要求される鍵交換のプロトコルが古すぎることが原因

たしかにKioptrixはだいぶ古いマシンなので、それも納得ですわ・・・

ということで、古い、かつ要求されているKeyExchangeを追加する

 

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 192.168.3.29

 

すると、さらに別のエラー

kali@kali:/etc/ssh$ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 192.168.3.29
Unable to negotiate with 192.168.3.29 port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se

 

 

これも同様に、サーバ側が要求する暗号化方式が古すぎてNGとなっている例

引数で追加してあげる

kali@kali:/etc/ssh$ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oCiphers=+aes128-cbc 192.168.3.29
The authenticity of host '192.168.3.29 (192.168.3.29)' can't be established.
RSA key fingerprint is SHA256:VDo/h/SG4A6H+WPH3LsQqw1jwjyseGYq9nLeRWPCY/A.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.3.29' (RSA) to the list of known hosts.
kali@192.168.3.29's password:
unknown terminal "xterm-256color"
unknown terminal "xterm-256color"
[kali@kioptrix kali]$

 

ようやくつながった!!!

 

 

 

さて、別でrootで入っている状況で、

/etc/sudoersの設定を変更してあげる

 

cd /etc

echo "kali ALL=(ALL) ALL" >> sudoers

 

 

これでいつでもSSHログインからのroot権限昇格が可能になりました

バックドアの完成です

 

[kali@kioptrix /]$
[kali@kioptrix /]$ sudo su
unknown terminal "xterm-256color"
unknown terminal "xterm-256color"
[root@kioptrix /]#

 

 

※暗号化については以下の記事で勉強予定

qiita.com

 

sambaサービスの確認

 SSHで無事ログインできたので、

samba含めてサービスを確認する

 

[root@kioptrix /]# service --status-all
anacron dead but subsys locked
apmd (pid 700) is running...
arpwatch is stopped
atd (pid 915) is running...
Configured Mount Points:
------------------------

Active Mount Points:
--------------------
Broadcom BCM5820 init script
Copyright (c) 2001 Broadcom Corporation
usage: bcm5820 [start|stop|restart|condrestart]
crond (pid 867) is running...
gpm (pid 849) is running...
httpd (pid 1333 1332 1331 1330 1328 1326 925) is running...
identd is stopped
ipchains: Incompatible with this kernel
Table: filter
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Table: nat
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Table: mangle
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
No status available for this package
lpd is stopped
Configured devices:
lo eth0
Currently active devices:
eth0 lo
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
rpc.statd (pid 588) is running...
nscd is stopped
portmap (pid 560) is running...
postmaster is stopped
The random data source exists
rpc.rstatd is stopped
rpc.rusersd is stopped
rpc.rwalld is stopped
rwhod is stopped
sendmail (pid 830) is running...
smbd (pid 923) is running...
nmbd (pid 921) is running...
snmpd is stopped
squid is stopped
FATAL: Could not determine fully qualified hostname. Please set 'visible_hostname'

Squid Cache (Version 2.4.STABLE1): Terminated abnormally.
CPU Usage: 0.010 seconds = 0.000 user + 0.010 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 304
sshd (pid 6243 1113) is running...
syslogd (pid 535) is running...
klogd (pid 540) is running...
tux is stopped
xfs is stopped
xinetd (pid 789) is running...
ypbind is stopped
rpc.yppasswdd is stopped
ypserv is stopped
ypxfrd is stopped

 

 

smbd...動いてるなぁ・・・

 

[root@kioptrix /]# service smb status
smbd (pid 923) is running...
nmbd (pid 921) is running...
[root@kioptrix /]# ps aux | grep 923
root 923 0.0 1.9 3256 1192 ? S 03:11 0:00 smbd
[root@kioptrix /]# service smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
[root@kioptrix /]# ps aux | grep 923
[root@kioptrix /]# service smb status
smbd (pid 7778) is running...
nmbd (pid 7783) is running...
[root@kioptrix /]#

 

 

試しにrestartしたけどダメでした・・・

 

 

 改めてenum4linuxのエラーを確認する

 

...
=====================================
| Session Check on 192.168.3.29 |
=====================================
[E] Server doesn't allow session using username '', password ''. Aborting remainder of tests.

...

 

 

あー、これって普通にユーザ名/PWの組み合わせが間違ってるってことっすね・・・

あれ?でも一部のWriteUpでは普通に出てるけどなんでなんじゃろ?

 

 

 

でもまぁとにかく、

バックドアまで作り終えたので完了とさせていただきますわぁ

 

 

 

次回もしかしたら脆弱性をなくすためのアップデート大作戦するかも

 

 

以上!