[Transfer] Encryption and decryption of Shell scripts in Linux

888u

Last update at :2024-05-14,Edit by888u

The shell scripts we write usually contain information such as account passwords or information that you don’t want others to see, so it is necessary to simply encrypt the written shell scripts. There are four commonly used shell encryption methods, namely encryption through gzexe, encryption through shc, encryption through UPX and encryption through openssl. This blog will give a brief introduction to these four encryption algorithms. 1.GZEXE compression algorithm This algorithm is not very advanced and is mainly used to compress code. Strictly speaking, it is not an encryption tool, but when you open it directly, the display will be garbled. Many people are helpless about this, so I will briefly introduce it. gzexe is usually provided by the system. When you need to encrypt, you only need to write:

  • gzexe
  • The original script can be compressed to generate a compressed script similar to gz format. Decompressing such encrypted scripts is also very simple, just run

  • gzexe –d script.sh
  • It can be unlocked and restored to the original script. 2.SHC encryption algorithm This is a slightly more advanced algorithm and is encryption in the true sense. SHC installation method:

  • wget http://www.datsi.fi.upm.es/%7Efrosal/sources/shc-3.8.9.tgz
  • tar vxf shc–3.8.9.tgz
  • cd shc–3.8.9
  • make test
  • make strings
  • make install
  • How to use:

  • shc –v –f script name.sh
  • -v is the actual encryption process -f followed by the file to be encrypted The decryption method is also very simple. You only need to install the Unshc software. Install:

  • wget –N —no–check–certificate –O /usr/local/bin/unshc https://raw.githubusercontent.com/yanncam/UnSHc/master/latest/unshc.sh && chmod +x /usr/local/bin/unshc
  • Use:

  • unshc script name.sh
  • 3.UPX encryption algorithm UPX is actually a lightweight compression tool that can be used as soon as you download it. UPX download is a direct link. Remember to give UPX permissions in Linux systems Packing command:

  • ./upx script name.sh
  • Unpacking command:

  • ./upx –d script name.sh
  • 4.openssl encryption Introduction: If you want to use OpenSSL to encrypt files, it is actually as simple as encrypting messages. The only difference is that instead of using the echo command, we use the -in option, followed by the actual file we want to encrypt, and the -out option, which instructs OpenSSL to store the encrypted file in a directory named In the file: Encryption:

  • $ openssl enc –aes–256–cbc –in /etc/services –out services.dat
  • Decryption:

  • $ openssl enc –aes–256–cbc –d –in services.dat > services.txt
  • enter aes–256–cbc decryption password:
  • Recommended site searches: free hosting, domain name registration service website, Japanese proxy server ip, registration password retrieval, ip proxy free version 2.80, me domain name, registration-free hosting in mainland China, domain name registration query, asp hosting space, free domain name Space application,

    [Transfer] Encryption and decryption of Shell scripts in Linux

    All copyrights belong to 888u unless special state
    取消
    微信二维码
    微信二维码
    支付宝二维码