IPSec快速式策略

@echo off
:again
set num=
set fastpolicyname=
set issoft=
set livetime=
set fps=
setlocal EnableDelayedExpansion
cls
echo.
echo.
echo --------------------请选择要执行的操作--------------------
echo -----.创建IP安全快速模式策略
echo -----.创建具有指定安全措施的快速模式策略
echo -----.修改IP安全快速模式策略配置信息
echo -----.删除指定的IP安全快速模式策略
echo -----.退出程序
echo.
echo.
set /p num=请选择要执行的操作:
if "!num!"=="" (
set /p fastpolicyname=请输入IP安全快速模式策略名称:
set /p issoft=ipsec协商失败时若使用不安全通信请输入yes,否则输入no:
set /p fps=请输入会话密钥的级别:
echo.
netsh ipsec dynamic add qmpolicy name=!fastpolicyname! soft=!issoft! pfsgroup=!fps!
echo 命令执行成功,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p fastpolicyname=请输入IP安全快速模式策略名称:
set /p issoft=ipsec协商失败时若使用不安全通信请输入yes,否则输入no:
set /p fps=请输入会话密钥的级别:
set /p keyexpress=请输入密钥交换安全措施表达式:
echo.
netsh ipsec dynamic add qmpolicy name=!fastpolicyname! soft=!issoft! pfsgroup=!fps! qmsecmethods="!keyexpress!"
echo 命令执行成功,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p fastpolicyname=请输入要修改的IP安全快速模式策略名称:
set /p issoft=ipsec协商失败时若使用不安全通信请输入yes,否则输入no:
set /p fps=请输入会话密钥的级别:
set /p keyexpress=请输入密钥交换安全措施表达式:
echo.
netsh ipsec dynamic set qmpolicy name=!fastpolicyname! soft=!issoft! pfsgroup=!fps! qmsecmethods="!keyexpress!"
echo 命令执行成功,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p fastpolicyname=请输入要删除的IP安全快速模式策略名称:
echo.
netsh ipsec dynamic delete qmpolicy name=!fastpolicyname!
echo 命令执行成功,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
goto end
)
if "!num!"=="" (
goto again
)
if not "!num!"=="" (
echo 选择错误,请按任意键返回主菜单后重新选择!
pause > nul
goto again
)
:end
exit

IPSec主模式策略

@echo off
:again
set num=
set masterpolicyname=
set keytime=
set livetime=
set keyexpress=
set number=
setlocal EnableDelayedExpansion
cls
echo.
echo.
echo --------------------请选择要执行的操作--------------------
echo -----.创建IP安全主模式策略
echo -----.创建具有密钥交换安全措施的主模式策略
echo -----.修改IP安全主模式策略配置信息
echo -----.删除指定的IP安全主模式策略
echo -----.退出程序
echo.
echo.
set /p num=请选择要执行的操作:
if "!num!"=="" (
set /p masterpolicyname=请输入IP安全主模式策略名称:
set /p keytime=请输入密钥生成时间:
set /p livetime=请输入未受保护的安全关联存活时间:
echo.
netsh ipsec dynamic add mmpolicy name=!masterpolicyname! softsaexpirationtime=!livetime! mmlifetime=!keytime!
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p masterpolicyname=请输入IP安全主模式策略名称:
set /p keytime=请输入密钥生成时间:
set /p livetime=请输入未受保护的安全关联存活时间:
set /p keyexpress=请输入密钥交换安全措施表达式:
echo.
netsh ipsec dynamic add mmpolicy name=!masterpolicyname! softsaexpirationtime=!livetime! mmlifetime=!keytime! mmsecmethods=^
"!keyexpress!"
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p masterpolicyname=请输入IP安全主模式策略名称:
set /p keytime=请输入密钥生成时间:
set /p livetime=请输入未受保护的安全关联存活时间:
set /p keyexpress=请输入密钥交换安全措施表达式:
set /p number=请输入主密钥材料可用来派生会话密钥的次数:
echo.
netsh ipsec dynamic set mmpolicy name=!masterpolicyname! softsaexpirationtime=!livetime! mmlifetime=!keytime! mmsecmethods=^
"!keyexpress!"
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
set /p masterpolicyname=请输入要删除的IP安全主模式策略名称:
echo.
netsh ipsec dynamic delete mmpolicy name=!masterpolicyname!
echo 命令执行完毕,请按任意键后返回主菜单... ...
pause > nul
goto again
)
if "!num!"=="" (
goto end
)
if "!num!"=="" (
goto again
)
if not "!num!"=="" (
echo 选择错误,请按任意键返回主菜单后重新选择!
pause > nul
goto again
)
:end
exit
05-08 15:27