egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Encrypt
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
micky
Voice


Joined: 13 Dec 2004
Posts: 11

PostPosted: Wed Dec 29, 2004 3:43 pm    Post subject: Encrypt Reply with quote

Some of you know how encrypt tcl? (http://mini.net/tcl/728)
Maybe some of you would be so kind and tell me how i can encrypt scripts or how to use obfuscation.
Back to top
View user's profile Send private message
^DooM^
Owner


Joined: 26 Aug 2003
Posts: 772
Location: IronForge

PostPosted: Wed Dec 29, 2004 3:48 pm    Post subject: Reply with quote

why would you want to encrypt a script?
_________________
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Dec 29, 2004 3:53 pm    Post subject: Reply with quote

you can compile your script with TclPro, it will produce a .tbc file which has a little loader header in clear Tcl (which of course depends on external library - libtbcload) and the rest is compiled bytecode stuff, similar to that in Java .class files (needless to say, there are .tbc decompilers, I hear user wrote one Wink so your script will never be safe from cracking)
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Dec 29, 2004 4:12 pm    Post subject: Reply with quote

alternatively, if you need script encryption as a preventive measure against peeking at your files on the shell, you can store your scripts encrypted with a key (of course, you'll need to patch your bot to be able to load those scripts)
Back to top
View user's profile Send private message Visit poster's website
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Wed Dec 29, 2004 4:13 pm    Post subject: Reply with quote

hmm i don't see the point using tcl as an ecrypter knowning that.. if you read the script that is gone encrypt it that it can be used to decrypt it ..

you will need to write a module to encrypt it .. when its compiled you can use a key or something which can't be read from the binary file.. when it is compiled .. well everything is possible if you know how but still its gone be a hard and for sur when you use hex chars .. to hide that code .. or encrypt the variables within the c code..
_________________
XplaiN but think of me as stupid
Back to top
View user's profile Send private message Visit poster's website
micky
Voice


Joined: 13 Dec 2004
Posts: 11

PostPosted: Wed Dec 29, 2004 4:37 pm    Post subject: Reply with quote

no, no, i need crypt like that http://www.tclshack.com/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=22
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Dec 29, 2004 4:48 pm    Post subject: Reply with quote

micky wrote:
no, no, i need crypt like that http://www.tclshack.com/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=22


lame and primitive obfuscation scriptlet, presumably hiding even lamer script (hard-coded parsing of HTML, will stop working when they change the webpage)
Back to top
View user's profile Send private message Visit poster's website
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Wed Dec 29, 2004 9:02 pm    Post subject: Reply with quote

micky wrote:
no, no, i need crypt like that http://www.tclshack.com/modules.php?op=modload&name=Downloads&file=index&req=getit&lid=22


i think i understand verry well what you wana do you wana encrypt the script so its only readable to the module..

you wana hide the script source ..

then if you wana do that you need a module not a script a module can decrypt or crypt a script you load the crypt into memory then decrypt it.. thats how u can do it .. and eval the code.. in the variable .. but making this work you should use a C module cause if you use a tcl script then there is no use crypting it .. you will be able to read how to decrypt it from the script cause the encrypter or decrypter still will be open source if you use a tcl script to crypt or decrypt it !!!!!

or do you mean a script that decrypts encrypted text that passes by in a channel ??
_________________
XplaiN but think of me as stupid
Back to top
View user's profile Send private message Visit poster's website
^DooM^
Owner


Joined: 26 Aug 2003
Posts: 772
Location: IronForge

PostPosted: Wed Dec 29, 2004 9:48 pm    Post subject: Reply with quote

try saying that after a few pints Ofloo Laughing
_________________
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Back to top
View user's profile Send private message Visit poster's website
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Wed Jan 05, 2005 9:51 pm    Post subject: Maybe a bit too late... :) Reply with quote

this is a slightly modified version of my code from this post...

Code:

# turn a string into random (octal/hexadecimal/unicode) escapes
proc lamesc str {
   set o ""
   foreach c [split $str ""] {
      if {[string is space $c]} {
         append o $c
      } {
         append o [switch [expr {int(rand()*3)}] {
            0 {format \\%o [scan $c %c]}
            1 {format \\x%x [scan $c %c]}
            2 {format \\u%x [scan $c %c]}
         }]
      }
   }
   set o
}

# obfuscate a piece of code
proc obfuscate code {
   foreach c [split $code ""] {set tmp($c) ""}
   set chrs [array names tmp]
   set i [array size tmp]
   set forward [set back [list]]
   foreach c $chrs {
      set r [expr {int(rand()*$i)}]
      incr i -1
      lappend forward $c [lindex $chrs $r]
      set back [concat [list [lindex $chrs $r] $c] $back]
      set chrs [lreplace $chrs $r $r]
   }
   switch [expr {int(rand()*3)}] {
      0 {set cmd "if [expr {1+int(rand()*(1<<24))}]"}
      1 {set cmd eval}
      2 {set cmd "uplevel 0"}
   }
   set code "[lamesc $cmd] \[[lamesc "string map"] [list $back [string map $forward $code]]\]"
}

# obfuscate everything between #OBF and #/OBF in one file and dump the result to another file
proc OBF {infile {outfile {}} {A "#OBF\n"} {B "\n#/OBF\n"}} {
   set i [set c 0]
   set j [string len $A]
   set k [string len $B]
   set data [read [set f [open $infile]]][close $f]
   if {$outfile=={}} {set f [open $infile w]} {set f [open $outfile w]}
   while {
      [set a [string first $A $data $i]]>-1
                  &&
      [set b [string first $B $data $a]]>-1
   } {
      puts -nonewline $f [string range $data $i [expr {$a-1}]]
      puts $f [obfuscate [string range $data [incr a $j] [expr {$b-1}]]]
      set i [expr {$b+$k}]
      incr c
   }
   puts -nonewline $f [string range $data $i end]
   close $f
   set c
}

# look for command line parameters and invoke OBF if there are any
if $argc {
   if {[catch [concat OBF $argv] err]} {
      puts $err
   } else {
      puts "$err part[expr {$err==1?"":"s"}] obfuscated."
   }
   exit
}


source the script and invoke the procs you want
...or save it to a file and do 'tclsh file input.tcl output.tcl' in your shell (will run the OBF proc on input.tcl and write the result to output.tcl)

Example:
Code:
proc demobf args {
#OBF
   return "Hello world"
#/OBF
}

...was turned into the beautiful code below by OBF
Code:
proc demobf args {
\x75\u70\154\u65\u76\145\u6c \60 [\163\x74\x72\151\u6e\147 \x6d\141\160 {o o r n e l d {   } n H w w {   } u t e H t {"} d u {"} l r { } { }} {dltH   lr unteeo wole"u}]
}


Using it to obfuscate only the body of a proc, like I did here, is not recommended.
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
mm
Halfop


Joined: 01 Jul 2004
Posts: 78

PostPosted: Wed Jan 05, 2005 11:18 pm    Post subject: Reply with quote

Hi,
demond
Quote:
alternatively, if you need script encryption as a preventive measure against peeking at your files on the shell, you can store your scripts encrypted with a key (of course, you'll need to patch your bot to be able to load those scripts)


demond, where can i find a patch?

thanks
_________________
MM
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Jan 05, 2005 11:58 pm    Post subject: Reply with quote

mm wrote:
Hi,
demond
Quote:
alternatively, if you need script encryption as a preventive measure against peeking at your files on the shell, you can store your scripts encrypted with a key (of course, you'll need to patch your bot to be able to load those scripts)


demond, where can i find a patch?

thanks


I don't believe you'll find such a patch available publicly; after all, the whole point of that is to conceal how the actual encryption (respectivelly decryption/loading) is done, in order to prevent potential crackers/takeover monkeys from patching your scripts (or at least to make their task harder; if they want your channel really bad and have some skills, they'd crack the bot binary anyway; besides, there are other methods for hacking ops from encrypted bot, such as connection hijacking, using ptrace() to attach to & control bot's process, etc.)

I once wrote similar patch for eggdrop 1.4, but it's not much of a use today anyway
Back to top
View user's profile Send private message Visit poster's website
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Thu Jan 06, 2005 3:58 am    Post subject: Reply with quote

User, how would you go about deobfuscating that script you obfuscate with your code so you can actually use it? :p
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Jan 06, 2005 4:30 am    Post subject: Reply with quote

just run it Razz
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
lsn
Voice


Joined: 19 Jul 2004
Posts: 25

PostPosted: Fri Dec 23, 2005 8:21 am    Post subject: Reply with quote

I write that code into a file named tcl
I run the code:
Code:
tclsh8.4 tcl x.tcl z.tcl

I get this
Quote:
0 parts obfuscated.

And the file z.tcl was identical with x.tcl, nothing has changed.. What goes wrong ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber