Gzexe encrypts shell scripts 01

Source: Internet
Author: User

Gzexe encrypts shell scripts 01

Gzexe encrypts shell scripts 01

I. Introduction

Most of the time, our script involves some private information, such as the user name, password, or other important information. We use some encryption methods to block this information, ensure that the security of the system has the streamability of scripts. Generally, we only need to use the built-in gzexe tool.

II, Lab test started:

2.1 compile a script for testing [root @ woo ~] # Vi woo. sh #! /Bin/kshecho 'prudentwoo' ''' date + % Y-% m-% d' % t' uptime2. 2. Grant the executable permission and run [root @ woo ~] # Chmod + x woo. sh [root @ woo ~] #./Woo. shPrudentWoo 22:13:27 up 10 days, 22:13:27, 3 users, load average: 0.00, 0.01, 0.052.3 perform the gzexe encryption operation [root @ woo ~] # Gzexe woo. shwoo. sh: 11.5% [root @ woo ~] # Ll woo. s *-rwxr-xr-x 1 root 888 Dec 30 woo. sh-rwxr-xr-x 1 root 61 Dec 30 woo. sh ~ [Root @ woo ~] #2.4 encrypted file content [root @ woo ~] # Strings woo. sh #! /Bin/shskip = 44tab = ''nl = 'ifs = "$ tab $ nl" umask = 'umask 77 gztmpdir = trap 'res = $? Test-n "$ gztmpdir" & rm-fr "$ gztmpdir" (exit $ res ); exit $ res '0 1 2 3 5 10 13 15if type mktemp>/dev/null 2> & 1; then gztmpdir = 'mktemp-dt 'else gztmpdir =/tmp/gztmp $; mkdir $ gztmpdirfi |{( exit 127); exit 127 ;} gztmp = $ gztmpdir/$0 case $0 in-* | */* '') mkdir-p" $ gztmp "& rm-r" $ gztmp ";; */*) gztmp = $ gztmpdir/'basename "$0" '; esac ||{ (exit 127); exit 127 ;} case 'echo X | tail-n + 1 2>/dev/nul L 'tail') tail_n =-n; *) tail_n =; esacif tail $ tail_n + $ skip <"$0" | gzip-cd> "$ gztmp "; then umask $ umask chmod 700 "$ gztmp" (sleep 5; rm-fr "$ gztmpdir ") 2>/dev/null & "$ gztmp" ${1 + "$ @"}; res = $? Else echo> & 2 "Cannot decompress $0" (exit 127); res = deffi; exit $ reswoo. sh (* MIWWWPOHI, IU2.5 re-executes the encrypted file, and the output result is the same as [root @ woo ~] #./Woo. shPrudentWoo 22:17:22 up 10 days, 22:17:22, 3 users, load average: 0.00, 0.01, 0.05 [root @ woo ~] #2.6 perform the decryption operation: [root @ woo ~] # Gzexe-d woo. sh [root @ woo ~] # Cat woo. sh #! /Bin/kshecho 'prudentwoo' ''' date + % Y-% m-% d' % t' uptime [root @ woo ~] #2.7 confirm again that encryption and decryption are all feasible: [root @ woo ~] #./Woo. shPrudentWoo 22:19:50 up 10 days, 22:19:50, 3 users, load average: 0.00, 0.01, 0.05 [root @ woo ~] #


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.