[TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

Post your working scripts, libraries and tools
AHKtreasureland
Posts: 9
Joined: 12 Mar 2018, 10:30

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

23 Jun 2018, 15:21

I'm amazed at the way it works. truly amazed. have one question, Don. Would it work with AHK_H? I kinda need that multithread power of H. Thank you again, Don.
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

25 Jun 2018, 10:47

HI, thanks for the feedback.

I didn't use ahk_h for now but I would say that normally the obfuscator should work without problem on AHK_H.

Nevertheless I think it would not work with AHK v2 or AHK_H v2 because there are major syntax changes the obfuscator will probably not recognize.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
DDook

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

28 Jul 2018, 15:30

Obfuscation is very good. There is one problem.
Gui's Glabel is obfuscated just like label:.
This is obfuscation of the source in my example.

Code: Select all

gui, add, button, xm y+20 G[b]k#fkfk@k#kk@f@@f@kk#k@k@@fkkk##k@k[/b], Test gui submit
	gui, add, button, x+20 yp G#fkkfkfkkfkkfff#fkff@kff@kf@k@, Cancel program
	gui, show
}


;LABEL ORIGINAL NAME: testguisubmit
[b]k#fkfk@k#kk@f@@f@kk#k@k@@fkkk##k@k[/b]:
	gui, submit, nohide
	msgbox, TESTING OBF OF Vvariablename IN 'gui, add':`n`nyou entered "%kfk#kfff%%f#kff#@fk@%%k@#kk##f%"
return
This is a source already obfuscated to the example.

Code: Select all

gui, add, button, xm y+20 G[b]fkfk%f@fffk%%fffff@%%f@fkkf%kff@%k#f@k#k#f@k#kfkfk#fkfffk%f%fkk#ffk#ffffk#fffkfkfkf@%fk#fkkfffk#ff[/b], Test gui submit
	gui, add, button, x+20 yp G%kff@f@k#fkffffffffk#f@f@k#k#%%k#f@k#fk%%fff@kf%, Cancel program
	gui, show
}


;LABEL ORIGINAL NAME: testguisubmit
[b]fkfkkff@ffkfk#fkkfffk#ff[/b]:
	gui, submit, nohide
	msgbox, TESTING OBF OF Vvariablename IN 'gui, add':`n`nyou entered "%fkf@k#k#%%kfkfk#kfk#%%fff@k#fk%"
return
What is the solution to this?
What am I doing wrong?
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

29 Jul 2018, 08:46

Hello DDook,

I'm not sure to understand.
It seems you provide two obfuscated script parts. Where is the unobfuscated original source code?

Which example exactly are you using? I had to search for it, there are several : "min-straight-obfuscation"?
If yes then if you create the TransMap for "straightobf.ahk", then run the obfuscation, you will see that gLabels are obfuscated correclty.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
DDook

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

29 Jul 2018, 15:09

Thank you for your reply.
This is part of the code in your example (mindynobf_obfuscated.ahk).

Code: Select all

k#kfk#ffk#f@kfk#() { 
	global
	local fff@kfffkff@k#kffkff, fff@f@k#f@k#k#k#kf, fkk#fffkk#fkfkkfff, f@fffkk#kffffk
;$OBFUSCATOR: $DEFLOSVARS: ff%kff@fk%f%f@fff@fk%@k%f@f@f@k#kfkfkff@k#k#%ff%ffk#ff%kff@k#kffkff, fff@f%ffk#ffk#%%k#k#kfffffkff@fkffff%k#f@k%k#f@fffk%#k#k#kf, fkk#ff%f@k#k#fkfffkffk#f@%%kfff%%kffff@%kk#fkfkkfff, f@%ffkfkfkf%ff%fkk#k#%f%k#f@k#fkkffkk#f@f@kffffk%k#%kfkffkkffff@k#kf%%fffk%ffffk

	fff@k%k#f@fffffff@fkf@ff%ffkff%ffkf%@k#kf%k#f@kfffk#k#fkffkffk%kff 		= % "s22"
	ff%k#f@kfffk#k#fkffkffk%@f@%fffk%k#f%k#k#fffk%@%f@fk%k#k#k#kf 		= % "s18"	
	%ffk#%%k#ffffk#fkk#ffk#kfff%%f@fk% 	= % "s14"
	f@f%fffff@%ffkk%fffkff%#%ffkfffkffffkf@fk%ffffk := "from Dynamic Obfuscator"

	gui 2:default
	gui, destroy
	gui, margin, 20, 20
	
	;the h1font variable below should be obfuscated
	gui, font, %kfffk#%%fff@kfffkff@k#kffkff%%k#kfkf% bold
	gui, add, text, xm ym, Obfuscator Test GUI
	
	gui, font, %f@k#k#kf%%fkk#fffkk#fkfkkfff%%f@fkk#ff% norm underline
	;the gosub label below should be obfuscated
	gui, add, text, xm y+12 cblue G%fffkk#fkfkfkfkk#fkk#k#fkk#ff%%k#k#fkkf%%fkf@%, test gosub obfuscation in gui statement ;point3
	
	gui, font, %fkk#fffkk#fkfkkfff%%kfffff%%fkfffkff% norm
	gui, add, text, xm y+12 G%f@f@fkfk%kffff@%k#f@k#k#f@k#kfkfk#fkfffk%f%fffk%k#f@k#%k#f@k#fkkffkk#f@f@kffffk%#k#fkfffffffkfkffk#, ;point3
(
hello world

TESTING LITERAL STRING :
"%f@fffkk#kffffk%%f@f@fkfk%%k#ffff%"

-press home key to test hotkeys-
)
	gui, add, text, xm y+12, enter something here to test`nvariable obfuscation
;$OBFUSCATOR: $DEFGLOBVARS: %k#f@fk%kf%k#fffkf@%k%kfk#f@kff@ffkff@kf%k#%fkf@fkfff@k#f@f@fkk#%fk#
	gui, add, edit, xm y+2 V%fkk#ffk#ffffk#fffkfkfkf@%f%fkf@k#%kf%f@f@ffk#k#k#kfk#f@k#k#%%fkkf%#kfk# r4, 
		
	gui, add, button, xm y+20 Gfkfk%f@fffk%%fffff@%%f@fkkf%kff@%k#f@k#k#f@k#kfkfk#fkfffk%f%fkk#ffk#ffffk#fffkfkfkf@%fk#fkkfffk#ff, Test gui submit ;point1
	gui, add, button, x+20 yp G%kff@f@k#fkffffffffk#f@f@k#k#%%k#f@k#fk%%fff@kf%, Cancel program ;point2
	gui, show
}


;LABEL ORIGINAL NAME: testguisubmit
fkfkkff@ffkfk#fkkfffk#ff: ;point1
	gui, submit, nohide
	msgbox, TESTING OBF OF Vvariablename IN 'gui, add':`n`nyou entered "%fkf@k#k#%%kfkfk#kfk#%%fff@k#fk%"
return


;LABEL ORIGINAL NAME: cancelprog
fkfkfff@k#f@k#k#f@kffkk#f@: ;point2
	exitapp
return


;LABEL ORIGINAL NAME: guigosub
kffff@ffk#f@k#k#k#fkfffffffkfkffk#: ;point3
	msgbox, inside _guigosub_
return

This code is what I did (mindynobf.ahk).

Code: Select all

ff#ffkfkf#kfk@() { 
	global
	local @f@kkk#fk##fkk#ff#ff, f##fkf@f#kf##k, #ff@kfk@k@@kf#ffkk, k#fkkf#kkkkfk#@kf@ff
;$OBFUSCATOR: $DEFLOSVARS: @%@fk@#kfkk@ff@kfk#kkkf@%@%ffkf#f%kkk#fk##fkk#ff#ff, f#%f@#k%#fkf%f@@fk@ff@kfk@kkk#kffk#%f#kf##k, #f%f#k@f#f@f##kk#%@kf%#kkf@ffk@fk#ffkkk@kf%@k%fff#%@@%#ff@%kf#ffkk, k#f%f#@k@k%kkf#%k@@fkff#@ff@k#k#f@#k%%#fkkfk@fkff##ff#k#%kkfk#@kf@ff

	%f##k%%@kk@fk@kff#kff#fk@kkf#@f%%k#kkkfff% 		= % "s22"
	%@kfk@k%%#k#fk@@ff#f#k#kf@kf#%%f@k#k#% 		= % "s18"	
	%k#f@%%k#@f%%@fff@f@ff@kk#k% 	= % "s14"
	k#fkk%@fk@#kfkk@ff@kfk#kkkf@%#kkkkfk%@fkk@f%#@kf@ff := "from Dynamic Obfuscator"

	gui 2:default
	gui, destroy
	gui, margin, 20, 20
	
	;the h1font variable below should be obfuscated
	gui, font, %k@kk%%@f@kkk#fk##fkk#ff#ff%%@f@kkkf#% bold
	gui, add, text, xm ym, Obfuscator Test GUI
	
	gui, font, %k##kk@kf%%#ff@kfk@k@@kf#ffkk%%k##fk#% norm underline
	;the gosub label below should be obfuscated
	gui, add, text, xm y+12 cblue Gf#k#f@f@kfkffkfff#@k@kk@kf@kfk, test gosub obfuscation in gui statement ;point3
	
	gui, font, %#ff@kfk@k@@kf#ffkk%%#kkffkff%%#k#k% norm
	gui, add, text, xm y+12 Gf#k#f@f@kfkffkfff#@k@kk@kf@kfk, ;point3
(
hello world

TESTING LITERAL STRING :
"%fkff#k%%k#fkkf#kkkkfk#@kf@ff%%kkkffk#f%"

-press home key to test hotkeys-
)
	gui, add, text, xm y+12, enter something here to test`nvariable obfuscation
