[Themes] 在UOS中使用SecureCRT一键连接天融信管理的服务器
Tofloor
poster avatar
139******14
deepin
2021-10-12 19:20
Author

运维的客户有一家用的天融信,连接其中的服务器需要安装单点登陆工具,而且必须使用IE,而我们使用UOS第一没法安装单点登陆工具,第二没有IE(虽然有wine版的,但是也没什么好办法安装各种IE插件不是)

通过分析页面内容,发现通过随机生成的验证码,生成连接参数再调用本地的如putty、SecureCRT等工具进行连接,那么如何使这个步骤由自己决定如何调用呢?想来想去,使用油猴插件应该可以完成验证码的获取和本地应用的调用。

通过点击页面上的快速登陆按钮,分析找到对应的调用位置

img

我这边分配的是调用本地的putty进行连接,所以定位到putty调用的地方

        if (fort_ip == null) {
alert("单点登录错误: FORT_IP ERR");
return;
}

//sso.run("sso_putty.exe","-ssh -P 22 -pw ROOTROOT root@192.168.23.104");
try{
sso.run("sso_putty.exe", sso_url);
} catch(err) {
alert("客户端控件未安装或被禁用!");
}
}

我使用的edge浏览器,正常点击,会提示

image-20211012104001001

修改这个返回信息为调用过程:

            if (fort_ip == null) {
              alert("单点登录错误: FORT_IP ERR");
              return;
          }

          //sso.run("sso_putty.exe","-ssh -P 22 -pw ROOTROOT root@192.168.1.2");
          try{
              sso.run("sso_putty.exe", sso_url);
          } catch(err) {
              var randompwd="";
              var seorun="";
              //生成命令行内容并进行base64加密(加密方式可以自选,主要是因为window.open调用时内容不能有空格)
              seorun=window.btoa("ssh2 user@`+window.document.domain+` /P 22 /PASSWORD "+randompwd);
              //与本地mime协议进行通讯
              window.open('x-ssh://'+seorun);
          }
      }

到这里就完成了验证码提取与参数调用本地应用的内容。

完整脚本内容可以看 这里 通过浏览器安装 油猴脚本猫 导入脚本即可使用

备注:该脚本对应的是天融信不支持Linux客户端的设备版本,具体版本号未知,因为我也只有访问授权的基础页面,看不到相关版本信息,联系官方客服通过界面也无法判断具体版本。

附录内容:

通过js调用本地应用,需要注册本地应用通讯协议

1、创建并编辑 /usr/share/applications/x-ssh.desktop 文件

sudo touch /usr/share/applications/x-ssh.desktop
sudo chmod +x /usr/share/applications/x-ssh.desktop
sudo deepin-editor /usr/share/applications/x-ssh.desktop

将下边内容粘贴到文件内

[Desktop Entry]
Name=x-ssh
Comment=local ssh trans
Exec=x-ssh %u
Icon=
StartupNotify=true
Terminal=false
Type=Application
Categories=Network;

Actions=Window;

[Desktop Action Window]
Name=New Window
Exec=x-ssh %u
OnlyShowIn=Unity;
MimeType=x-scheme-handler/x-ssh

2、创建 x-ssh.sh 执行文件,将获取到的参数进行base64解码还原,再调用给SecureCRT

#!/bin/bash
if [ -n "$1" ]; then
  seorun=`echo ${1/x-ssh:\/\/}|base64 -d`
  /usr/bin/SecureCRT $seorun
fi

3、.sh文件无法被页面的x-ssh://唤起,需要生成二进制文件

#安装 shc 如果已安装可以跳过
sudo apt install shc

#生成二进制文件,生成的文件是 x-ssh.sh.x
shc -r -f x-ssh.sh

#移动二进制文件到 /usr/bin
sudo mv x-ssh.sh.x /usr/bin/x-ssh
#赋予执行权限
sudo chmod +x /usr/bin/x-ssh

4、注册 名为 x-ssh 的应用协议

xdg-mime default x-ssh.desktop x-scheme-handler/x-ssh

 

Reply Favorite View the author
All Replies
uvz
deepin
2021-10-13 19:07
#1

virtualbox + win7 

右ctrl + L

Reply View the author
139******14
deepin
2021-10-13 19:24
#2
uvz

virtualbox + win7 

右ctrl + L

也是得开虚拟机啊

抛弃虚拟机不是更好?

Reply View the author
jiutian123
deepin
2021-10-26 05:34
#3

路上的阻碍一个个消灭掉,期待那一天

Reply View the author