Results 1 to 11 of 11
  1. #1

    shell script encrypt

    Hi,

    I am looking for a way to either encrypt / obfuscate a string using a bash shell script.

    The catch is...

    It cant be a one-way hash. Md5, etc wont work because it needs to be reversible, preferably with a key.

    I found some cheesey ROT13 routine.. I would like to make it a little more interesting than that.

    This is just for some little project - it doesnt have to be overly secure.

    Any ideas?
    "The only difference between a poor person and a rich person is what they do in their spare time."
    "If youth is wasted on the young, then retirement is wasted on the old"

  2. #2
    Join Date
    Jul 2002
    Location
    Kuwait
    Posts
    10,573
    shell script compiler

    converts ur script into c source then compile it, i use it all the time amazing
    Bashar Al-Abdulhadi - KuwaitNET Internet Services Serving customers since 1997
    Kuwait's First Webhosting and Domain Registration provider - an ICANN Accredited Registrar

    Twitter: Bashar Al-Abdulhadi

  3. #3
    I think you misunderstood me.

    I dont want to encrypt the entire script.

    I want to operate on a string, using a bash shell script.

    POssible?
    "The only difference between a poor person and a rich person is what they do in their spare time."
    "If youth is wasted on the young, then retirement is wasted on the old"

  4. #4
    Join Date
    Jul 2002
    Location
    Kuwait
    Posts
    10,573
    ah use the command enigma (on freebsd) not sure if its there by default on linux

    ested by:
    Code:
    #!/usr/local/bin/bash
    read -p "enter a command " ecmd
    read -p "enter key " ekey
    echo $ecmd |enigma $ekey > /tmp/.ecmd
    read -p " what is the key? " ekeys
    enigma $ekeys < /tmp/.ecmd
    if you more /tmp/.ecmd its an encrypted file
    # file /tmp/.ecmd
    /tmp/.ecmd: data
    Bashar Al-Abdulhadi - KuwaitNET Internet Services Serving customers since 1997
    Kuwait's First Webhosting and Domain Registration provider - an ICANN Accredited Registrar

    Twitter: Bashar Al-Abdulhadi

  5. #5
    Join Date
    Apr 2002
    Location
    Troy, MI
    Posts
    309
    hmm cant seem to get shc to work; compile a script with it and execute the generated binary and it just sits there; have to kill it.
    Ryan MacDonald
    Lead Administrator | TotalChoice Hosting
    Choice Does Matter! | Serving over 26,000 clients

  6. #6
    Join Date
    Feb 2004
    Posts
    1,226
    seriously, if you want to "compile" a shell script, that's probably because you want to distribute that...
    and if you need to do that, i would HIGH suggest that you write it in C from the start... no "language X to language Y" conversor is good even more those to convert from a language like shell that you don't even need to declare variables and types to one that you need

  7. #7
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,687
    Originally posted by Lem0nHead
    I would HIGH suggest that you write it in C from the start...
    Agreed, you can even use the system() call in C to get your shell script compiled. It's cheap I know, but it works. I actually use C to manage and maintain 90% of my scripts. The only ones I don't are the more complicated ones which will take a little more tweaking to move to C
    WHMCS Guru - WHMCS addons, management, support and more.
    WHMCS Notifications Extended - Add slack, hipchat, SMS, pushover to WHMCS !!
    Always looking for Linux, WHMCS, Support Desk work. PM for details

  8. #8
    Join Date
    Apr 2002
    Location
    Troy, MI
    Posts
    309
    Im just toying with shc; i know the pro's and con's of application development be it a small script or a bloated application; in C.

    Just curious if anyone has gotten shc to work properly.
    Ryan MacDonald
    Lead Administrator | TotalChoice Hosting
    Choice Does Matter! | Serving over 26,000 clients

  9. #9
    Works fine for me.

    RH9 / FC1.

    I dont use any special flags.

    Hell, it even works for me under Cygwin> I can compile SHC from source, use it, and the binaries work.
    "The only difference between a poor person and a rich person is what they do in their spare time."
    "If youth is wasted on the young, then retirement is wasted on the old"

  10. #10
    Join Date
    Apr 2002
    Location
    Troy, MI
    Posts
    309
    Hmm ya it only not working on my hardened grsec/gradm systems; dont see pax terminations or grsec logging events -- o well.
    Ryan MacDonald
    Lead Administrator | TotalChoice Hosting
    Choice Does Matter! | Serving over 26,000 clients

  11. #11
    Join Date
    Jul 2002
    Location
    Kuwait
    Posts
    10,573
    Originally posted by wolfstream
    Agreed, you can even use the system() call in C to get your shell script compiled. It's cheap I know, but it works. I actually use C to manage and maintain 90% of my scripts. The only ones I don't are the more complicated ones which will take a little more tweaking to move to C
    with system() its possible to read the commands written there using 'strings' i have tried that earlier and found that my best option was shc since i'm not a C guy and i have most of my shell scripts written long time ago.
    Bashar Al-Abdulhadi - KuwaitNET Internet Services Serving customers since 1997
    Kuwait's First Webhosting and Domain Registration provider - an ICANN Accredited Registrar

    Twitter: Bashar Al-Abdulhadi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •