Skip to content

Commit 3a04fd7

Browse files
committed
update man
1 parent 5ccc981 commit 3a04fd7

File tree

3 files changed

+419
-105
lines changed

3 files changed

+419
-105
lines changed

man.html

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<meta http-equiv="Content-Style-Type" content="text/css" />
6+
<meta name="generator" content="pandoc" />
7+
<meta name="date" content="2017-05-17" />
8+
<title>shc(1) shc user manual</title>
9+
<style type="text/css">code{white-space: pre;}</style>
10+
<style type="text/css">
11+
div.sourceCode { overflow-x: auto; }
12+
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
13+
margin: 0; padding: 0; vertical-align: baseline; border: none; }
14+
table.sourceCode { width: 100%; line-height: 100%; }
15+
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
16+
td.sourceCode { padding-left: 5px; }
17+
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
18+
code > span.dt { color: #902000; } /* DataType */
19+
code > span.dv { color: #40a070; } /* DecVal */
20+
code > span.bn { color: #40a070; } /* BaseN */
21+
code > span.fl { color: #40a070; } /* Float */
22+
code > span.ch { color: #4070a0; } /* Char */
23+
code > span.st { color: #4070a0; } /* String */
24+
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
25+
code > span.ot { color: #007020; } /* Other */
26+
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
27+
code > span.fu { color: #06287e; } /* Function */
28+
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
29+
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
30+
code > span.cn { color: #880000; } /* Constant */
31+
code > span.sc { color: #4070a0; } /* SpecialChar */
32+
code > span.vs { color: #4070a0; } /* VerbatimString */
33+
code > span.ss { color: #bb6688; } /* SpecialString */
34+
code > span.im { } /* Import */
35+
code > span.va { color: #19177c; } /* Variable */
36+
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
37+
code > span.op { color: #666666; } /* Operator */
38+
code > span.bu { } /* BuiltIn */
39+
code > span.ex { } /* Extension */
40+
code > span.pp { color: #bc7a00; } /* Preprocessor */
41+
code > span.at { color: #7d9029; } /* Attribute */
42+
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
43+
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
44+
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
45+
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
46+
</style>
47+
</head>
48+
<body>
49+
<div id="header">
50+
<h1 class="title">shc(1) shc user manual</h1>
51+
<h3 class="date">May 17, 2017</h3>
52+
</div>
53+
<hr>
54+
<h1 id="name">NAME</h1>
55+
<p>shc - Generic shell script compiler</p>
56+
<h1 id="synopsis">SYNOPSIS</h1>
57+
<p><strong>shc</strong> [ -e <em>date</em> ] [ -m <em>addr</em> ] [ -i <em>iopt</em> ] [ -x <em>cmnd</em> ] [ -l <em>lopt</em> ] [ -o <em>outfile</em> ] [ -ABCDhUv ] -f <em>script</em></p>
58+
<h1 id="description">DESCRIPTION</h1>
59+
<p><strong>shc</strong> creates a stripped binary executable version of the script specified with <code>-f</code> on the command line.</p>
60+
<p>The binary version will get a <code>.x</code> extension appended by default if <em>outfile</em> is not defined with [-o <em>outfile</em>] option 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 <code>.x.c</code> or in a file specified with appropriate option.</p>
61+
<p>If you supply an expiration date with the <code>-e</code> option, the compiled binary will refuse to run after the date specified. The message <strong>Please contact your provider</strong> will be displayed instead. This message can be changed with the <code>-m</code> option.</p>
62+
<p>You can compile any kind of shell script, but you need to supply valid <code>-i</code>, <code>-x</code> and <code>-l</code> options.</p>
63+
<p>The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e. <code>#!/bin/sh</code>), thus <strong>shc</strong> does not create completely independent binaries.</p>
64+
<p><strong>shc</strong> 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 <code>-c</code> option. Unfortunatelly, it will not give you any speed improvement as a real C program would.</p>
65+
<p><strong>shc</strong>'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.</p>
66+
<h1 id="options">OPTIONS</h1>
67+
<dl>
68+
<dt>-e <em>date</em></dt>
69+
<dd>Expiration date in <em>dd/mm/yyyy</em> format <code>[none]</code>
70+
</dd>
71+
<dt>-m <em>message</em></dt>
72+
<dd>message to display upon expiration <code>[&quot;Please contact your provider&quot;]</code>
73+
</dd>
74+
<dt>-f <em>script_name</em></dt>
75+
<dd>File path of the script to compile
76+
</dd>
77+
<dt>-i <em>inline_option</em></dt>
78+
<dd>Inline option for the shell interpreter i.e: <code>-e</code>
79+
</dd>
80+
<dt>-x <em>command</em></dt>
81+
<dd>eXec command, as a printf format i.e: <code>exec(\\'%s\\',@ARGV);</code>
82+
</dd>
83+
<dt>-l <em>last_option</em></dt>
84+
<dd>Last shell option i.e: <code>--</code>
85+
</dd>
86+
<dt>-o <em>outfile</em></dt>
87+
<dd>output to the file specified by outfile
88+
</dd>
89+
<dt>-r</dt>
90+
<dd>Relax security. Make a redistributable binary which executes on different systems running the same operating system. You can release your binary with this option for others to use
91+
</dd>
92+
<dt>-v</dt>
93+
<dd>Verbose compilation
94+
</dd>
95+
<dt>-D</dt>
96+
<dd>Switch on debug exec calls
97+
</dd>
98+
<dt>-U</dt>
99+
<dd>Make binary to be untraceable (using <em>strace</em>, <em>ptrace</em>, <em>truss</em>, etc.)
100+
</dd>
101+
<dt>-C</dt>
102+
<dd>Display license and exit
103+
</dd>
104+
<dt>-A</dt>
105+
<dd>Display abstract and exit
106+
</dd>
107+
<dt>-B</dt>
108+
<dd>Compile for BusyBox
109+
</dd>
110+
<dt>-h</dt>
111+
<dd>Display help and exit
112+
</dd>
113+
</dl>
114+
<h1 id="environment-variables">ENVIRONMENT VARIABLES</h1>
115+
<dl>
116+
<dt>CC</dt>
117+
<dd>C compiler command <code>[cc]</code>
118+
</dd>
119+
<dt>CFLAGS</dt>
120+
<dd>C compiler flags <code>[none]</code>
121+
</dd>
122+
</dl>
123+
<h1 id="examples">EXAMPLES</h1>
124+
<p>Compile a script which can be run on other systems with the trace option enabled (without <code>-U</code> flag):</p>
125+
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -f myscript -o mybinary</code></pre></div>
126+
<p>Compile an untraceable binary:</p>
127+
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -Uf myscript -o mybinary</code></pre></div>
128+
<h1 id="bugs">BUGS</h1>
129+
<p>The maximum size of the script that could be executed once compiled is limited by the operating system configuration parameter <code>_SC_ARG_MAX</code> (see sysconf(2))</p>
130+
<h1 id="authors">AUTHORS</h1>
131+
<p>Francisco Rosales <script type="text/javascript">
132+
<!--
133+
h='&#102;&#x69;&#46;&#x75;&#112;&#x6d;&#46;&#x65;&#x73;';a='&#64;';n='&#102;&#114;&#x6f;&#x73;&#x61;&#108;';e=n+a+h;
134+
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
135+
// -->
136+
</script><noscript>&#102;&#114;&#x6f;&#x73;&#x61;&#108;&#32;&#x61;&#116;&#32;&#102;&#x69;&#32;&#100;&#x6f;&#116;&#32;&#x75;&#112;&#x6d;&#32;&#100;&#x6f;&#116;&#32;&#x65;&#x73;</noscript></p>
137+
<p>Md Jahidul Hamid <script type="text/javascript">
138+
<!--
139+
h='&#x79;&#x61;&#104;&#x6f;&#x6f;&#46;&#x63;&#x6f;&#x6d;';a='&#64;';n='&#106;&#x61;&#104;&#x69;&#100;&#x75;&#108;&#104;&#x61;&#x6d;&#x69;&#100;';e=n+a+h;
140+
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
141+
// -->
142+
</script><noscript>&#106;&#x61;&#104;&#x69;&#100;&#x75;&#108;&#104;&#x61;&#x6d;&#x69;&#100;&#32;&#x61;&#116;&#32;&#x79;&#x61;&#104;&#x6f;&#x6f;&#32;&#100;&#x6f;&#116;&#32;&#x63;&#x6f;&#x6d;</noscript></p>
143+
<h1 id="report-bugs-to">REPORT BUGS TO</h1>
144+
<p><a href="https://github.com/neurobin/shc/issues" class="uri">https://github.com/neurobin/shc/issues</a></p>
145+
</body>
146+
</html>

man.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
% shc(1) shc user manual
2+
%
3+
% May 17, 2017
4+
<hr>
5+
6+
# NAME
7+
shc - Generic shell script compiler
8+
9+
# SYNOPSIS
10+
**shc** [ -e *date* ] [ -m *addr* ] [ -i *iopt* ] [ -x *cmnd* ] [ -l *lopt* ] [ -o *outfile* ] [ -ABCDhUv ] -f *script*
11+
12+
# DESCRIPTION
13+
**shc** creates a stripped binary executable version of the script specified with `-f` on the command line.
14+
15+
The binary version will get a `.x` extension appended by default if *outfile* is not defined with [-o *outfile*] option
16+
and will usually be a bit larger in size than the original ascii code.
17+
Generated C source code is saved in a file with the extension `.x.c` or in a file specified with appropriate option.
18+
19+
If you supply an expiration date with the `-e` option, the compiled binary will refuse to run after the date specified.
20+
The message **Please contact your provider** will be displayed instead. This message can be changed with the `-m` option.
21+
22+
You can compile any kind of shell script, but you need to supply valid `-i`, `-x` and `-l` options.
23+
24+
The compiled binary will still be dependent on the shell specified in the first line of the shell code (i.e. `#!/bin/sh`),
25+
thus **shc** does not create completely independent binaries.
26+
27+
**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.
28+
It then uses the system compiler to compile a stripped binary which behaves exactly like the original script.
29+
Upon execution, the compiled binary will decrypt and execute the code with the shell `-c` option.
30+
Unfortunatelly, it will not give you any speed improvement as a real C program would.
31+
32+
**shc**'s main purpose is to protect your shell scripts from modification or inspection.
33+
You can use it if you wish to distribute your scripts but don't want them to be easily readable by other people.
34+
35+
# OPTIONS
36+
37+
-e *date*
38+
: Expiration date in *dd/mm/yyyy* format `[none]`
39+
40+
-m *message*
41+
: message to display upon expiration `["Please contact your provider"]`
42+
43+
-f *script_name*
44+
: File path of the script to compile
45+
46+
-i *inline_option*
47+
: Inline option for the shell interpreter i.e: `-e`
48+
49+
-x *command*
50+
: eXec command, as a printf format i.e: `exec(\\'%s\\',@ARGV);`
51+
52+
-l *last_option*
53+
: Last shell option i.e: `--`
54+
55+
-o *outfile*
56+
: output to the file specified by outfile
57+
58+
-r
59+
: Relax security. Make a redistributable binary which executes on different systems running the same operating system. You can release your binary with this option for others to use
60+
61+
-v
62+
: Verbose compilation
63+
64+
-D
65+
: Switch on debug exec calls
66+
67+
-U
68+
: Make binary to be untraceable (using *strace*, *ptrace*, *truss*, etc.)
69+
70+
-C
71+
: Display license and exit
72+
73+
-A
74+
: Display abstract and exit
75+
76+
-B
77+
: Compile for BusyBox
78+
79+
-h
80+
: Display help and exit
81+
82+
83+
# ENVIRONMENT VARIABLES
84+
85+
CC
86+
: C compiler command `[cc]`
87+
88+
CFLAGS
89+
: C compiler flags `[none]`
90+
91+
92+
# EXAMPLES
93+
94+
Compile a script which can be run on other systems with the trace option enabled (without `-U` flag):
95+
96+
```bash
97+
shc -f myscript -o mybinary
98+
```
99+
100+
Compile an untraceable binary:
101+
102+
```bash
103+
shc -Uf myscript -o mybinary
104+
```
105+
106+
107+
# BUGS
108+
The maximum size of the script that could be executed once compiled is limited by the operating system configuration parameter `_SC_ARG_MAX` (see sysconf(2))
109+
110+
# AUTHORS
111+
Francisco Rosales <frosal@fi.upm.es>
112+
113+
Md Jahidul Hamid <jahidulhamid@yahoo.com>
114+
115+
# REPORT BUGS TO
116+
<https://github.com/neurobin/shc/issues>
117+

0 commit comments

Comments
 (0)