Gzexe Help shell scripting encryption 01

Source: Internet
Author: User

Gzexe Help Shell Scripting Encryption on

First, Introduction

many times our script will involve some private information, such as: User name, password, or other important information, we use some encryption to block this information, to ensure that the security of the system has been scripted, usually we only need to bring through the system's own Gzexe This tool is enough.

Second, The experimental test begins :

 2.1 Writing a script for testing [[email protected] ~]# VI woo.sh#! /bin/kshecho ' Prudentwoo ' ' Date +%y-%m-%d '%T ' uptime2.2 gives executable permission and executes [[email protected] ~]# chmod +x woo.sh[[ Email protected] ~]#./woo.shprudentwoo 2014-12-30 22:13:27 22:13:27 up ten days, 23:03, 3 users, load average:0.00 , 0.01, 0.052.3 perform gzexe encryption operation [[[email protected] ~]# Gzexe woo.shwoo.sh:11.5%[[email protected] ~]# ll WOO.S*-RW Xr-xr-x 1 root root 888 Dec 22:15 woo.sh-rwxr-xr-x 1 root root Dec 22:11 woo.sh~[[email protected] ~] #2.4 Plus Secret file contents [[email protected] ~]# strings woo.sh#!/bin/shskip=44tab= ' nl= ' ifs= "$tab $nl" umask= ' umask ' umask  77gztmpdir=trap ' res=$? Test-n "$gztmpdir" && rm-fr "$gztmpdir" (Exit $res); Exit $res ' 0 1 2 3 5 15if type mktemp >/dev/null 2>&1; Then gztmpdir= ' mktemp-dt ' else gztmpdir=/tmp/gztmp$$; mkdir $gztmpdirfi | | {(exit 127); Exit 127;} gztmp= $gztmpdir/$0case $ in-* | */* ') mkdir-p "$gztmp" && rm-r "$gztmp";; */*)gztmp= $gztmpdir/' basename ' $ "';; Esac | | {(exit 127); Exit 127;} Case ' echo X | Tail-n +1 2>/dev/null ' InX) tail_n=-n;; *) tail_n=;; ESACIF tail $tail _n + $skip < "$ A" | GZIP-CD > "$gztmp"; Then umask $umask chmod "$gztmp" (Sleep 5; rm-fr "$gztmpdir") 2>/dev/null & "$gztmp" ${1+ "[Email prot Ected] "}; Res=$?else echo >&2 "Cannot decompress" (Exit 127); Res=127fi; Exit $reswoo. SH (*miwwwpohi,iu2.5 executes the encrypted file again, the output is the same [[email protected] ~]#./woo.shprudentwoo 2014-12-30 22:17:22 22:17:22 up ten days, 23:06, 3 users, load average:0.00, 0.01, 0.05[[email protected] ~] #2.6 Perform the decryption operation: [[EMAIL&NBSP;PR Otected] ~]# gzexe-d woo.sh[[email protected] ~]# cat woo.sh#! /bin/kshecho ' Prudentwoo ' ' Date +%y-%m-%d '%T ' uptime[[email protected] ~] #2.7 Confirm again, encryption and decryption are feasible:[[email  Protected] ~]#./woo.shprudentwoo 2014-12-30 22:19:50 22:19:50 up ten days, 23:09, 3 users, load average:0.00, 0.01, 0.0 5[[email protected] ~]#


Gzexe Help shell scripting encryption 01

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.