Preventing script from being replicated on a defined number of hosts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Preventing script from being replicated on a defined number of hosts
# 8  
Old 02-19-2013
Quote:
Originally Posted by DGPickett
Well, encoding usually means taking 6 bits at a time of the binary and encoding them in some of the innocuous ascii valuse between ' ' and '~', for instance adding them to '!'. Hex is just a 4 bit version of the same. Nobody has been desperate enough to find a way to encode using 96 characters for 6.5 bits a character. Smilie Here is an example of what a hacker sees if you compress plain text and then convert it to hex:
Code:
$ echo hidden data string |bzip2|od -x
0000000 425a 6839 3141 5926 5359 e937 8426 0000
0000020 0551 8000 1040 0026 e11c 0020 0031 0340
0000040 d029 a635 3c45 9ac0 17b9 7f4d 8256 68bb
0000060 9229 c284 8749 bc21 3000
0000071

Encoding 4 bits is easy:
Code:
$ vim hexify 
 
#include <stdio.h>
main(){
int c ;
int o ;
int llen = 0;
 while ( EOF != ( c = getchar())){
   putchar( '0' + ( c & 15 ));
   putchar( '0' + ( c >> 4 ));
   if ( 70 < ( llen += 2 )){
        putchar( '\n' );
        llen = 0 ;
    }
  }
 if ( llen ) putchar( '\n' );
}
~
~
~
"mysrc/hexify.c" 21 lines, 264 characters 
$ mycc hexify
$ echo hidden data string | bzip2 | hexify
24:586931314956235959>734862000050150800010400621><10002001330040=926:53
<354:90<719;?7=4286586;;29922<487894<;1203
$

It seems bzip2 expands small things a lot!
i read this multiple times but i cant seem to understand. let me break this down in my simple terms and hopefully you can help me understand what you're doing it.

say i have a script that contains:

Code:
#!/bin/bash

echo "You are welcome"
echo "You are the greatest"

Now this script is named
Code:
aboutme

I need to send this script to a user, but i dont want this user to be able to view what's in aboutme.

when i zip up aboutme and i send it to the user, i want to make sure all that the user needs to do, in order to run this script will be:

Code:
unzip aboutme.zip
./aboutme

how can your encryption method make this feasible?

Code:
uuencode aboutme.uu

./aboutme.uu ?

# 9  
Old 02-20-2013
In place of a shell script, you deliver a C program that has the shell script, compressed and uuencoded, in a static string variable, which it runs by popen( "uudecode | gunzip | sh", "w" ) and writing the encrypted script to the pipe. The C program never changes but in the string variable and name, to run any number of scripts. If there are command line variables, you need to move them from argv to quoted on the popen command line, or restructure the script for them to arrive on stdin.

You could even just put the script in the string variable as hex and un-hex it as you write the pipe, so you need no uudecode or gunzip. The hexification means it is not obvious to the 'string' command.
This User Gave Thanks to DGPickett For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh. Actions to perform within a single ssh session via shell script - copy a file - untar at destination (remote host) OS : Linux RHEL6 (3 Replies)
Discussion started by: sankasu
3 Replies

2. UNIX for Beginners Questions & Answers

selection particular number of line from a bunch by user defined limits.

hello i am having a file having a matrix as the following 4.1 5.5 6.55 7.2 8.2 1.002 i am having around 1 lakh rows, now i need a program in which i show give min x and min y and min z values and as well as max x max y max z, the values between these minimun and maximum values should be... (1 Reply)
Discussion started by: charan pattabhi
1 Replies

3. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway. For example: Input: ./subnetter.sh 192.168.0.0/24 3 Output: 192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Discussion started by: mail2rias
1 Replies

4. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway. For example: Input: ./subnetter.sh 192.168.0.0/24 3 Output: 192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Discussion started by: mail2rias
1 Replies

5. Shell Programming and Scripting

No lock file: Preventing multiple instance of a script

I've been bitten by using a lock or pid file to prevent multiple instances of a script. A user typed kill -9, and the pid file didn't go away. You can't trap -9. So when he tried to restart, it said "already running", and I got trouble report. Argh. So here's what we came up with: # Stop if... (1 Reply)
Discussion started by: McFadden586
1 Replies

6. Shell Programming and Scripting

Number of days between the current date and user defined date

I am trying to find out the number of days between the current date and user defined date. I took reference from here for the date2jd() function. Modified the function according to my requirement. But its not working properly. Original code from here is working fine. #!/bin/sh... (1 Reply)
Discussion started by: hiten.r.chauhan
1 Replies

7. UNIX for Dummies Questions & Answers

Maximum Number of Virtual Hosts per Apache instance

Is there a directive to limit the number of virtual hosts allowed per apache instance? I am told yes but I cannot find it. (1 Reply)
Discussion started by: mojoman
1 Replies

8. Shell Programming and Scripting

Awk to extract lines with a defined number of characters

This is my problem, my file (file A) contains the following information: Now, I would like to create a file (file B) containing only the lines with 10 or more characters but less than 20 with their corresponding ID: Then, I need to compare the entries and determine their frequency. Thus, I... (7 Replies)
Discussion started by: Xterra
7 Replies

9. Shell Programming and Scripting

sed/awk to insert comment at defined line number

Hi there, may someone easily help me on this : I want to insert a text in a specific line number like : linenumb2start=`cat memory_map.dld | nl -ba | egrep -i "label" | cut -f1` line2insert=`expr $linenumb2start + 2` and now I need to replace something like {} with {comment} at... (8 Replies)
Discussion started by: homefp
8 Replies

10. UNIX for Advanced & Expert Users

Preventing script to run at the same time.

I have a script, myscript.pl I want to set the script to exit if it is already running. At the moment I am using soft stop. eg: if -e dummy file then exit else create a dummy file Is there any other better way to perform this? Maybe ps -ef | egrep 'myscript.pl' (3 Replies)
Discussion started by: cronboss
3 Replies
Login or Register to Ask a Question