导航:首页 > 文档加密 > 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脚本加密且能运行相关的资料

热点内容
项目编译后浏览器不对应刷新 浏览:564
三星升级android60 浏览:292
粘土的压缩模量 浏览:115
美国程序员生活 浏览:219
51单片机摘要 浏览:405
英语经典pdf下载 浏览:317
大学文件夹怎么删除 浏览:668
linux科研软件 浏览:553
ue4打包编译着色器 浏览:775
云服务器可以在手机上登录吗 浏览:676
网游脚本为什么要连接服务器 浏览:7
程序员发展路线图 浏览:318
手机语音加密会议 浏览:591
冰与火pdf 浏览:420
为什么叫我买阿里云服务器 浏览:475
加密货币征税一览表 浏览:964
llc编译器 浏览:927
数控可编程电阻器 浏览:762
培训app源码 浏览:436
phpcurl启用 浏览:538