导航:首页 > 文档加密 > shell脚本加密且能运行

shell脚本加密且能运行

发布时间:2023-06-27 00:40:42

‘壹’ linux shell脚本,运行时要输入密码,密码正确才往下跑,这个怎么实现呢

A=123456
read-p"请输入密码:"PASSWD
if["$PASSWD"=="$A"];then
continue
else
echo"密码不错误,请重启输入!"
fi

‘贰’ shell脚本加密

两种方法
gzexe shell-script
这样会把shell脚本打包成一个可执行程序,但是使用者看不到脚本内容
gcc compile file
用gcc对shell进行编译生成可执行文件

‘叁’ 如何给PowerShell脚本加密

适用于Powershell3.0及以后版本。假设你需要给文件加密,下面教你如何给自己的文件加密:

$Path = "$env:temp\secret.txt"
$Secret = 'Hello World!'
$Passphrase = 'Some secret key'

$key = [Byte[]]($Passphrase.PadRight(24).Substring(0,24).ToCharArray())

$Secret |
ConvertTo-SecureString -AsPlainText -Force |
ConvertFrom-SecureString -Key $key |
Out-File -FilePath $Path

notepad $Path

当你需要解密出里面的内容,这时就需要最初的密码:

$Passphrase = Read-Host 'Enter the secret pass phrase'

$Path = "$env:temp\secret.txt"

$key = [Byte[]]($Passphrase.PadRight(24).Substring(0,24).ToCharArray())

$cred = New-Object -TypeName System.Management.Automation.PSCredential('mmy', $decryptedTextSecureString)
$decryptedText = $cred.GetNetworkCredential().Password

‘肆’ 如何将shell脚本变为可执行文件

方法一、可以使用gzexe命令直接将shell脚本变成可执行文件,命令为gzexe 后面接要处理的shell文件名。

4、shc常用参数说明
-e date (指定过期日期)
-m message (指定过期提示的信息)
-f script_name(指定要编译的shell的路径及文件名)
-r Relax security. (可以在相同操作系统的不同系统中执行)
-v Verbose compilation(编译的详细情况)

‘伍’ 如何给powershell脚本加密

适用于Powershell3.0及以后版本。
假设你需要给文件加密,下面教你如何给自己的文件加密:

$Path="$env:tempsecret.txt"
$Secret='HelloWorld!'
$Passphrase='Somesecretkey'

$key=[Byte[]]($Passphrase.PadRight(24).Substring(0,24).ToCharArray())

$Secret|
ConvertTo-SecureString-AsPlainText-Force|
ConvertFrom-SecureString-Key$key|
Out-File-FilePath$Path

notepad$Path

当你需要解密出里面的内容,这时就需要最初的密码:

$Passphrase=Read-Host'Enterthesecretpassphrase'

$Path="$env:tempsecret.txt"

$key=[Byte[]]($Passphrase.PadRight(24).Substring(0,24).ToCharArray())

try
{
$decryptedTextSecureString=Get-Content-Path$Path-Raw|
ConvertTo-SecureString-Key$key-ErrorActionStop

$cred=New-Object-TypeNameSystem.Management.Automation.PSCredential('mmy',$decryptedTextSecureString)
$decryptedText=$cred.GetNetworkCredential().Password
}
catch
{
$decryptedText='(wrongkey)'
}
"Thedecryptedsecrettext:$decryptedText"

‘陆’ 如何用shell脚本对文件内容加密

使用OPENSSL命令吧

Plain Text code?

1
2
3
4
5

#加密
openssl enc -e -aes-256-cbc -in 要加密的文件 -out 要解密的文件 -pass pass:密码

#解密
openssl enc -d -aes-256-cbc -in 要解密的文件 -out 要加密的文件 -pass pass:密码

‘柒’ shell脚本是否可以编译,封装,加密

SHELL脚本是被/bin/sh执行的,如果加密,自然/bin/sh无法解析。
但也有方法可以达到你的目的,你讲SHELL加密,写一个可执行文件,可执行文件解密你的SHELL,然后fork进程去执行你的SHELL文件。

阅读全文

与shell脚本加密且能运行相关的资料

热点内容
数据库查询系统源码 浏览:614
php5314 浏览:354
完美国际安装到哪个文件夹 浏览:666
什么app可以扫一扫做题 浏览:537
程序员编码论坛 浏览:923
淘点是什么app 浏览:658
中国高等植物pdf 浏览:453
51单片机时间 浏览:182
后台如何获取服务器ip 浏览:265
单片机流水灯程序c语言 浏览:233
程序员第二职业挣钱 浏览:237
运行里怎么输入服务器路径 浏览:840
pythonstepwise 浏览:509
刘一男词汇速记指南pdf 浏览:62
php认证级别 浏览:366
方舟编译啥时候推送 浏览:1010
php手机验证码生成 浏览:675
哲学思维pdf 浏览:14
凌达压缩机有限公司招聘 浏览:534
weblogic命令部署 浏览:36