-
Notifications
You must be signed in to change notification settings - Fork 3
/
shc.html
138 lines (98 loc) · 3.71 KB
/
shc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<HTML>
<HEAD>
<TITLE>shc(1)</TITLE>
<link rel=stylesheet type="text/css" href="/css/osix.css">
</HEAD>
<BODY>
<H1>Manpage for shc(1)</H1>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->
</PRE>
<H2>NAME</H2><PRE>
shc - Generic shell script compiler
</PRE>
<H2>SYNOPSIS</H2><PRE>
shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ]
[ -l lopt ] [ -ACDhTv ] -f script
</PRE>
<H2>DESCRIPTION</H2><PRE>
shc creates a stripped binary executable version of the
script specified with -<I>f</I> on the command line.
The binary version will get a .<I>x</I> extension appended and will
usually be a bit larger in size than the original ascii
code. Generated C source code is saved in a file with the
extension .<I>x</I>.<I>c</I>
If you supply an expiration date with the -<I>e</I> option the com-
piled binary will refuse to run after the date specified.
The message "Please contact your provider" will be displayed
instead. This message can be changed with the -<I>m</I> option.
You can compile any kind of shell script, but you need to
supply valid -<I>i</I>, -<I>x</I> and -<I>l</I> options.
The compiled binary will still be dependent on the shell
specified in the first line of the shell code (i.e.
#!/bin/sh), thus shc does not create completely independent
binaries.
shc itself is not a compiler such as cc, it rather encodes
and encrypts a shell script and generates C source code with
the added expiration capability. It then uses the system
compiler to compile a stripped binary which behaves exactly
like the original script. Upon execution, the compiled
binary will decrypt and execute the code with the shell -<I>c</I>
option. Unfortunatelly, it will not give you any speed
improvement as a real C program would.
shc's main purpose is to protect your shell scripts from
modification or inspection. You can use it if you wish to
distribute your scripts but don't want them to be easily
readable by other people.
</PRE>
<H2>OPTIONS</H2><PRE>
The command line options are:
-e date
Expiration date in dd/mm/yyyy format [none]
-m message
message to display upon expiration ["Please contact
your provider"]
-f script_name
File name of the script to compile
-i inline_option
Inline option for the shell interpreter i.e: -e
-x comand
eXec command, as a printf format i.e:
exec(\\'%s\\',@ARGV);
-l last_option
Last shell option i.e: --
-r Relax security. Make a redistributable binary which
executes on different systems running the same operat-
ing system.
-v Verbose compilation
-D Switch on debug exec calls
-T Allow binary to be traceable (using strace, ptrace,
truss, etc.)
-C Display license and exit
-A Display abstract and exit
-h Display help and exit
</PRE>
<H2>ENVIRONMENT VARIABLES</H2><PRE>
CC C compiler command [cc]
CFLAGS
C compiler flags [none]
</PRE>
<H2>EXAMPLES</H2><PRE>
Compile a script which can be run on other systems with the
trace option enabled:
example% shc -v -r -T -f myscript
</PRE>
<H2>BUGS</H2><PRE>
The maximum size of the script that could be executed once com
piled is limited by the operating system configuration parameter
_SC_ARG_MAX (see <B>sysconf(2)</B>)
</PRE>
<H2>AUTHOR</H2><PRE>
Francisco Rosales <[email protected]>
</PRE>
<H2>REPORT BUGS TO</H2><PRE>
the author.
</PRE>
<P>
</BODY>
</HTML>