在非root用户下运行busybox的telnetd服务,会因为默认绑定的是23端口,而导致运行失败,直接退出无任何提示。
可以通过busybox telnetd -p 23023方式选择其他端口。
通过查看busybox telnetd --help的帮助,可以看到可以通过-l选项指定当telnet登录时,会执行的login脚本
tom@iStation:~$ ./busybox-1.34.0/busybox telnetd --help
BusyBox v1.34.0 (2021-09-11 10:07:27 CST) multi-call binary.
Usage: telnetd [OPTIONS]
Handle incoming telnet connections
-l LOGIN Exec LOGIN on connect
-f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue
-K Close connection as soon as login exits
(normally wait until all programs close slave pty)
-p PORT Port to listen on
-b ADDR[:PORT] Address to bind to
-F Run in foreground
-i Inetd mode
-w SEC Inetd 'wait' mode, linger time SEC
inetd.conf line: 23 stream tcp wait root telnetd telnetd -w10
-S Log to syslog (implied by -i or without -F and -w)
这里演示执行:
./busybox-1.34.0/busybox telnetd -p 23023 -l ./login.sh
写了一个login.sh脚本
#!/bin/bash
echo "aaaaaaaaaaaaaa"
su User1
在另外一个窗口登录
xl993@iStation:~/mymind$ telnet 127.0.0.1 23023
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Ubuntu 20.04.3 LTS
aaaaaaaaaaaaaa
Password: