|
| 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>["Please contact your provider"]</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='fi.upm.es';a='@';n='frosal';e=n+a+h; |
| 134 | +document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>'); |
| 135 | +// --> |
| 136 | +</script><noscript>frosal at fi dot upm dot es</noscript></p> |
| 137 | +<p>Md Jahidul Hamid <script type="text/javascript"> |
| 138 | +<!-- |
| 139 | +h='yahoo.com';a='@';n='jahidulhamid';e=n+a+h; |
| 140 | +document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>'); |
| 141 | +// --> |
| 142 | +</script><noscript>jahidulhamid at yahoo dot com</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> |
0 commit comments