AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple Obfuscation/Source Protection

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed May 21, 2008 11:18 pm    Post subject: Simple Obfuscation/Source Protection Reply with quote

This is a simple script that can obfuscate and launch your .ahk files. The two main downsides to using something like this are performance (can be somewhat slower to start on large files) and you need an extra file in order to use these scripts... also, it's extremely simple to just use this file to get the original source. Nevertheless here it is, I guess you can write in more elaborate encryption type functions if you want to but this is the basic script.

This script requires Laszlo's Bin Read/Write functions

Code:
ObFile =

#NoTrayIcon

NFile := A_Temp . "\" . A_Now . ".ahk"
SetBatchLines, -1
BinRead(ObFile,ObFileDat)
Enc(ObFileDat)
BinWrite(NFile,ObFileDat)
Run, %A_AHKPath% "%NFile%",,, PID
Loop
{
   Process, Exist, %PID%
   If (ErrorLevel == PID)
      Break
   Sleep, 1
}
Sleep, 1000
FileDelete, % NFile
Return

Enc(ByRef Str)
{
   NStr := ""
   SetFormat, Integer, H
   Loop, % StrLen(Str)//2
   {
      Hex := "0x" . SubStr(str,1,2)
      NStr .= RegExReplace((0xFF - Hex),"^0x")
      Str  := SubStr(str,3)
   }
   Str := NStr
}
#Include BinReadWrite.ahk

Change the ObFile variable to the obfuscated file and run.

To obfuscate files:
Code:
File =

#NoTrayIcon

NFile = SubStr(File,1,StrLen(File)-3) . "obf"
SetBatchLines, -1
BinRead(File,ObFileDat)
Enc(ObFileDat)
BinWrite(NFile,ObFileDat)
Return

Enc(ByRef Str)
{
   NStr := ""
   SetFormat, Integer, H
   Loop, % StrLen(Str)//2
   {
      Hex := "0x" . SubStr(str,1,2)
      NStr .= RegExReplace((0xFF - Hex),"^0x")
      Str  := SubStr(str,3)
   }
   Str := NStr
}
#Include BinReadWrite.ahk
Back to top
greynite



Joined: 17 May 2008
Posts: 11

PostPosted: Thu May 22, 2008 12:55 pm    Post subject: Reply with quote

Why not just compile the script with a password?
Back to top
View user's profile Send private message
Guest






PostPosted: Thu May 22, 2008 6:00 pm    Post subject: Reply with quote

This ends up being a much smaller file, and I remember seeing a post asking about this somewhere before... But yeah, compiling does make it a lot more secure and is generally easier to work with
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group