| View previous topic :: View next topic |
| Author |
Message |
]Kami[ Owner

Joined: 24 Jul 2003 Posts: 590 Location: Slovenia
|
Posted: Wed Aug 04, 2004 3:14 pm Post subject: Encrypting/Obfuscation |
|
|
Hey,
I'm interested about encrypting tcl scripts or obfuscation.Yesterday i read every topic on egghelp about encrypting/obfuscation and also obfuscation site.I didn't really understand how to do it, but maybe some of you would be so kind and tell me how i can 'encrypt' scripts or how to use 'obfuscation'.I need it for my next script which source shouldn't be visible to public.I still didn't start to write script, because i don't know how i can 'encrypt' it later.
Tnx _________________ Slovene Eggdrop Page |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Aug 04, 2004 3:56 pm Post subject: |
|
|
There's no way to create working code that can't be read by anyone. But you can scare off most people by using procomp to bytecode compile your script. (I would still be able to get your source ;P) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Aug 04, 2004 3:58 pm Post subject: |
|
|
same goes with obfuscation.. it can easily be deobfuscated if you know where to look and to add  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Aug 04, 2004 4:00 pm Post subject: |
|
|
| caesar wrote: | same goes with obfuscation.. it can easily be deobfuscated if you know where to look and to add  |
bytecode compilation IS obfuscation.  _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Aug 04, 2004 4:04 pm Post subject: |
|
|
oh.. lol.. I knew that..  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
KrzychuG Master

Joined: 16 Aug 2003 Posts: 306 Location: Torun, Poland
|
Posted: Wed Aug 04, 2004 4:12 pm Post subject: |
|
|
| Quote: |
There's no way to create working code that can't be read by anyone. But you can scare off most people by using procomp to bytecode compile your script. (I would still be able to get your source ;P)
|
I don't think so. _________________ Que? |
|
| Back to top |
|
 |
]Kami[ Owner

Joined: 24 Jul 2003 Posts: 590 Location: Slovenia
|
Posted: Wed Aug 04, 2004 4:23 pm Post subject: |
|
|
| user wrote: | | There's no way to create working code that can't be read by anyone. But you can scare off most people by using procomp to bytecode compile your script. (I would still be able to get your source ;P) |
Just read the site and it looks ok, but i need something which doesn't need extra libary/file to be loaded...Just something which strikelight is using...I don't need it to be super encrypted, only something which will prevert newbies to view the source Any idea, how i can use similar method like strikelight is using? _________________ Slovene Eggdrop Page |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Aug 04, 2004 5:42 pm Post subject: |
|
|
The whole point of obfuscation is that people don't understand how it works, so posting a way to obfuscate kinda defeats its own purpose If a method of obfuscation becomes widely used, the way to deobfuscate it will (sooner or later) become public knowledge too.
| 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]
}
# EDIT 3: added this if
if {rand()>0.5} {
set cmd "if [expr {int(rand()*(1<<24))}]"
} {
set cmd eval
}
set code "[rndesc $cmd] \[[rndesc "string map"] [list $back [string map $forward $code]]\]"
}
proc obfuscateFile file {
set f [open $file r+]
puts $f [obfuscate [read $f][seek $f 0]]
close $f
}
# EDIT 2: added this little sucker to hide the cleartext commands a bit :)
proc rndesc 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%.4x [scan $c %c]}
}]
}
}
set o
} |
Make sure you back up any file you want to try this on as i didn't test it much
Btw: you can run it multiple times on the same file if you want to waste some more cpu loading the script. _________________ Have you ever read "The Manual"?
Last edited by user on Fri Aug 06, 2004 11:52 am; edited 5 times in total |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Aug 05, 2004 10:49 am Post subject: |
|
|
| KrzychuG wrote: | | I don't think so. |
What? _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
KrzychuG Master

Joined: 16 Aug 2003 Posts: 306 Location: Torun, Poland
|
Posted: Thu Aug 05, 2004 11:45 am Post subject: |
|
|
I don't think you can retrieve source code from compiled tcl files. _________________ Que? |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Aug 05, 2004 6:19 pm Post subject: |
|
|
| KrzychuG wrote: | | I don't think you can retrieve source code from compiled tcl files. |
should I care?
Just because you failed doesn't mean it's impossible. I won't give you my decompiler, so you better start coding your own (just start reading the tbc loader source and get to know the format, and you should be able to make your own decompiler in a couple of evenings) or rewrite those scripts you claim to have lost.  _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
KrzychuG Master

Joined: 16 Aug 2003 Posts: 306 Location: Torun, Poland
|
Posted: Thu Aug 05, 2004 7:06 pm Post subject: |
|
|
I rewrote them already
Btw, can you give me some advices about tcl pro decompiler? _________________ Que? |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Aug 05, 2004 7:30 pm Post subject: |
|
|
Advice 1: Be more specific
Advice 2: Stay focused when reading the source and take notes
As I don't know C, my decompiler is 100% tcl (which is sort of weird, sure ) it has a call stack emulator that actually "runs" the bytecode. (the only way to do it i guess)
But if you're doing it in C, I think there's lots of stuff to cut'n'paste from where the error messages are generated (it will generate the source for a small part of the bytecode where the error occured (iirc)) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
|