免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: GM
打印 上一主题 下一主题

红袖添香:续问.......!!!!! [复制链接]

论坛徽章:
0
41 [报告]
发表于 2003-02-24 21:50 |只看该作者

红袖添香:续问.......!!!!!

红袖兄:
      好!
这个gzexec是不是gzip压缩软件中的一个应用程序,要是这样我要装一下试试!!!
还有
被gzexec执行过的shell文件,此文件能执行,但如原文件file.sh~丢了,
能把执行的shell文件再用什么方法能转换成原文件吗 ????

论坛徽章:
0
42 [报告]
发表于 2003-02-24 23:29 |只看该作者

红袖添香:续问.......!!!!!

...

具体 gzexe 是不是 gzip 的一部分不是很清楚,反正我是没有特意装过它。在 GNU 的网站也只有 gzip 而没有 gzexe,估计应该是包含在 gzip 中的。

举例说吧,我有一个 a.sh

  1. netstat -n | awk ' /^tcp.*(ESTABLISHED|WAIT|LISTEN)/ { print $5}' | awk -F. '{
  2.   ip = $1"."$2"."$3"."$4
  3.   ipg[ip]
  4.   if ( ip in ipg ) num[ip]++
  5. }
  6. END { for ( i in num )
  7.   if ( num[i] >= 1 ) printf " %-15s %3s\n", i, num[i]
  8. }'
复制代码


# gzexe a.sh
a.sh            25.0%
#

然后看一下 a.sh 的内容,

  1. #!/bin/sh
  2. skip=14
  3. tmpdir=`/usr/bin/mktemp -d /tmp/gzexeXXXXXXXXXX` || exit 1
  4. prog="${tmpdir}/`echo \"$0\" | sed 's|^.*/||'`"
  5. if /usr/bin/tail +$skip "$0" | gzip -cd > "$prog"; then
  6.   chmod 700 "$prog"
  7.   trap '/bin/rm -rf $tmpdir exit $res' 0
  8.   "$prog" ${1+"$@"}; res=$?
  9. else
  10.   echo Cannot decompress $0
  11.   rm -rf $tmpdir
  12.   exit 1
  13. fi; exit $res
  14. ^_~K^H^Hd0Z>^B^Ca.sh^@5~NM^K~B@^X~D??+^FQ?ü???~A?~Q^P^^T:~T~AD?^Rm?^[^]?????e^Xf
  15. ~^á}?~U÷??p^XF??;txg~i?~E~Q^Ve??g?.M?C~\~U??e~Z~[^^^F?^]e^\j8é?~Y?u?^O ^@m^QA?^U
  16. WQ~WR^B)?os;??~Zm^CC~R~T?^T&??!;?^B~Y@?<^QG~Zg')        ~IZ@?á^LWXG?E:??@~A??a^O
  17. -èOL±Aí?G&~]|^@???Yè^@^@^@
复制代码


真正的程序部分是下面的乱码。解开的办法就是上面的几行程序,应该很简单吧。

(你在这问得这么详细,不怕你们单位的人也在这儿~ ,呵呵~ )

论坛徽章:
0
43 [报告]
发表于 2003-02-26 12:42 |只看该作者

红袖添香:续问.......!!!!!

原帖由 "红袖添香" 发表:

(你在这问得这么详细,不怕你们单位的人也在这儿~ ,呵呵~ )


呵呵,这到不怕,因为我们单位没有gzexec,我现在有点明白了,关于这个应用问题!!!
也就是shell程序用gzexec之后,在应用时这个gzexec还有用,不能删,是吧!
还有
gzip压缩程序中,我查过了好象没有这gzexec,这个东东你是怎么得到的?
还有这个东东是不是只要这一个就能应用,如果这样能不能送给我一个用用,我的邮箱是:
g2003m@163.com
谢谢你的帮助,我这个人有点烦,让你麻烦了,呵呵!!!!

论坛徽章:
0
44 [报告]
发表于 2003-02-26 22:54 |只看该作者

红袖添香:续问.......!!!!!

...

hoho,我好笨!今天才发现原来那个gzexe是个脚本,呵呵。

这是 Solaris8 下的版本:

  1. #!/bin/sh
  2. # gzexe: compressor for Unix executables.
  3. # Use this only for binaries that you do not use frequently.
  4. #
  5. # The compressed version is a shell script which decompresses itself after
  6. # skipping $skip lines of shell commands.  We try invoking the compressed
  7. # executable with the original name (for programs looking at their name).
  8. # We also try to retain the original file permissions on the compressed file.
  9. # For safety reasons, gzexe will not create setuid or setgid shell scripts.

  10. # WARNING: the first line of this file must be either : or #!/bin/sh
  11. # The : is required for some old versions of csh.
  12. # On Ultrix, /bin/sh is too buggy, change the first line to: #!/bin/sh5

  13. x=`basename $0`
  14. if test $# = 0; then
  15.   echo compress executables. original file foo is renamed to foo~
  16.   echo usage: ${x} [-d] files...
  17.   echo   "   -d  decompress the executables"
  18.   exit 1
  19. fi

  20. tmp=gz$$
  21. trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15

  22. decomp=0
  23. res=0
  24. test "$x" = "ungzexe" && decomp=1
  25. if test "x$1" = "x-d"; then
  26.   decomp=1
  27.   shift
  28. fi

  29. echo hi > zfoo1$$
  30. echo hi > zfoo2$$
  31. if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then
  32.   cpmod=${CPMOD-cpmod}
  33. fi
  34. rm -f zfoo[12]$$

  35. tail=""
  36. IFS="${IFS=         }"; saveifs="$IFS"; IFS="${IFS}:"
  37. for dir in $PATH; do
  38.   test -z "$dir" && dir=.
  39.   if test -f $dir/tail; then
  40.     tail="$dir/tail"
  41.     break
  42.   fi
  43. done
  44. IFS="$saveifs"
  45. if test -z "$tail"; then
  46.   echo cannot find tail
  47.   exit 1
  48. fi

  49. for i do
  50.   if test ! -f "$i" ; then
  51.     echo ${x}: $i not a file
  52.     res=1
  53.     continue
  54.   fi
  55.   if test $decomp -eq 0; then
  56.     if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
  57.       echo "${x}: $i is already gzexe'd"
  58.       continue
  59.     fi
  60.   fi
  61.   if ls -l "$i" | grep '^...[sS]' > /dev/null; then
  62.     echo "${x}: $i has setuid permission, unchanged"
  63.     continue
  64.   fi
  65.   if ls -l "$i" | grep '^......[sS]' > /dev/null; then
  66.     echo "${x}: $i has setgid permission, unchanged"
  67.     continue
  68.   fi
  69.   case "`basename $i`" in
  70.   gzip | tail | chmod | ln | sleep | rm)
  71.         echo "${x}: $i would depend on itself"; continue ;;
  72.   esac
  73.   if test -z "$cpmod"; then
  74.     cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp
  75.     if test -w $tmp 2>/dev/null; then
  76.       writable=1
  77.     else
  78.       writable=0
  79.       chmod u+w $tmp 2>/dev/null
  80.     fi
  81.   fi
  82.   if test $decomp -eq 0; then
  83.     sed 1q $0 > $tmp
  84.     sed "s|^if tail|if $tail|" >> $tmp <<'EOF'
  85. skip=18
  86. if tail +$skip $0 | "/usr/bin"/gzip -cd > /tmp/gztmp$$; then
  87.   /bin/chmod 700 /tmp/gztmp$$
  88.   prog="`echo $0 | /bin/sed 's|^.*/||'`"
  89.   if /bin/ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then
  90.     trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0
  91.     (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null &
  92.     /tmp/"$prog" ${1+"$@"}; res=$?
  93.   else
  94.     trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0
  95.     (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null &
  96.     /tmp/gztmp$$ ${1+"$@"}; res=$?
  97.   fi
  98. else
  99.   echo Cannot decompress $0; exit 1
  100. fi; exit $res
  101. EOF
  102.     "/usr/bin"/gzip -cv9 "$i" >> $tmp || {
  103.       /bin/rm -f $tmp
  104.       echo ${x}: compression not possible for $i, file unchanged.
  105.       res=1
  106.       continue
  107.     }

  108.   else
  109.     # decompression
  110.     skip=18
  111.     if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
  112.       eval `sed -e 1d -e 2q "$i"`
  113.     fi
  114.     if tail +$skip "$i" | "/usr/bin"/gzip -cd > $tmp; then
  115.       :
  116.     else
  117.       echo ${x}: $i probably not in gzexe format, file unchanged.
  118.       res=1
  119.       continue
  120.     fi
  121.   fi
  122.   rm -f "$i~"
  123.   mv "$i" "$i~" || {
  124.     echo ${x}: cannot backup $i as $i~
  125.     rm -f $tmp
  126.     res=1
  127.     continue
  128.   }
  129.   mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || {
  130.     echo ${x}: cannot create $i
  131.     rm -f $tmp
  132.     res=1
  133.     continue
  134.   }
  135.   rm -f $tmp
  136.   if test -n "$cpmod"; then
  137.     $cpmod "$i~" "$i" 2>/dev/null
  138.   elif test $writable -eq 0; then
  139.     chmod u-w $i 2>/dev/null
  140.   fi
  141. done
  142. exit $res
复制代码

论坛徽章:
0
45 [报告]
发表于 2003-02-26 22:58 |只看该作者

红袖添香:续问.......!!!!!

...

你看看哪个能用用哪个吧~

这是OpenBSD3.1下的版本:

  1. #!/bin/sh
  2. # gzexe: compressor for Unix executables.
  3. # Use this only for binaries that you do not use frequently.
  4. #
  5. # The compressed version is a shell script which decompresses itself after
  6. # skipping $skip lines of shell commands.  We try invoking the compressed
  7. # executable with the original name (for programs looking at their name).
  8. # We also try to retain the original file permissions on the compressed file.
  9. # For safety reasons, gzexe will not create setuid or setgid shell scripts.

  10. # WARNING: the first line of this file must be either : or #!/bin/sh
  11. # The : is required for some old versions of csh.
  12. # On Ultrix, /bin/sh is too buggy, change the first line to: #!/bin/sh5
  13. #
  14. # $OpenBSD: gzexe,v 1.6 2001/09/29 01:13:16 millert Exp $

  15. x=`basename "$0"`
  16. if test $# = 0; then
  17.   echo compress executables. original file foo is renamed to foo~
  18.   echo usage: ${x} [-d] files...
  19.   echo   "   -d  decompress the executables"
  20.   exit 1
  21. fi

  22. decomp=0
  23. res=0
  24. test "$x" = "ungzexe" && decomp=1
  25. if test "x$1" = "x-d"; then
  26.   decomp=1
  27.   shift
  28. fi

  29. tail=""
  30. IFS="${IFS=         }"; saveifs="$IFS"; IFS="${IFS}:"
  31. for dir in $PATH; do
  32.   test -z "$dir" && dir=.
  33.   if test -f $dir/tail; then
  34.     tail="$dir/tail"
  35.     break
  36.   fi
  37. done
  38. IFS="$saveifs"
  39. if test -z "$tail"; then
  40.   echo cannot find tail
  41.   exit 1
  42. fi

  43. for i do
  44.   if test ! -f "$i" ; then
  45.     echo ${x}: $i not a file
  46.     res=1
  47.     continue
  48.   fi
  49.   if test $decomp -eq 0; then
  50.     if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
  51.       echo "${x}: $i is already gzexe'd"
  52.       continue
  53.     fi
  54.   fi
  55.   if ls -l "$i" | grep '^...[sS]' > /dev/null; then
  56.     echo "${x}: $i has setuid permission, unchanged"
  57.     continue
  58.   fi
  59.   if ls -l "$i" | grep '^......[sS]' > /dev/null; then
  60.     echo "${x}: $i has setgid permission, unchanged"
  61.     continue
  62.   fi
  63.   case "`basename $i`" in
  64.   sh | gzip | tail | chmod | ln | sleep | rm | sed | mktemp)
  65.         echo "${x}: $i would depend on itself"; continue ;;
  66.   esac

  67.   tmp=`/usr/bin/mktemp gzXXXXXXXXXX` || exit 1
  68.   trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15

  69.   cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp
  70.   if test -w $tmp 2>/dev/null; then
  71.     writable=1
  72.   else
  73.     writable=0
  74.     chmod u+w $tmp 2>/dev/null
  75.   fi
  76.   if test $decomp -eq 0; then
  77.     sed 1q "$0" > $tmp
  78.     sed "s|^if tail|if $tail|" >> $tmp <<'EOF'
  79. skip=14
  80. tmpdir=`/usr/bin/mktemp -d /tmp/gzexeXXXXXXXXXX` || exit 1
  81. prog="${tmpdir}/`echo \"$0\" | sed 's|^.*/||'`"
  82. if tail +$skip "$0" | gzip -cd > "$prog"; then
  83.   chmod 700 "$prog"
  84.   trap '/bin/rm -rf $tmpdir exit $res' 0
  85.   "$prog" ${1+"$@"}; res=$?
  86. else
  87.   echo Cannot decompress $0
  88.   rm -rf $tmpdir
  89.   exit 1
  90. fi; exit $res
  91. EOF
  92.     gzip -cv9 "$i" >> $tmp || {
  93.       /bin/rm -f $tmp
  94.       echo ${x}: compression not possible for $i, file unchanged.
  95.       res=1
  96.       continue
  97.     }

  98.   else
  99.     # decompression
  100.     skip=18
  101.     if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then
  102.       eval `sed -e 1d -e 2q "$i"`
  103.     fi
  104.     if tail +$skip "$i" | gzip -cd > $tmp; then
  105.       :
  106.     else
  107.       echo ${x}: $i probably not in gzexe format, file unchanged.
  108.       /bin/rm -f $tmp
  109.       res=1
  110.       continue
  111.     fi
  112.   fi
  113.   rm -f "$i~"
  114.   mv "$i" "$i~" || {
  115.     echo ${x}: cannot backup $i as $i~
  116.     /bin/rm -f $tmp
  117.     res=1
  118.     continue
  119.   }
  120.   mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || {
  121.     echo ${x}: cannot create $i
  122.     /bin/rm -f $tmp
  123.     res=1
  124.     continue
  125.   }
  126.   /bin/rm -f $tmp
  127.   if test $writable -eq 0; then
  128.     chmod u-w $i 2>/dev/null
  129.   fi
  130. done
  131. exit $res
复制代码

论坛徽章:
0
46 [报告]
发表于 2003-02-28 18:57 |只看该作者

红袖添香:续问.......!!!!!

红(兄)姐:
你好!!!
我首先要问你叫你姐好呢,还是叫你兄好呢,别人大多叫你姐,我以前叫你兄的,不好意思啊!!但不管你是女的还是男的,你总是一如既往地帮助大家,使我们受益非浅,谢谢了!!!!
对了,我又要言规正转了,你给我的两个脚本,我使用时好象有点问题,如出现以下情况:
gzexec bb.sh
./gzexec: syntax error at line 151: `end of file' unexpected
不知何解呢???

论坛徽章:
0
47 [报告]
发表于 2003-03-01 01:36 |只看该作者

红袖添香:续问.......!!!!!

...

呵呵,没关系,“XX兄”听起来也不错。其实叫红袖就好了,还可以少打一个字哦~

脚本为什么会在你那就不运行,看上去少了点什么,开头我也很纳闷。后来我自己从我自己的帖子上 copy &amp; paste 做了一个试试,果真如此。很费解,后来查出了原因,我晕晕晕~~~

原来问题出在第 108 行,在拷贝的过程中 EOF 后面会产生一个空格!因为这个空格,造成了和前面的语句不配对了,除掉这个多余的空格就好了。

论坛徽章:
0
48 [报告]
发表于 2003-03-01 10:34 |只看该作者

红袖添香:续问.......!!!!!

请问GM兄在哪家银行啊?

论坛徽章:
0
49 [报告]
发表于 2003-03-01 10:59 |只看该作者

红袖添香:续问.......!!!!!

[quote]原帖由 "GM"]sco中也没有 ping -f 参数的!!![/quote 发表:


老兄,您可能搞错了,sco中ping 命令有-f的参数。虽然参数表中没有显示,
直接Ping -f 也不行,但是用ping -c1 -f ip的确可行!!!

论坛徽章:
0
50 [报告]
发表于 2003-03-02 12:50 |只看该作者

红袖添香:续问.......!!!!!

[quote]原帖由 "凝嫣"]请问GM兄在哪家银行啊?但是用ping -c1 -f ip的确可行!!! [/quote 发表:

呵,我是商业银行的!!!
ping -c1 -f ip在sco中到是行,但没有达到我们在前面讨论中的功能:
如:在ping的机子在通的情况下,可行,但也没有加上-f的必要。
但在没通的情况下,加上-f后,反而不会停下来了,还是不加上为好。
我们在上面讨论的是,要在限止一定的时间内,不论通与不通马上得退出来,可以后面的工作,以达到工作的效率。但总之也要谢谢关心对我们的话题!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP