見出し画像

OverTheWire:Behemoth7



Behemoth もいよいよ最後の問題。次のレベル ( Behemoth8 )のパスワードを入手すれば全問クリアである。今回も気合を入れて解いてゆこう。

前回の記事で入手したパスワードを使用して問題のサーバーに接続する。
ssh behemoth7@behemoth.labs.overthewire.org -p 2221

今回、解析するプログラムは behemoth7  である。

ehemoth7@behemoth:~$ ls -l /behemoth/behemoth7 
-r-sr-x--- 1 behemoth8 behemoth7 5676 Aug 26  2019 /behemoth/behemoth7

とりあえず実行してみる。

behemoth7@behemoth:~$ /behemoth/behemoth7
behemoth7@behemoth:~$ 

ありゃ?何も起きない。
トレースしてみよう。引数も適当に指定して様子を見てみる。

behemoth7@behemoth:~$ ltrace /behemoth/behemoth7 ABCDE
__libc_start_main(0x804852b, 2, 0xffffd774, 0x8048650 <unfinished ...>
strlen("LC_ALL=en_US.UTF-8")                     = 18
memset(0xffffd8b0, '\0', 18)                     = 0xffffd8b0
strlen("LS_COLORS=rs=0:di=01;34:ln=01;36"...)    = 1467
memset(0xffffd8c3, '\0', 1467)                   = 0xffffd8c3
strlen("SSH_CONNECTION=60.100.205.81 491"...)    = 52
memset(0xffffde7f, '\0', 52)                     = 0xffffde7f
strlen("LANG=en_US.UTF-8")                       = 16
memset(0xffffdeb4, '\0', 16)                     = 0xffffdeb4
strlen("USER=behemoth7")                         = 14
memset(0xffffdec5, '\0', 14)                     = 0xffffdec5
strlen("PWD=/home/behemoth7")                    = 19
memset(0xffffded4, '\0', 19)                     = 0xffffded4
strlen("HOME=/home/behemoth7")                   = 20
memset(0xffffdee8, '\0', 20)                     = 0xffffdee8
strlen("SSH_CLIENT=60.100.205.81 49166 2"...)    = 33
memset(0xffffdefd, '\0', 33)                     = 0xffffdefd
strlen("SSH_TTY=/dev/pts/4")                     = 18
memset(0xffffdf1f, '\0', 18)                     = 0xffffdf1f
strlen("MAIL=/var/mail/behemoth7")               = 24
memset(0xffffdf32, '\0', 24)                     = 0xffffdf32
strlen("TERM=xterm-256color")                    = 19
memset(0xffffdf4b, '\0', 19)                     = 0xffffdf4b
strlen("SHELL=/bin/bash")                        = 15
memset(0xffffdf5f, '\0', 15)                     = 0xffffdf5f
strlen("TMOUT=1800")                             = 10
memset(0xffffdf6f, '\0', 10)                     = 0xffffdf6f
strlen("SHLVL=1")                                = 7
memset(0xffffdf7a, '\0', 7)                      = 0xffffdf7a
strlen("LOGNAME=behemoth7")                      = 17
memset(0xffffdf82, '\0', 17)                     = 0xffffdf82
strlen("PATH=/usr/local/bin:/usr/bin:/bi"...)    = 61
memset(0xffffdf94, '\0', 61)                     = 0xffffdf94
strlen("_=/usr/bin/ltrace")                      = 17
memset(0xffffdfd2, '\0', 17)                     = 0xffffdfd2
__ctype_b_loc()                                  = 0xf7e106cc
__ctype_b_loc()                                  = 0xf7e106cc
__ctype_b_loc()                                  = 0xf7e106cc
__ctype_b_loc()                                  = 0xf7e106cc
__ctype_b_loc()                                  = 0xf7e106cc
strcpy(0xffffd4cc, "ABCDE")                      = 0xffffd4cc
+++ exited (status 0) +++

実行時の引数を strcpy() でバッファにコピーしているので、バッファオーバーフローの脆弱性がありそうだ。

ここから先は

8,781字

¥ 500

この記事が気に入ったらサポートをしてみませんか?