Skip to content

Commit

Permalink
Merge pull request neurobin#70 from mathieu-aubin/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
neurobin authored Jan 27, 2019
2 parents e86b16c + c868244 commit d5d1b89
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 222 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
src/.deps
src/shc
src/shc.o
*Makefile
config.status
/build
/autom4te.cache
*.scan
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ make
make check
```

## Known bugs
## Known limitations

The one (and I hope the only) limitation using shc is the _SC_ARG_MAX system configuration parameter.
It limits the maximum length of the arguments to the exec function, limiting the maximum length of the runnable script of shc.
Expand Down
161 changes: 53 additions & 108 deletions man.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,36 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<meta name="author" content="" />
<meta name="date" content="2018-11-20" />
<meta name="date" content="2019-01-14" />
<title>shc(1) shc user manual</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code > span.kw { color: #007020; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #40a070; }
code > span.fl { color: #40a070; }
code > span.ch { color: #4070a0; }
code > span.st { color: #4070a0; }
code > span.co { color: #60a0b0; font-style: italic; }
code > span.ot { color: #007020; }
code > span.al { color: #ff0000; font-weight: bold; }
code > span.fu { color: #06287e; }
code > span.er { color: #ff0000; font-weight: bold; }
</style>
</head>
<body>
<div id="header">
<h1 class="title">shc(1) shc user manual</h1>
<h2 class="author"></h2>
<h3 class="date">November 20, 2018</h3>
<h3 class="date">January 14, 2019</h3>
</div>
<hr>

<h1 id="name">NAME</h1>
<p>shc - Generic shell script compiler</p>
<h1 id="synopsis">SYNOPSIS</h1>
Expand All @@ -66,87 +47,51 @@ <h1 id="description">DESCRIPTION</h1>
<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>
<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>
<h1 id="options">OPTIONS</h1>
<dl>
<dt>-e <em>date</em></dt>
<dd>Expiration date in <em>dd/mm/yyyy</em> format <code>[none]</code>
</dd>
<dt>-m <em>message</em></dt>
<dd>message to display upon expiration <code>[&quot;Please contact your provider&quot;]</code>
</dd>
<dt>-f <em>script_name</em></dt>
<dd>File path of the script to compile
</dd>
<dt>-i <em>inline_option</em></dt>
<dd>Inline option for the shell interpreter i.e: <code>-e</code>
</dd>
<dt>-x <em>command</em></dt>
<dd>eXec command, as a printf format i.e: <code>exec(\\'%s\\',@ARGV);</code>
</dd>
<dt>-l <em>last_option</em></dt>
<dd>Last shell option i.e: <code>--</code>
</dd>
<dt>-o <em>outfile</em></dt>
<dd>output to the file specified by outfile
</dd>
<dt>-r</dt>
<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
</dd>
<dt>-v</dt>
<dd>Verbose compilation
</dd>
<dt>-S</dt>
<dd>Switch ON setuid for root callable programs [OFF]
</dd>
<dt>-D</dt>
<dd>Switch on debug exec calls
</dd>
<dt>-U</dt>
<dd>Make binary to be untraceable (using <em>strace</em>, <em>ptrace</em>, <em>truss</em>, etc.)
</dd>
<dt>-H</dt>
<dd>Hardening. Extra security flag without root access requirement that protects against dumping, code injection, <code>cat /proc/pid/cmdline</code>, ptrace, etc.. This feature is <strong>experimental</strong> and may not work on all systems. This option currently only works with Bourne shell (sh) scripts without any positional parameters.
</dd>
<dt>-s</dt>
<dd>Hardening with single process. Requires -H option, runs the binary in a single process, shell is called in the main process otherwise its called in a child process. This feature is <strong>experimental</strong> (may hang) and may not work on all systems. This option currently only works with Bourne shell (sh) scripts without any positional parameters.
</dd>
<dt>-C</dt>
<dd>Display license and exit
</dd>
<dt>-A</dt>
<dd>Display abstract and exit
</dd>
<dt>-B</dt>
<dd>Compile for BusyBox
</dd>
<dt>-h</dt>
<dd>Display help and exit
</dd>
</dl>
<p>-e <em>date</em> : Expiration date in <em>dd/mm/yyyy</em> format <code>[none]</code></p>
<p>-m <em>message</em> : message to display upon expiration <code>[&quot;Please contact your provider&quot;]</code></p>
<p>-f <em>script_name</em> : File path of the script to compile</p>
<p>-i <em>inline_option</em> : Inline option for the shell interpreter i.e: <code>-e</code></p>
<p>-x <em>command</em> : eXec command, as a printf format i.e: <code>exec(\\'%s\\',@ARGV);</code></p>
<p>-l <em>last_option</em> : Last shell option i.e: <code>--</code></p>
<p>-o <em>outfile</em> : output to the file specified by outfile</p>
<p>-r : 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</p>
<p>-v : Verbose compilation</p>
<p>-S : Switch ON setuid for root callable programs [OFF]</p>
<p>-D : Switch on debug exec calls</p>
<p>-U : Make binary to be untraceable (using <em>strace</em>, <em>ptrace</em>, <em>truss</em>, etc.)</p>
<p>-H : Hardening. Extra security flag without root access requirement that protects against dumping, code injection, <code>cat /proc/pid/cmdline</code>, ptrace, etc.. This feature is <strong>experimental</strong> and may not work on all systems. This option currently only works with Bourne shell (sh) scripts without any positional parameters.</p>
<p>-s : Hardening with single process. Requires -H option, runs the binary in a single process, shell is called in the main process otherwise its called in a child process. This feature is <strong>experimental</strong> (may hang) and may not work on all systems. This option currently only works with Bourne shell (sh) scripts without any positional parameters.</p>
<p>-C : Display license and exit</p>
<p>-A : Display abstract and exit</p>
<p>-B : Compile for BusyBox</p>
<p>-h : Display help and exit</p>
<h1 id="environment-variables">ENVIRONMENT VARIABLES</h1>
<dl>
<dt>CC</dt>
<dd>C compiler command <code>[cc]</code>
</dd>
<dt>CFLAGS</dt>
<dd>C compiler flags <code>[none]</code>
</dd>
<dt>LDFLAGS</dt>
<dd>Linker flags <code>[none]</code>
</dd>
</dl>
<p>CC : C compiler command <code>[cc]</code></p>
<p>CFLAGS : C compiler flags <code>[none]</code></p>
<p>LDFLAGS : Linker flags <code>[none]</code></p>
<h1 id="examples">EXAMPLES</h1>
<p>Compile a script which can be run on other systems with the trace option enabled (without <code>-U</code> flag):</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">shc</span> -f myscript -o mybinary</code></pre></div>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -f myscript -o mybinary</code></pre>
<p>Compile an untraceable binary:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">shc</span> -Uf myscript -o mybinary</code></pre></div>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -Uf myscript -o mybinary</code></pre>
<p>Compile an untraceable binary that doesn't require root access (experimental):</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">shc</span> -Hf myscript -o mybinary</code></pre></div>
<h1 id="bugs">BUGS</h1>
<pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">shc</span> -Hf myscript -o mybinary</code></pre>
<h1 id="limitations">LIMITATIONS</h1>
<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>
<h1 id="authors">AUTHORS</h1>
<p>Francisco Rosales <a href="mailto:[email protected]">[email protected]</a></p>
<p>Md Jahidul Hamid <a href="mailto:[email protected]">[email protected]</a></p>
<p>Francisco Rosales <script type="text/javascript">
<!--
h='&#102;&#x69;&#46;&#x75;&#112;&#x6d;&#46;&#x65;&#x73;';a='&#64;';n='&#102;&#114;&#x6f;&#x73;&#x61;&#108;';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
// -->
</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>
<p>Md Jahidul Hamid <script type="text/javascript">
<!--
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;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
// -->
</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>
<h1 id="report-bugs-to">REPORT BUGS TO</h1>
<p><a href="https://github.com/neurobin/shc/issues" class="uri">https://github.com/neurobin/shc/issues</a></p>
<p><a href="https://github.com/neurobin/shc/issues">https://github.com/neurobin/shc/issues</a></p>
</body>
</html>
4 changes: 2 additions & 2 deletions man.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% shc(1) shc user manual
%
% November 20, 2018
% January 14, 2019
<hr>

# NAME
Expand Down Expand Up @@ -120,7 +120,7 @@ Compile an untraceable binary that doesn't require root access (experimental):
shc -Hf myscript -o mybinary
```

# BUGS
# LIMITATIONS
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))

# AUTHORS
Expand Down
Loading

0 comments on commit d5d1b89

Please sign in to comment.