打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
"SSH Connect" in Dashboard context menu
1. Get Shellinabox AJAX web ssh/telnet shell.
2. Compile and install it, but don't start it as a service.
3. Edit the following telnet.sh and ssh.sh and put them into the cgi-bin directory of your web server that is hosting Zabbix frontend.
PHP Code:
#!/bin/bash
# ssh.sh
# This is a CGI script that uses shellinabox in CGI mode.
function connect {
shellinaboxd --cgi -c /var/lib/shellinabox -s /:SSH:$parms
if [ $? -ne 0 ]; then
echo "$res" > /tmp/1.log
cannot_connect
fi
}
function default {
# First time that the CGI script was called. Show initial HTML page.
printf 'Content-Type: text/html\r\n\r\n'
cat <<EOF
<html>
<head>
<title>SSH Shell</title>
</head>
<body>
<h1>SSH Shell</h1>
<p>Enter address to connect to:
<form method="POST">
<input type="text" name="cmd" style="width: 40em" value="127.0.0.1" />
</form>
</p>
</body>
EOF
}
function cannot_connect {
printf 'Content-Type: text/html\r\n\r\n'
cat <<EOF
<html>
<head>
<title>SSH Shell</title>
</head>
<body>
<h1>SSH Shell</h1>
<p>Unable to establish connection with $parms</p>
</body>
EOF
}
case "${REQUEST_METHOD}" in
GET)
# Retrieve CGI parameter, then start shellinabox with this address
parms=`echo $QUERY_STRING`
if [ "$parms" != "" ]; then
connect $parms
else
default
fi
;;
POST)
# Retrieve CGI parameter, then start shellinabox with this address
read parms
parms="$(printf "$(echo "${parms}"|sed -e 's/%\(..\)/\\x\1/g;s/%/%%/g')")" #"
parms="${parms#cmd=}"
if [ "$parms" != "" ]; then
connect $parms
else
default
fi
;;
*)
default
;;
esac
END__VBULLETIN__CODE__SNIPPET ?>
PHP Code:
#!/bin/bash
# telnet.sh
# This is a CGI script that uses shellinabox in CGI mode.
function connect {
shellinaboxd --cgi -c /var/lib/shellinabox -s "/:$(id -u):$(id -g):HOME:telnet ${parms}"
if [ $? -ne 0 ]; then
cannot_connect
fi
}
function default {
# First time that the CGI script was called. Show initial HTML page.
printf 'Content-Type: text/html\r\n\r\n'
cat <<EOF
<html>
<head>
<title>Telnet Shell</title>
</head>
<body>
<h1>Telnet Shell</h1>
<p>Enter address to connect to:
<form method="POST">
<input type="text" name="cmd" style="width: 40em" value="127.0.0.1" />
</form>
</p>
</body>
EOF
}
function cannot_connect {
printf 'Content-Type: text/html\r\n\r\n'
cat <<EOF
<html>
<head>
<title>Telnet Shell</title>
</head>
<body>
<h1>Telnet Shell</h1>
<p>Unable to establish connection with $parms</p>
</body>
EOF
}
case "${REQUEST_METHOD}" in
GET)
# Retrieve CGI parameter, then start shellinabox with this address
parms=`echo $QUERY_STRING`
if [ "$parms" != "" ]; then
connect $parms
else
default
fi
;;
POST)
# Retrieve CGI parameter, then start shellinabox with this address
read parms
parms="$(printf "$(echo "${parms}"|sed -e 's/%\(..\)/\\x\1/g;s/%/%%/g')")" #"
parms="${parms#cmd=}"
if [ "$parms" != "" ]; then
connect $parms
else
default
fi
;;
*)
default
;;
esac
END__VBULLETIN__CODE__SNIPPET ?>
4. Ensure that your cgi-bin directory is enabled in your web server config and cgi-scripts are accessible from a web browser.
5. Create /var/lib/shellinabox directory and make it rwx-accessible by your web server process, i.e. apache, nobody, whatever it is. Or just chmod it to 777, which is a security hole.
6. Open Zabbix network map editor, chose a host to edit and type in the URL field: http://<Your Zabbix Web Server Address>/cgi-bin/telnet.sh?<IP Address Of A Network Host>
7. Save the map, open it in the map viewer, point at the edited icon and click the URL link. A telnet window will replace your current browser tab.
If you have firewalling on your Zabbix server enabled your browser will likely fail to connect to Shellinabox. In this case temporary enable all incoming connections to check it's working and tune your firewall.
There are other web shells such as Ajaxterm, js_terminal, nixs, webshell, webtty, and probably others, but I didn't try them because Shellinabox just worked.
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
群辉有没有shell套件?
基于web的ssh登录工具shellinabox,手机也可以登录你的服务器了
expect学习笔记及实例详解
access Mercurial over ssh tunnel (相忘于江湖)
Oracle数据库自动启动Shell脚本
php的SAPI,CLI SAPI,CGI SAPI
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服