;$OBFUSCATOR: $DEFGLOBVARS: f#%fff@%%kf@kfffk@f@kf#kkk#%f%#ffk%f#@fk@
	gui, add, edit, xm y+2 Vf#kff#@fk@ r4, 
		
	gui, add, button, xm y+20 Gk#fkfk@k#kk@f@@f@kk#k@k@@fkkk##k@k, Test gui submit ;point1
	gui, add, button, x+20 yp G#fkkfkfkkfkkfff#fkff@kff@kf@k@, Cancel program ;point2
	gui, show
}


;LABEL ORIGINAL NAME: testguisubmit
k#fkfk@k#kk@f@@f@kk#k@k@@fkkk##k@k: ;point1
	gui, submit, nohide
	msgbox, TESTING OBF OF Vvariablename IN 'gui, add':`n`nyou entered "%kfk#kfff%%f#kff#@fk@%%k@#kk##f%"
return


;LABEL ORIGINAL NAME: cancelprog
#fkkfkfkkfkkfff#fkff@kff@kf@k@: ;point2
	exitapp
return


;LABEL ORIGINAL NAME: guigosub
f#k#f@f@kfkffkfff#@k@kk@kf@kfk: ;point3
	msgbox, inside _guigosub_
return
This code is from line 135 to line 193 of mindynobf_obfuscated.ahk.
Do you know the difference?
Look at the "point1","point2","point3" in the code.

The mindynobf_obfuscated.ahk originally in the example
Label: and Glabel do not match.
But my code is the same as Label: and Glabel.

What is the solution for this?
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

30 Jul 2018, 13:48

Hi DDook,

Alright I see now.
I've run some tests and it seems that there are indeed no %'s straight or dynamic vars introduced inside the names for gLabels or vVars no more.
It means I must have changed it at some point because it used to be obfuscated this way.

So that's an undocumented regression and that's on my side, not yours. Thanks for pointing that out.

To correct it would need a bunch of testing from my side but I currently do not have the ressources to do so (donations have been unfortunately non-existent...).
Maybe I'll be able to fix it in the future, I will update the post if I do.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Kmeaha

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

20 Aug 2018, 03:19

Dear Mr. DigiDon

thanks a lot for your project it is working great as i tried with straight and dynamic mode, perfect and smoothly
but when i tried the ihidestr() option it didn't work properly, i use your example (hidestring_example.ahk) and after testing to obfuscated with the gui it didn't give me the same result of your file (hidestring_example_obfuscated.ahk), the string 12 and text still showing after obfuscated
this is a part of your example:
;test obfuscation of parameters
;msgbox will show 12 if obfuscation of parameters works
msgbox, % "parameter: " . test_parameters(ihidestr("12"))

msgbox % "obfuscated text = " ihidestr("TEXT")

RETURN


and this is the result after obfuscated:
;test obfuscation of parameters
;msgbox will show 12 if obfuscation of parameters works
msgbox, % "parameter: " . #fkff%ffkkff%k@fkff@k#k@(fkf%@ff#f#%kk@#f@kk#("12"))

msgbox % "obfuscated text = " fkfk%@k#k%k@#f@kk#("TEXT")

RETURN


thanks again
DigiDon
Posts: 176
Joined: 19 May 2014, 04:55
Contact:

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

20 Aug 2018, 08:34

Hello Kmeaha,

You're right: The function should be named "hidestr" and not "ihidestr".

I forgot to modify the internal example. The online doc is OK though.

Thanks for pointing it out.
EverFastAccess : Take Notes on anything the Fast way: Attach notes, Set reminders & Speed up research in 1 gesture - AHK topic
AHK Dynamic Obfuscator L - Protect your AHK code by Obfuscation - AHK topic
QuickModules for Outlook : Sort Outlook emails very quickly to multiple folders - AHK topic

Coding takes lots of time and efforts. If I have helped you or if you enjoy one of my free projects, please consider a small donation :thumbup:
Kmeaha

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

21 Aug 2018, 09:00

Thanks for the reply Mr. DigiDon
now i tested and the obfuscated option working but giving me an error
the original script working fine but after obfuscated it is giving me an error
her is my full testing script:

Code: Select all

#SingleInstance force
#NoEnv

;$OBFUSCATOR: $STRAIGHT_MODE:

;$OBFUSCATOR: $DEFGLOBVARS: startdate,enddate,pcname

pcname := hidestr("hb1it014")
startdate := hidestr("20180801")
enddate := hidestr("20200801")

#r::
heckExpiry:
FormatTime, Today,, yyyyMMdd
Start  = %startdate%
Expiry = %enddate%
If (Today > Expiry or Today < Start)
{
		MsgBox % "PROGRAM trial version expired`nContact author for a full version ."
		ExitApp
}

If A_ComputerName != %pcname%
{
	MsgBox % "This is not the authorized computer: hb1it014."
	ExitApp
}

MsgBox % "Everything is running fine."
ExitApp

;$OBFUSCATOR: $END_AUTOEXECUTE: 
;******************************************
;	PUT THESE FUNCTIONS IN YOUR ACTUAL AUTOHOTKEY SCRIPT FILE

hidestr(thisstr)
{
	return thisstr
}


