首页 > 其他 > 详细

使用shc简单加密后的脚本文件恢复

时间:2014-02-26 04:04:45      阅读:1466      评论:0      收藏:0      [点我收藏+]

现学现用,写了个解密shc加密脚本的脚本:

#!/bin/sh
##############################################################
# Used to unzip script files generated by shc                #
# Created by cuterhei at 2014-02-25                          #
##############################################################

function uncomp_shc()
{
    skip=0
    skl_f="none"
    while read skip_line
    do
        skipstrlist=$(echo $skip_line|tr "=" "\n")
        for xs in $skipstrlist; do
            let "skip += 1"
            if [ "$xs" = "skip" ]; then
                skl_f="find"
            elif [ "$skl_f" = "find" ]; then
               skip="$xs"
               skl_f="succ"
               break
            elif [ $skip -eq 2 ]; then
               skl_f="failed"
               break
            fi
        done
        if [ "$skl_f" = "succ" -o  "$skl_f" = "failed" ]; then
            break
        fi
    done < "$1"

    if [ "$skl_f" = "succ" ]; then
        if tail -n +"$skip" "$1" | gzip -cd > "$2"; then
            echo "Unzip $1 to $2 with skip=$skip successfully."
        else
            echo "Unzip $1 with skip=$skip failed."
        fi
    else
        echo "Skip flag not found in file $1"
    fi
}

if [ "$#" = "0" ]; then
    echo "  Used to unzip script file generated by shc."
    echo "  Usage:"
    echo "    1. shcd inputfile "
    echo "    2. shcd inputfile outputfile "
    echo "    3. shcd -all "
elif [ -f $1 ]; then
    if [ "$#" = "2" ]; then
        uncomp_shc "$1" "$2"
    else
        uncomp_shc "$1" "$1.bat"
    fi
elif [ "$1" = "-all" ]; then
    for file in ./*
    do
        if [ -f $file ]; then
            uncomp_shc $file "$file.bat"
        fi
    done
else
    echo "File $1 is not exist."
fi

exit

使用shc简单加密后的脚本文件恢复

原文:http://blog.csdn.net/cuterhei/article/details/19926425

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!