首页 > 其他分享 >一键安装Cisco AnyConnect Secure Mobility Client

一键安装Cisco AnyConnect Secure Mobility Client

时间:2022-10-03 23:08:45浏览次数:66  
标签:choiceIdentifier AnyConnect Cisco Secure NC anyconnect echo pkg 安装

Mac版本

背景:公司内部安装此VPN软件的时候,因默认是安装了所有模块,但我们只需要vpn模块,所产生的干扰。并且有人因不熟悉Mac pkg 软件的卸载方法导致非正常卸载,导致重新安装也无法安装,软件也没了。原来的解决方式是给出相关安装文档与卸载命令,但因在此过程中有些人就不看文档,或者看不懂文档特别是涉及通过代码层次的卸载解决方式很多人并不会,在此过程中造成了大量的无效沟通成本,因此我就写了一个shell脚本解决以上问题。

目录架构

❯ tree -a
.
├── .AnyConnect.pkg #这是软件主程序,如果脚本运行有问题的话可以双击此程序来手动安装(自带)
├── .DS_Store
├── .Profiles #配置文件(不用管,自带的)
│ ├── .DS_Store
│ ├── ACTransforms.xml
│ ├── ampenabler
│ ├── feedback
│ ├── iseposture
│ ├── nvm
│ ├── umbrella
│ └── vpn
├── .VolumeIcon.icns #图标(自带)
├── .background #背景(自带)
│ └── dmg_background.tiff
├── .install_1.xml #这是安装所需要的配置文件,里面定义了默认只安装vpn模块,其他模块不装(自行定义编写)
└── install #这是一个安装脚本(自行定义编写)

代码说明

.install_1.xml

这是一个自定义配置文件,配置说明如下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>attributeSetting</key>
<integer>1</integer> <!-- 这个参数控制是否默认安装模块,不知道这是对应的哪个模块可以看下面的 string字段,例如是vpn模块,那么名字就是 choice_vpn,其他的以此类推 -->
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_vpn</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_websecurity</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_fireamp</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_dart</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_posture</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_iseposture</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_nvm</string>
</dict>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>choice_umbrella</string>
</dict>
</array>
</plist>

install

这个文件其实就是一个shell脚本,别人安装也是运行这个脚本,通过运行脚本来安装软件

#!/bin/bash
clear
RED='\033[0;31m'
GRN='\033[0;32m'
BLU='\033[0;34m'
NC='\033[0m'
pkgName=$(pkgutil --pkgs|grep "com.cisco.pkg.anyconnect.vpn")
# 当前路径
parentPath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parentPath"
# 在当前路径查询符合pkg后缀的文件
pkgPath=$( find "$parentPath" -name '*.pkg' -maxdepth 1)
# 在当前路径查询符合xml后缀的文件
xmlPath=$( find "$parentPath" -name '*.xml' -maxdepth 1)
# 逻辑判断,是否有查到已经安装了com.cisco.pkg.anyconnect.vpn,如果有则d,则先卸载再重新安装,否则直接安装 vpn。安装完后直接等待两秒直接关闭终端
if [ ! $pkgName ];then
echo -e "${RED}不存在,不需要卸载,接下来直接安装。${NC}"
echo -e "${BLU}请输入开机密码,输入完成后按下回车键(输入过程中密码是看不见的>)${NC}"
sudo installer -pkg "${pkgPath}" -applyChoiceChangesXML "${xmlPath}" -target / > /dev/null
if [ $? -eq 0 ];then
echo -e "${GRN}安装完成,本窗口可关闭${NC}"
sleep 2 && osascript -e "do Shell script \"osascript -e \\\"tell application \\\\\\\"Terminal\\\\\\\" to quit\\\" &> /dev/null &\""; exit
else
echo "${RED}安装失败请截图联系it-help${NC}"
fi
else
echo -e "${BLU}开始卸载原软件${NC}"
echo -e "${RED}------------------------------${NC}"
echo -e "${BLU}请输入开机密码,输入完成后按下回车键(输入过程中密码是看不见的>)${NC}"
sudo pkgutil --forget com.cisco.pkg.anyconnect.vpn
echo -e "${BLU}开始安装VPN客户端${NC}"
sleep 2
sudo installer -pkg "${pkgPath}" -applyChoiceChangesXML "${xmlPath}" -target / > /dev/null
if [ $? -eq 0 ];then
echo -e "${GRN}安装完成,本窗口可关闭${NC}"
sleep 2 && osascript -e "do Shell script \"osascript -e \\\"tell application \\\\\\\"Terminal\\\\\\\" to quit\\\" &> /dev/null &\""; exit
else
echo "${RED}安装失败请截图联系it-help${NC}"
fi
fi

Mac命令

注意⚠️:以下是此过程中需要用到的一些命令。

# 将anyconnect-macos-4.10.05111-predeploy-k9.dmg 转成可读写
hdiutil convert anyconnect-macos-4.10.05111-predeploy-k9.dmg -format UDRW -o anyconnect-macos-4.10.05111-predeploy-k9-rw.dmg
# 将anyconnect-macos-4.10.05111-predeploy-k9.dmg 转成只读
hdiutil convert anyconnect-macos-4.10.05111-predeploy-k9-rw.dmg -format UDRO -o anyconnect-macos-4.10.05111-predeploy-k9-ro.dmg

vpn软件包

4.10.05111 软件包已经上传到我的阿里云盘中了,有需要自取。Windows,Mac,Linux版本包都在里面了。

​软件包​

参考链接

​xml自定义参考文件​​​​官方指导文件​​​​pkg卸载​



标签:choiceIdentifier,AnyConnect,Cisco,Secure,NC,anyconnect,echo,pkg,安装
From: https://blog.51cto.com/u_14907428/5730573

相关文章

  • cisco 设备 index 重启后是否发生变化
    跟思科确认:用asr1001-x路由器开的case。思科售后通过用真机测试,可以确定,asr路由器的index重启后会重新排列,此机制是无法改变的。3750交换机index不会改变,因为每一个index......
  • Cisco ASA防火墙恢复开机密码
    CiscoASA密码恢复一、思路CiscoASA防火墙密码恢复,与路由器相似修改寄存器的值,绕过startup-config配置文件重新修改密码恢复修改寄存器的值,保存密码二、操作步骤......
  • 解决SecureFX中文乱码的方法
    SecureFX出现乱码,解决办法在这里插入图片描述1.点击Options选项,选择GlobalOptions在这里插入图片描述2.点击打开GlobalOptions窗口之后,在左边的General选项下方找到Confi......
  • 代码审计(Java)——WebGoat_InsecureDeserialization
    level-5找到java文件,可以看到传入的token经过64解码后输入导对象输入流中,然后没有加限制直接readObject进行了反序列化操作,确实存在漏洞点~packageorg.owasp.web......
  • secure boot (一)fit image
    前言secureboot和FITImage是前段时间接触到的,其实早就该总结下了,奈何懒癌犯了,拖了好久才写出来。之前也有人问我,工作后最大的感受是什么?我的回答是:“快速学习”。就......
  • secure boot (二)基本概念和框架
    什么是securebootsecureboot是指确保在一个平台上运行的程序的完整性的过程或机制。secureboot会在固件和应用程序之间建立一种信任关系。在启用secureboot功能后,未经......
  • secure boot(三)secure boot的签名和验签方案
    简介FIT格式支持存储镜像的hash值,并且在加载镜像时会校验hash值。这可以保护镜像免受破坏,但是,它并不能保护镜像不被替换。而如果对hash值使用私钥签名,在加载镜像时使用......
  • How to install and configure fail2ban to secure linux server
    Howtochecklinuxloginhistoryfail2ban-basic最近把吃灰好几年的树莓派重新整起来之后:......
  • 企业版idea编辑器的破解版安装教程+一些其它软件的安装(navicat+vscode+nodepad+Secure
    1、idea编辑器的安装,IDEA全称IntelliJIDEA,是用于java语言开发的集成环境(也可用于其他语言),IntelliJ在业界被公认为最好的java开发工具之一,尤其在智能代码助手、代码自动......
  • cisco type 7 解密 password
    #include"stdafx.h"#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>charDecPwd[255]={0};charxlat[]={0×64,0×73,0×66,......