decode_ihidestr(startstr) 
{
	global	
;$OBFUSCATOR: $DEFGLOBVARS: hexdigits
	
	static newstr, startstrlen, charnum, hinibble, lownibble, mybinary
;$OBFUSCATOR: $DEFLOSVARS: newstr, startstrlen, charnum, hinibble, lownibble, mybinary

	hexdigits = % "0123456789abcdef"
		
	decode_hexshiftkeys(startstr)
	
	startstr = % substr(startstr, 1, 1) . substr(startstr, 6)
	startstrlen = % strlen(startstr)
		
	newstr = 
	loop, % strlen(startstr) 
		newstr = % substr(startstr, a_index, 1) . newstr
	
	startstr = % newstr
	newstr = 
	charnum = 1
	while true
	{
		if (charnum >startstrlen)
			break
			
		hinibble = % substr(startstr, charnum, 1)
		hinibble = % instr(hexdigits, hinibble) - 1
		
		lownibble = % substr(startstr, charnum + 1, 1)
		lownibble = % instr(hexdigits, lownibble) - 1
		
		hinibble := decode_shifthexdigit(hinibble)
		lownibble := decode_shifthexdigit(lownibble)
		
		mybinary = % hinibble * 16 + lownibble
		newstr .= chr(mybinary)
		
		charnum += 2		
	}
		
	newstr = % fixescapes(newstr)
		
	return, newstr	
}
decode_hexshiftkeys(startstr)
{
	global
;$OBFUSCATOR: $DEFGLOBVARS: decodekey, ishexchar, useshiftkey
	
	decodekey := "fff@kkf1ffkfkfkfff#k1fk@kf#@fffk@#kk"
	ishexchar := "fff@f1ff@kffkk#f1fffffkf"
	
	%decodekey%%ishexchar%1 = % substr(startstr, 2, 1)
	%decodekey%%ishexchar%2 = % substr(startstr, 3, 1)
	%decodekey%%ishexchar%3 = % substr(startstr, 4, 1)
	%decodekey%%ishexchar%4 = % substr(startstr, 5, 1)
	
	loop, 4
		%decodekey%%a_index% = % instr(hexdigits, %decodekey%%ishexchar%%a_index%) - 1
			
	useshiftkey = 0
}	

decode_shifthexdigit(hexvalue)
{
	global
	
	useshiftkey++
	if (useshiftkey > 4)
		useshiftkey = 1	
	
	hexvalue -= %decodekey%%useshiftkey%
	
	if (hexvalue < 0) 
		hexvalue += 16
		
	return hexvalue	
}

fixescapes(forstr)
{
	global
	
	StringReplace, forstr, forstr, % "````", % "``", all
	StringReplace, forstr, forstr, % "``n", % "`n", all
	StringReplace, forstr, forstr, % "``r", % "`r", all
	StringReplace, forstr, forstr, % "``,", % "`,", all
	StringReplace, forstr, forstr, % "``%", % "`%", all	
	StringReplace, forstr, forstr, % "``;", % "`;", all	
	StringReplace, forstr, forstr, % "``t", % "`t", all
	StringReplace, forstr, forstr, % "``b", % "`b", all
	StringReplace, forstr, forstr, % "``v", % "`v", all
	StringReplace, forstr, forstr, % "``a", % "`a", all
	
	StringReplace, forstr, forstr, % """""", % """", all
	
	return forstr
}
Kmeaha

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

21 Aug 2018, 09:15

thanks it is already solved

the problem was in line of decode as i forgot to change it to hidestr instead of ihidestr:
decode_ihidestr(startstr)
{
Bluscream
Posts: 5
Joined: 10 Jan 2017, 23:12
GitHub: Bluscream

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

14 Oct 2018, 02:28

I don't get it, why can't i just click one button and the whole script becomes obfuscated? I mean with java i can even do it online (https://javascriptobfuscator.com/Javasc ... cator.aspx)
guest3456
Posts: 2433
Joined: 09 Oct 2013, 10:31

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

14 Oct 2018, 09:31

I don't get it, why can't i just click one button and the whole script becomes obfuscated? I mean with java i can even do it online (https://javascriptobfuscator.com/Javasc ... cator.aspx)
go ahead and update this script for us, so we all can click one button and have the script obfuscated. once you attempt to do that, either 1. you'll have your answer as to why, or 2. you'll have been a better coder than those who have attempted it, and you will have achieved it for us.

Alibaba
Posts: 473
Joined: 29 Sep 2013, 16:15
Location: Germany

Re: [TOOL] AHK Dynamic Obfuscator L - Protect your code by Obfuscation

09 Nov 2018, 02:26

I don't get it, why can't i just click one button and the whole script becomes obfuscated? I mean with java i can even do it online (https://javascriptobfuscator.com/Javasc ... cator.aspx)
Good luck obfuscating Java with a JavaScript Obfuscator... :roll:
"Nothing is quieter than a loaded gun." - Heinrich Heine

Return to “Scripts and Functions”

Who is online

Users browsing this forum: SAbboushi and 36 guests