网心云容器魔方一键扫码工具(图形化)
此脚本利用网心云公开的容器魔方的http接口,并使用时脚本进行判断是否有所需依赖。且为用户提供图形交互 网心云sn wget -cq http://$(ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -c 1-):18888/docker/data -O - | jq -r '.data.device.sn' 网心云acode wget -cq http://$(ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -c 1-):18888/docker/data -O - | jq -r '.data.device.acode' 二维码扫码 qrencode -l M -t UTF8 -k "https://www.onethingcloud.com/download-center/?activecode=$(wget -cq http://$(ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -c 1-):18888/docker/data -O - | jq -r '.data.device.acode')&sn=$(wget -cq http://$(ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -c 1-):18888/docker/data -O - | jq -r '.data.device.sn')" #!/bin/bash #必须为bash #字符串定义 str5=$(ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -c 1-) #本机IP str6=wget str7=-cq str8=https://www.onethingcloud.com/download-center #网心云下载地址/二维码生成一键扫码 #本地查询模组(模块侧) function wxedge1() { dir1=$($str6 $str7 http://$str5:$str2/docker/data -O - | jq -r '.data.device.sn') #本机容器魔方接口,调用sn dir2=$($str6 $str7 http://$str5:$str2/docker/data -O - | jq -r '.data.device.acode') #本机容器魔方接口,调用acode if [ ! -n "$dir1" ]; then #判定本机是否正确输入端口号,错误将循环。按esc将结束本程序! if [ $exitstatus = 0 ]; then whiptail --msgbox --title "网心云容器魔方信息搜寻工具(错误)" "该端口号没有相关信息!请重新输入" --ok-button "确认" 10 60 str2=$(whiptail --title "网心云容器魔方信息搜寻工具(本机搜索)" --inputbox "请输入本机端口" --ok-button "确认" --cancel-button "退出" 10 60 "18888" 3>&1 1>&2 2>&3) exitstatus=$? #判断二次输入是否正确,否则继续该循环! wxedge1 #循环该参数! else echo "stop" fi else { for ((i = 0; i <= 100; i += 10)); do sleep 0.05 echo $i done } | whiptail --gauge "请稍后,数据回传中......" 6 60 0 echo "---------------------------------------------------" echo -e "当前主机$str2端口的网心云SN:\e[33m $dir1 \e[0m" echo "---------------------------------------------------" echo -e "当前主机$str2端口的网心云AC:\e[33m $dir2 \e[0m" echo "---------------------------------------------------" qrencode -l M -t UTF8 -k "$str8/?activecode=$dir2&sn=$dir1" #二维码生成传入sn&acode输出utf8字符串 fi } #远程查询模组(模块侧) function wxedge2() { dir3=$($str6 $str7 http://$str3:$str4/docker/data -O - | jq -r '.data.device.sn') dir4=$($str6 $str7 http://$str3:$str4/docker/data -O - | jq -r '.data.device.acode') if [ ! -n "$dir3" ]; then whiptail --msgbox --title "网心云容器魔方信息搜寻工具(错误)" "请重新输入" --ok-button "确认" 10 60 str3=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请重新输入目标IP" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) exitstatus=$? if [ ! $exitstatus = 0 ]; then echo "stop" exit 1 fi str4=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请重新输入目标PORT" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) exitstatus=$? if [ ! $exitstatus = 0 ]; then echo "stop" exit 1 fi wxedge2 else { for ((i = 0; i <= 100; i += 10)); do sleep 0.05 echo $i done } | whiptail --gauge "请稍后,数据回传中......" 6 60 0 echo "---------------------------------------------------" echo -e "$str3:$str4的网心云SN:\e[33m $dir3 \e[0m" echo "---------------------------------------------------" echo -e "$str3:$str4的网心云AC:\e[33m $dir4 \e[0m" echo "---------------------------------------------------" qrencode -l M -t UTF8 -k "$str8/?activecode=$dir4&sn=$dir3" fi } #提示页面(交互侧) whiptail --msgbox --title "网心云容器魔方信息搜寻工具" "欢迎使用容器魔方信息搜寻工具,严禁用于非法用途!" --ok-button "确认" 10 60 #使用前判断是否满足条件 if ! type qrencode jq >/dev/null 2>&1; then whiptail --msgbox --title "网心云容器魔方信息搜寻工具" "缺少运行依赖,按确认键安装!" --ok-button "确认" 10 60 echo "缺少运行依赖,正在安装!" apt update apt install -y qrencode jq whiptail fi #主页面(交互侧) OPTION=$(whiptail --title "网心云容器魔方信息搜寻工具" --menu "请选择查询方式" --notags --ok-button "确认" --cancel-button "退出" 15 60 4 \ "a" "本机搜索" \ "b" "高级搜索" 3>&1 1>&2 2>&3) exitstatus=$? if [ $exitstatus = 0 ]; then if [ $OPTION = "a" ]; then #子窗口1 str2=$(whiptail --title "网心云容器魔方信息搜寻工具(本机搜索)" --inputbox "请输入本机端口" --ok-button "确认" --cancel-button "退出" 10 60 "18888" 3>&1 1>&2 2>&3) #默认为18888 exitstatus=$? if [ $exitstatus = 0 ]; then wxedge1 else echo "stop" fi elif [ $OPTION = "b" ]; then #子窗口2 str3=$(whiptail --title "网心云容器魔方信息搜寻工具(高级搜索)" --inputbox "请输入目标IP" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) exitstatus=$? if [ ! $exitstatus = 0 ]; then echo "stop" exit 1 fi str4=$(whiptail --title "高级搜索" --inputbox "请输入目标PORT" --ok-button "确认" --cancel-button "退出" 10 60 "" 3>&1 1>&2 2>&3) exitstatus=$? if [ ! $exitstatus = 0 ]; then echo "stop" exit 1 fi wxedge2 else echo "stop" fi else echo "stop" fi