Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/linting #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@ CHANGES

* zsh support
* Fix issue #13 (https://github.com/neurobin/shc/issues/13)


3.9.2 Fri Aug 21 16:12:33 BDT 2015

Added BusyBox support with patch taken from:
https://onedrive.live.com/prev?cid=18a41d08a9f3c543&id=18A41D08A9F3C543!231&authkey=!AJQ6Iah_5D3WJ60&v=TextFileEditor
as suggested by https://github.com/marcoburatto

3.9.1 Fri Apr 03 00:22:11 GMT 2015

Renamed option -T to -U and reversed it's logic.
So now, the executable prepared will execute without using sudo,
by default.


3.9.0 Wed Apr 01 08:35:22 AM GMT 2015
3.9.0 Wed Apr 01 08:35:22 AM GMT 2015

(http://github.com/neurobin)
Added output file option with [-o filename]
and fixed bug on make install (manual install failed)
Now you can access manual by entering command: man shc
in a terminal.



3.8.9 Wed Apr 25 09:24:25 CEST 2012
Expand Down Expand Up @@ -122,8 +122,8 @@ CHANGES
- Fixed bug: "rlax" used after encryption.

Thanks to Nalneesh Gaur <[email protected]> for:
- Read permision of the script.x exposes it to disassembling.
- Group and others read permision is now removed by default.
- Read permission of the script.x exposes it to disassembling.
- Group and others read permission is now removed by default.



Expand Down Expand Up @@ -227,16 +227,15 @@ SCO, both not used now.
3.0b1 Wed Feb 26 14:27:22 WET 1997

The main difference with 2.4 is that in it the script was
compressed an then shuffle around, now int 3.0 the script is encripted
with an inline code, so not needend any external comand to work, and been
faster at startup. Other related adventage is that the only information
not encripted in .x.c is an stamp, expiration date and provider email
compressed an then shuffle around, now int 3.0 the script is encrypted
with an inline code, so not needing any external command to work, and been
faster at startup. Other related advantage is that the only information
not encrypted in .x.c is an stamp, expiration date and provider email
address.

Something equivalent to cheksums have been used to enforced at
Something equivalent to checksums have been used to enforced at
execution that the executing shell has not been modified from the time
the script was compiled. If anybody tries to change the excuting shell,
the script was compiled. If anybody tries to change the executing shell,
.x will refuse to execute.

The generated .x.c source code is now readable.

1 change: 0 additions & 1 deletion man.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,3 @@ Md Jahidul Hamid <[email protected]>

# REPORT BUGS TO
https://github.com/neurobin/shc/issues

21 changes: 10 additions & 11 deletions src/shc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ static const char version[] = "Version 4.0.3";
static const char subject[] = "Generic Shell Script Compiler";
static const char cpright[] = "GNU GPL Version 3";
static const struct { const char * f, * s, * e; }
provider = { "Md Jahidul", "Hamid", "<[email protected]>" };
provider = { "Md Jahidul", "Hamid", "<[email protected]>" };

/*
/*
static const struct { const char * f, * s, * e; }
author = { "Francisco", "Garcia", "<[email protected]>" };
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ static const char * abstract[] = {
" of the script specified at command line.",
"",
" Binary version will be saved with a .x extension by default.",
" You can specify output file name too with [-o filname] option.",
" You can specify output file name too with [-o outfile] option.",
"",
" You can specify expiration date [-e] too, after which binary will",
" refuse to be executed, displaying \"[-m]\" instead.",
Expand All @@ -67,7 +67,7 @@ static const char * abstract[] = {
"",
0};

static const char usage[] =
static const char usage[] =
"Usage: shc [-e date] [-m addr] [-i iopt] [-x cmd] [-l lopt] [-o outfile] [-rvDSUHCAB2h] -f script";

static const char * help[] = {
Expand Down Expand Up @@ -279,7 +279,7 @@ static const char * RTC[] = {
"}",
"",
"/*",
" * Crypt data. ",
" * Encrypt data. ",
" */",
"void arc4(void * str, int len)",
"{",
Expand Down Expand Up @@ -895,7 +895,7 @@ static void parse_args(int argc, char * argv[])
if (ret == -1)
err++;
} while (ret);

if (err) {
fprintf(stderr, "\n%s %s\n\n", my_name, usage);
exit(1);
Expand All @@ -907,7 +907,7 @@ static void parse_args(int argc, char * argv[])
static unsigned char stte[256], indx, jndx, kndx;

/*
* Reset arc4 stte.
* Reset arc4 stte.
*/
void stte_0(void)
{
Expand All @@ -918,7 +918,7 @@ void stte_0(void)
}

/*
* Set key. Can be used more than once.
* Set key. Can be used more than once.
*/
void key(void * str, int len)
{
Expand All @@ -937,7 +937,7 @@ void key(void * str, int len)
}

/*
* Crypt data.
* Encrypt data.
*/
void arc4(void * str, int len)
{
Expand Down Expand Up @@ -1167,7 +1167,7 @@ void prnt_array(FILE * o, void * ptr, char * name, int l, char * cast)
int m = rand_mod(1+l/4); /* Random amount of random pre padding (offset) */
int n = rand_mod(1+l/4); /* Random amount of random post padding (tail) */
int a = (offset+m)%l;
if (cast && a) m += l - a; /* Type alignement. */
if (cast && a) m += l - a; /* Type alignment. */
fprintf(o, "\n");
fprintf(o, "#define %s_z %d", name, l);
fprintf(o, "\n");
Expand Down Expand Up @@ -1361,4 +1361,3 @@ int main(int argc, char * argv[])
exit(1);
return 1;
}

5 changes: 3 additions & 2 deletions test/pru.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ echo "$0" "$@"
ps $$
ps wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww $$
cat /proc/$$/cmdline
touch $0.kk
read ENTER
touch "$0.kk"
# shellcheck disable=SC2034
read -r ENTER
5 changes: 3 additions & 2 deletions test/ttest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ pc=0
fc=0
echo
echo "== Running tests ..."
for shell in ${shells[@]}; do
for shell in "${shells[@]}"; do
for opt in "${check_opts[@]}"; do
tmpd=$(mktemp -d)
tmpf="$tmpd/test.$(basename $shell)"
tmpf="$tmpd/test.$(basename "$shell")"
echo '#!'"$shell
echo 'Hello World fp:'\$1 sp:\$2
" > "$tmpf"
# shellcheck disable=SC2086
"$shc" $opt -f "$tmpf" -o "$tmpd/a.out"
out=$("$tmpd/a.out" first second)
#~ echo " Output: $out"
Expand Down