免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2560 | 回复: 6
打印 上一主题 下一主题

转:把一个shell程序编译成二进制可执行文件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-18 21:08 |只看该作者 |倒序浏览
或者是其他形式的可执行文件,只要无法查看程序内容就行.

但是,如果你仅仅是看不见内容就行了的话,不妨用

gzexe a.sh

原来的 a.sh 就被存为 a.sh~,新的 a.sh 是乱码,但是可以用 sh 的方式运行。

一、 如果在 C 程序用 system() 来运行,就一点意义都没有了,

因为 system 就是就是又开了一个shell进程,然后其内容也是shell -c "" 中的参数。你可以在命令行中测试:

system("ls -l") 就相当于
sh -c 'ls -l'

这应该能够解释为什么在C中会暴露所有源码的问题。


二、如果是用shell,就一定不可能存在保险的加密方法!

因为shell是一种解释性的语言,它必须能被读,被逐行被解释器读入,所以不管用了何种方式,最后都逃不掉必须还原为明文,明文还能被读这一过程,这就决定了shell源码不可能有有效加密方式的宿命。

比如有做同样一件事的两个程序

---x--x--x 1 jingyi stud 806 Jan 14 03:02 a.out
---x--x--x 1 jingyi stud 94 Dec 20 15:49 a.sh

a.out 为 C 的编译产物,而 a.sh 是 shell 程序。 它们都有执行位,但是 a.out 能被执行,但是 a.sh 则不行!原因就是 a.sh 缺了 -r 位。


三、在不能保证安全的情况下,敏感口令还是不要出现在shell程序中为好。很多程序为了安全,不但不出现在程序中,还不准出现在命令行中,特意做成交互式的。因为在命令行中,通过 history 或其它类似手段重现历史命令,非常不安全。


四、如果只是出于防范不太高手的内部用户,执行

gzexec a.sh

后,a.sh 中源码会看不见了。原来的文件被更名为 a.sh~ ,并且不需要了,你可以删除或存在其它地方。

这只是个变通的方式(只能称之为变通,不能称这为加密,因为学过一点shell编程的人就能很轻松地还原它),也许对不太 geek 的用户群中可以凑合用用。



希望以上解释对你和众多想加密shell的人有点帮助。

论坛徽章:
0
2 [报告]
发表于 2006-01-19 09:16 |只看该作者
晕,这个gzexeg弄完之后可以......用vim 可以直接查看地。

论坛徽章:
0
3 [报告]
发表于 2006-01-19 09:48 |只看该作者
gzexe在哪个系统平台,我的SCO系统怎么无此命令

论坛徽章:
0
4 [报告]
发表于 2006-01-19 12:37 |只看该作者
在Linux!!

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
5 [报告]
发表于 2006-01-19 13:26 |只看该作者
When not to use shell scripts
· Resource−intensive tasks, especially where speed is a factor (sorting, hashing, etc.)
Procedures involving heavy−duty math operations, especially floating point arithmetic, arbitrary
precision calculations, or complex numbers (use C++ or FORTRAN instead)
·
· Cross−platform portability required (use C or Java instead)
Complex applications, where structured programming is a necessity (need type−checking of variables,
function prototypes, etc.)
·
· Mission−critical applications upon which you are betting the ranch, or the future of the company
Situations where security is important, where you need to guarantee the integrity of your system and
protect against intrusion, cracking, and vandalism
·
· Project consists of subcomponents with interlocking dependencies
Extensive file operations required (Bash is limited to serial file access, and that only in a particularly
clumsy and inefficient line−by−line fashion)
·
· Need native support for multi−dimensional arrays
· Need data structures, such as linked lists or trees
· Need to generate or manipulate graphics or GUIs
· Need direct access to system hardware
· Need port or socket I/O
· Need to use libraries or interface with legacy code

From:ABS

论坛徽章:
0
6 [报告]
发表于 2006-01-19 18:41 |只看该作者
原帖由 寂寞烈火 于 2006-1-19 13:26 发表

From:ABS


都是些什么呀,看不懂!

论坛徽章:
0
7 [报告]
发表于 2008-09-26 14:36 |只看该作者
谢谢了  这样也不错...  shc 使用起来不知道为什么  crontab不太支持
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP