Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Obfuscator for Autohotkey Scripts


  • Please log in to reply
53 replies to this topic
Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

I uploaded the project to github:

https://github.com/d...tkey-obfuscator

-includes some bug fixes

-fixed problem with hotkeys with spaces in them

 

 

i'm open sourcing an autohotkey obfuscator i created:

http://dynamicobfuscator.org

download and unzip

includes all source code, documentation, and examples

it can obfuscate autohotkey and autohotkey_L scripts

 

i obfuscated this 8,000 line autohotkey  program i built with it:

http://speedy-orange-pc-shortcuts.com/

download that program and then load it into resource hacker to see the obfuscated code!

version of program with no installation program:

http://speedy-orange...EE-portable.zip

 

here's some of the obfuscated code lifted from that program:

[email protected]@[email protected]#() {
global
[email protected]%ffkffkk#ffk#[email protected]%@f%[email protected]#ffkfk#k#[email protected]%ffk%k#fkfkk#kffffkfkk#[email protected]%fkf%ffkffkffffk#k#kffkk#fkfk%()
f%fkk#[email protected]@[email protected]@k#kffkfkfk%kk#f%[email protected]@k#ffffkfkfkf%[email protected]%[email protected]@[email protected]#fkffk#fk%f%[email protected]@[email protected]#[email protected]%fkfkf()
k#k%[email protected]@[email protected]#[email protected]%#kfk%[email protected]@%%[email protected]@kfk#[email protected]#kf%ff%k#k#[email protected]#[email protected]@[email protected]%[email protected]()
}
k#[email protected]#k#kfffk#ffkfffkfk#[email protected]#kf:
[email protected]%[email protected]#k#k#[email protected]#[email protected]%%fkk#[email protected]#fffkk#%@kfk%[email protected]#fkfkkffkff%%[email protected]#kf%%[email protected]#fffkk#[email protected]#%("kfffk#[email protected]@fffffkfkkfkfk#[email protected]@fkk#[email protected]#ffk#ffkfffk#[email protected]@[email protected]#fffkk#k#[email protected]#kfkfkfk#[email protected]@[email protected]@fffk")
return
[email protected]@fkk#[email protected](kffkfkkfk#ffkfff, [email protected]#[email protected]#[email protected], [email protected]#[email protected] = 0) {
global
%fkk#[email protected]%%[email protected]@[email protected]#%%[email protected]@[email protected]#[email protected]#%%k#[email protected]#fkk#ffkfk#%%[email protected]#[email protected]#[email protected]@k#%%k#kffkfffkk#[email protected]%([email protected]%[email protected]@[email protected]#kfff%[email protected]%[email protected]#[email protected]@ff%#f%[email protected]@k#ffk#[email protected]@[email protected]#%f%[email protected]#fffkk#[email protected]#%kfk#fk("e40367074516881777e707c457a775f5e7a6f71767c3d2"), fkf%ffk#kfk#[email protected]%%kfk#k#[email protected]@[email protected]#%@fk%k#fkkfkfffk#ffffkf%k%kfk#[email protected]%[email protected], [email protected]%fkk#[email protected]#ffkfkfffkf%%k#kfffkfk#k#k#ff%kk%[email protected]#fk%#[email protected], %k#[email protected]#ffk#k#k#[email protected]%%[email protected]@[email protected]#%kf%fkfkkfffffffk#[email protected]#kf%@fk%fkfkk#[email protected]#fkffk#%[email protected], kf%fkk#[email protected]%f%kffkkffkkfk#k#k#fkfkk#ff%fk%fkfkk#[email protected]#fkffk#%k%ffkfk#[email protected]%fk#ffkfff, %k#fkk#kfffffkf%%[email protected]@fkk#kfkffkfkffkfff%%k#[email protected]%, f%kffkk#fkfkfffffkfkfkkf%@f%k#fkkfkfffk#ffffkf%k#%kffkkffkkfk#k#k#fkfkk#ff%f%[email protected]#fkffffkfffff%[email protected]#[email protected], f%[email protected]@k#fffkfkk#fk%kf%[email protected]#fk%@f%kfk#kfkfk#[email protected]@k#%%[email protected]#[email protected]#ff%k%ffk#[email protected]#kfkffkfkkfkfkf%[email protected])
}
[email protected]#(kfkfkfk#[email protected]#) {
global
local kffkk#fkffkffkffk#[email protected], kfk#kfkfffkfffk#ffkf, [email protected]@
kff%[email protected]#[email protected]%fkf%[email protected]#kffkk#%@k%[email protected]@ffk#fffk%ffkk%fkk#ffk#[email protected]@fffffkfkff%[email protected] = % kfk%k#k#[email protected]#%kf%k#[email protected]#fkk#ffkfk#%k#%fkfffkkfk#[email protected]#[email protected]%[email protected]%[email protected]#k#[email protected]#ffk#kffk%fkk#
kf%k#[email protected]%#kfk%k#k#k#k#fkffffkf%fffk%[email protected]@fkff%fffk#ffkf =
loop, %
%[email protected]#[email protected]#[email protected]%%kfk#[email protected]@fkkf%%k#[email protected]#[email protected]#ff%%ffkfk#k#fffkkf%%fkffk#[email protected]%%k#[email protected]#ffk#%(%[email protected]@[email protected]#fkfkk#[email protected]%kff%fkk#ffk#[email protected]@fffffkfkff%%[email protected]#[email protected]%[email protected]%kffkk#fkfkkffffffkkf%[email protected])
{
k%[email protected]@[email protected]#ff%fkk%[email protected]@[email protected]#%#f%[email protected]#k#[email protected]#ffk#kffk%kffkffkffk#[email protected] = % %k#ffk#fkk#[email protected]@%%[email protected]@[email protected]@%%k#kfkfffk#k#%%fkffk#[email protected]#kfk#k#k#k#[email protected]@%%[email protected]@fkfk%%k#k#[email protected]#[email protected]%(k%[email protected]#[email protected]%%k#k#[email protected]#%fkf%[email protected]#k#k#k#kfkffk%f%[email protected]#fk%@kf%[email protected]#fkfkk#fkkfk#k#ff%[email protected], a_index, 1)
kf%ffk#[email protected]#kfkffkfkkfkfkf%k#k%fkk#[email protected]#ffkfkfffkf%kfffk%k#k#[email protected]#[email protected]%fffk#ffkf = % kf%[email protected]@[email protected]#[email protected]#%%k#[email protected]@%fkk%kffffkffffkffffkkfk#[email protected]%f%[email protected]@fkkffffkff%ffkffkffk#[email protected] . k%kfk#kfk#[email protected]@kf%k%[email protected]@k#ff%%[email protected]#k#[email protected]@kfk#kf%%[email protected]#fkkffkk#%kfkfffkfffk#ffkf
}
kfk#k%fkfffkkfk#[email protected]#[email protected]%%kfk#k#[email protected]@[email protected]#%fkfffk%k#fkkfkfffk#ffffkf%ffk#ffkf = % %[email protected]#k#k#[email protected]%%kfk#k#[email protected]@[email protected]#%%kfkfkffkfkkfffk#%(%[email protected]@fkk#kffk%fk#k%[email protected]@[email protected]#[email protected]#[email protected]%%kffkk#fkfkfffffkfkfkkf%fkf%[email protected]@%%kfk#k#k#k#[email protected]%fkfffk#ffkf)
return, % %[email protected]@k#kf%%[email protected]@[email protected]#%%[email protected]#fffkk#[email protected]#%
}
k#ffk#k#k#kffkk#[email protected]@[email protected]@:
f%ffffk#k#fkk#[email protected]%@f%kfkfk#k#k#[email protected]#fk%%[email protected]#kffkffff%fk%[email protected]#[email protected]%%k#[email protected]#ffk#%%[email protected]#kf%("k#kfk#fffkfffkk#k#k#k#[email protected]#[email protected]#[email protected]#[email protected]@fk[email protected]#k#k#k#fkk#[email protected]#[email protected]@[email protected]@[email protected]#fkffkfkfkfkfk#k#[email protected]@[email protected]#[email protected]@kffkff")
return
fkfkkfk#k#fkk#ff(ffkffkffk#fk) {
global
gui, font, norm underline
gui, add, text, xm+%ffkffkffk#fk%%[email protected]@fkk#kfkffkfkffkfff%%[email protected]#fkfkk#fkkfk#k#ff% yp-4 Cblue Gkffkk%k#ffk#fkk#[email protected]@%fk#[email protected]@%[email protected]@[email protected]#fk%fk#%[email protected]#[email protected]@k#kfffkf%ff%[email protected]#[email protected]%[email protected]#kf, % [email protected]%[email protected]#fkkfk#[email protected]@kfff%f%fffkk#ffffkfkfk#%%fkfkfffkfffkfkffk#kfffkf%k#ff%[email protected]@[email protected]#[email protected]@fk%kfk#fk("a77697e70797a7c297d71747d2a6e7b297877757c7c6d82297674816f2a6d747d2a7c71508c9")
}
[email protected]#([email protected]@[email protected]@) {
global
MsgBox, 4096, **ERROR**, % [email protected]%[email protected]@[email protected]#ff%[email protected]%[email protected]#k#k#[email protected]%f%[email protected]@k#[email protected]%[email protected]@
}
[email protected]@[email protected]#kf() {
global
static [email protected]#[email protected]#ffkfff
[email protected]%fkkffkfffkk#kfk#[email protected]@%%[email protected]@fkff%[email protected]%[email protected]@fkk#kfkffkfkffkfff%k#ffkfff++
if ([email protected]%[email protected]#[email protected]@k#kfffkf%#[email protected]#%k#kffkfffkk#[email protected]%ff%k#[email protected]#[email protected]#ff%kfff // 8) {
k#%[email protected]#ffkfk#k#[email protected]%kff%[email protected]@[email protected]@[email protected]@%@k%[email protected]#kfkffffk%ffkfkfkf()
fkf%[email protected]#[email protected]#kfkfk#fk%@k#%[email protected]#[email protected]%@k%fkk#[email protected]@[email protected]%#ff%[email protected]#kffkffff%fff=
}
}


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
excellent work, i will definitely study this

i donated on your site as well, as a 'thank you' for sharing this happy.png

however, your donation dropdown is broken, the paypal page automatically put $5 instead of $10, so i changed quantity x2

Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

thank you for your donationhappy.png

 

feel free to post any questions you have about using the program or its architecture



Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010

Impressive. A lot of people have been looking for something exactly like this. I'm sure it will be very useful.



Kangaroo
  • Members
  • 8 posts
  • Last active: Nov 04 2014 12:39 PM
  • Joined: 05 Dec 2012

Can you explain what's the purpose of this? Why would you "obfuscate" your AHK code? I don't understand.

thn. Kangaroo

 

 



Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

One reason to obfuscate program code is to protect your intellectual property. You don’t want someone else to decompile your code and use pieces or all of it as he wishes. Though you can’t prevent someone from decompiling your code, if he can’t understand the code, your coding secrets may remain secret. He may decide to not use any of your code in his own programs if he cannot figure out what the various parts of your code do.

 

professional obfuscators already exist for java and .NET

 

http://www.red-gate....CFQSf4AodAgMAFQ

 

http://web.archive.o...V/Article/11351

http://www.excelsior...bfuscators.html



trueski
  • Members
  • 121 posts
  • Last active: Jun 25 2014 09:12 PM
  • Joined: 08 Apr 2008

This looks like it would be pretty effective. You could make it even more confusing by using characters that almost look identical, such as 

 

ὋὌῸΌ

-trueski-

Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

one thing i thought of afterwards is all the obfusticated object names could randomly start with either the letter l or the letter O and then all the rest of the obfuscated object name would be constructed of random ones and zeros:

l1011001100101010:=O011010101010101010

that's actually a variable starting with the letter l being set equal to a variable starting with the letter O! those letters might look nearly identical to ones and zeros on your system especially with a monospace font like the code box above uses.

l00110101110101010101010(O0010101011101010, O110110100101010)

function call simulated above

 

same function call with security fragments inserted below:

l0%l0011101010111101010%1101%O000111101010111101%11101%l01010101011010%1010101010(O%l1110000110101010%00101%O01010101010%01011101010, O1%l1010101010111101%101%l111011101010%10100%O0101011111111000%101010)

obfuscated binary object names!



Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

I uploaded the obfuscator to github:

https://github.com/d...tkey-obfuscator

 

-fixed some bugs

-fixed problem with hotkeys with spaces in them

-fixed problem with obfuscating literal strings

 



tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Interesting script you have here, Dave-
Very useful, but it's like a dual edged blade, it will be harder to detect malicious code inside a script tongue.png


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
thanks for the update

Bugz000
  • Members
  • 155 posts
  • Last active: Oct 14 2015 01:03 PM
  • Joined: 24 Feb 2011

i'm looking to convert this entire script to a single function, no GUI needed - i'll get back to you with the code :)


n39peTm.jpg
Hire me to write your code! (join IRC or PM me for details)


Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

if you guys have a problem with using the program feel free to post it here.

 

tomoe, the obfuscation will hide your programs detection of it's own integrity. If your program is running as a script then it can do tests to make sure it is running on your development computer only. If it is running as a compiled program then it can do tests like checking its own size and crc. i saw an interesting script on this board where an autohotkey script can retrieve it's own code signing certificate and i'm going to start using that one.

 

you can make your code integrity checks into functions which you can then sprinkle throughout the main running parts of your program. these techniques will make it very, very difficult for someone to inject malicious code into your script. if they extract the script from the exe, it will not run, it will just go down a rabbit hole. if they change a single byte then recompile, it will not run.

 

the problem with exe wrap protector programs is that they will give false virus positives for autohotkey scripts. i tried using enigma protector on a script and i was unable to upload it to cnet.com (upload.com) because it said i had a virus! it came up with 12 false virus positives on virustotal.com! using my system you will not get any false virus positives on your script.

 

 

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
i just tried it with all the defaults, no checkboxes checked. i ran the translation Map and then obfuscate and tried to run. i added those 5 lines for the simple straight obfuscation at the top and then i added the END_AUTOEXEC line as well. adding those to my source fixed my initial problems of "This variable/function has an illegal character". so thats good

suggestions for above:
1. a checkbox for 'simple straight obfuscation' which checks for the 5 comment commands at the top and adds them if they are not there.
2. if END_AUTOEXEC comment command is missing, then prompt user
3. make the gui fonts smaller. i'm on 125% scaling in windows and the gui buttons for the obfuscate window were cut off at the bottom

anyway...

now, i'm getting this error

"Unsupported parameter default"
;FUNCTION ORIGINAL NAME: IsItemInList
kfffk#[email protected]@kf([email protected]#k#[email protected], kffkk#[email protected]#, ffffffffk#[email protected]#[email protected],[email protected]#[email protected]) { 
   Loop, Parse, kffkk#[email protected]#, %k#kfkfkffkfkk#fkffk#fk%ÿffffffk#fkfk%%[email protected]@ffffk#[email protected]%
   {
      if (A_LoopField = [email protected]#k#[email protected])
         return true
   }
   return false
}
original:
IsItemInList(item, list, del=",")
{
   Loop, Parse, list, %del%
   {
      if (A_LoopField = item)
         return true
   }
   return false
}


Dave-
  • Members
  • 46 posts
  • Last active: May 17 2013 04:57 PM
  • Joined: 30 Nov 2010

i like your ideas guest3456! i have regretted not making it default to straight obfuscation for the public version of this and i like your idea about the END_AUTOEXEC tag as well.

 

the problem with your code is no doubt the fact that your parameter default is a comma. when my obfuscator finds a new function section, it parses off the parameters by grabbing whatever is between the () and executing line 308 in my include file 'OBFcreatetransmap.ahk':

 

Loop, Parse, paramslist, `,, %A_Space%%A_Tab%
 

it just simply parses the parameters by splitting it by commas. so that means my program would have thought you had 4 parameters, not 3. in fact that is what i see in your obfuscated code. and then a variable ended up assigned as the default for the 3rd parameter which is not allowed by autohotkey and is the reason for the error message you got.

 

i'm not sure what i will do to fix the problem in my program but in the meantime this should work to fix your code:

IsItemInList(item, list, del="")
{
if (!del)
    del:=","
Loop, Parse, list, %del%
{
    if (A_LoopField = item)
        return true
}
return false
}