Script Dehumanizer

Post your working scripts, libraries and tools.
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Script Dehumanizer

15 Nov 2023, 09:52

I was thinking of mo old ipod, and how crappy apple handles all the data.
They made it inhumane to play music if you connected it as a harddisk and want tu use your default player to play it.
Randomly putting music in a 2 character hex folder, and naming the files similar.

So i was inspired to do the same with Scripts, imagine someone get's your 6000 lines of code and want to steel it.
If it is compiled like this one below, good luck.

The full source code :lol:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force
#Warn All
Ox139E19:=A_ScriptFullPath
OxB6BFA0:=Ox139E19?"":" "
FileExist(Ox139E19)?"":Exitapp()
SplitPath(Ox139E19,&OxE25762,&Ox0CD1B8,&Ox0707C1,&OxF343CE,&Ox9052FD)
Ox65097D:=Ox139E19
OxB08500:= Ox0CD1B8 "\" OxF343CE ".OxDExED.ahk"
Ox2330A4:= Ox0CD1B8 "\" OxF343CE ".OxDExED.ini"
Try {
OxE5AEBD:=FileRead(Ox65097D)
OxBAC175:=FileRead(Ox0CD1B8 "\" OxF343CE ".ini")
}
Ox48C5C1(&OxE5AEBD,&OxBAC175)
Msgbox OxE5AEBD
Ox48C5C1(&Ox25D15B,&OxCC18B8:=""){
Ox25D15B:=RegExReplace(Ox25D15B,"`amis)^\s*/\*.*?\*/")
Ox25D15B:=RegExReplace(Ox25D15B,"`amis)^\s*;.*?$")
Ox25D15B:=RegExReplace(Ox25D15B,"`amis)\s+;.*?$")
Ox25D15B:=RegExReplace(Ox25D15B, "`amis)\)\s*\{","){")
Ox25D15B:=RegExReplace(Ox25D15B, "`amis)^\s*")
Ox25D15B:=RegExReplace(Ox25D15B, "`amis)\s*$")
For , L_Value in ["**","+","-","~","&","?",":",":=",".=","+=","-=","//"] {
Ox25D15B:=StrReplace(Ox25D15B," " L_Value " ",L_Value)
Ox25D15B:=StrReplace(Ox25D15B," " L_Value    ,L_Value)
Ox25D15B:=StrReplace(Ox25D15B,    L_Value " ",L_Value)
}
Ox16EE87:=1
While Ox2B9974:=RegExMatch(Ox25D15B,"`amis)(\w+)(?<!Ox\w{6})(:=|\+=|\.=)",&Ox0F2FC7,Ox16EE87){
Ox16EE87:=Ox2B9974+8
Ox05FDAC:=Ox69439A()
Ox25D15B:=StrReplace(Ox25D15B,Ox0F2FC7[1],Ox05FDAC)
}
Ox16EE87:=1
While Ox2B9974:=RegExMatch(Ox25D15B,"`amis)&(\w+)(\?|,|\))",&Ox0F2FC7,Ox16EE87){
Ox16EE87:=Ox2B9974+8
If RegExMatch(Ox0F2FC7[1],"Ox\w{6}")
Continue
Ox05FDAC:=Ox69439A()
Ox25D15B:=StrReplace(Ox25D15B,Ox0F2FC7[1],Ox05FDAC)
}
Ox317F07:="i)^(Static\s)?(?P<Function>\w+)[(](?:.*[)](?=\s*(\{|=>)))"
Ox16EE87:=1
While Ox2B9974:=RegExMatch(Ox25D15B,"mi)^(Static\s)?(?P<Function>\w+)[(](?:.*[)](?=\s*(\{|=>)))",&Ox0F2FC7,Ox16EE87){
Ox16EE87:=Ox2B9974+8
If RegExMatch(Ox0F2FC7.Function,"Ox\w{6}")
Continue
If Ox0F2FC7.Function~= "i)(__New|__Get|__Set|__Call|__Item|__Enum|__Delete)"
Continue
Ox05FDAC:=Ox69439A()
Ox25D15B:=StrReplace(Ox25D15B,Ox0F2FC7.Function,Ox05FDAC)
}
Ox25D15B:=RegExReplace(Ox25D15B, "`ami)^[ `t\R]*\R+")
}
Ox69439A(){
Static Ox7D601C:=Map()
While (Ox05FDAC:=Format("Ox{:06X}", Random(0x000000, 0xFFFFFF)),Ox7D601C.Has(Ox05FDAC))
Continue
Ox7D601C[Ox05FDAC]:=1
Return  Ox05FDAC
}
Any contributors? :lol: :lol:
Good tips are welcome
Last edited by emmanuel d on 15 Nov 2023, 10:00, edited 1 time in total.
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: Script Dehumanizer

15 Nov 2023, 09:59

Ps change A_ScriptFullPath for your own file, and copy the text from the msgbox
User avatar
andymbody
Posts: 937
Joined: 02 Jul 2017, 23:47

Re: Script Dehumanizer

15 Nov 2023, 14:03

This looks like the result of the obfuscator, rather than the source code for it? Is this correct?
User avatar
emmanuel d
Posts: 90
Joined: 17 Nov 2013, 04:45

Re: Script Dehumanizer

15 Nov 2023, 14:12

:lol: both, source and obfuscated
but let me give you the readable version, for in case you are afraid to execute:

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance force   
#Warn All
G_File := A_ScriptFullPath
Test := G_File?"":" " ; this is nothing
FileExist(G_File) ? "" : Exitapp()
SplitPath(G_File,&G_ScriptNameExt,&G_ScriptDir,&G_ScriptExt,&G_ScriptName,&G_ScriptDrive)
G_ScriptFullPath := G_File
G_PathNewAhk :=  G_ScriptDir "\" G_ScriptName ".OxDExED.ahk" ; OxDExED
G_PathNewIni :=  G_ScriptDir "\" G_ScriptName ".OxDExED.ini"
Try {
  ; FileRecycle(G_ScriptFullPath ".Dehumanized.ahk")
  ; FileCopy(G_ScriptFullPath                   , G_PathNewAhk, 1) ; overwrite
  ; FileCopy(G_ScriptDir "\" G_ScriptName ".ini", G_PathNewIni, 1) ; overwrite
  G_Ahk := FileRead(G_ScriptFullPath)
  G_Ini := FileRead(G_ScriptDir "\" G_ScriptName ".ini")
  }

Dehumanizer(&G_Ahk,&G_Ini)
Msgbox G_Ahk
/* Exclude Meta functions
  __New|__Get|__Set|__Call|__Item|__Enum|__Delete
  New
  Get
  Set
  Call
  Item
  Enum
*/
/* Steps & Naming
  1 Remove CommentLines
  2 Remove Comment blocks
  3 Remove Inline comments
  Classes   => OxC12345
    Class( <= Initializing
    Class. <= Direct call
      StrReplace(Haystack,"Class(","OxC1234567(")
      StrReplace(Haystack,"Class.","OxC1234567.")
      StrReplace(Haystack,"Class","OxC1234567") <= Unsafe, Example Class MI And MI_App_Exit()
      RegExReplace(Haystack, "([^\w])Class([^\w])","$1OxC1234567$2")
 Functions => OxF1234567
  Variables => OxBFFFFF
  !!! Ini 
*/
; Create a list to reverse the change
; Hexadecimal 
; Msgbox Format("{1:#x} {2:X} 0x{3:x}`r`n", 3735928559, 195948557, 0)
; Loop 5
  ; Msgbox(CreateHex())
; Msgbox "Class Ox" . Format("{: 06X}", Random(0x000000, 0xFFFFFF)) ;returns  0001.
; Msgbox "Class Ox" . Format("{: 06X}", Random(0xC00000, 0xCFFFFF)) ;returns  0001.
; Msgbox "Func  Ox" . Format("{: 06X}", Random(0xF00000, 0xFFFFFF)) ;returns  0001.
; OxF1234567
; Ox Random(0, 0xFFFFFF)
Dehumanizer(&B_Ahk,&B_Ini:=""){
  B_Ahk := RegExReplace(B_Ahk,"`amis)^\s*/\*.*?\*/") ; Remove Comment Block
  B_Ahk := RegExReplace(B_Ahk,"`amis)^\s*;.*?$")   ; Remove Comment Lines
  B_Ahk := RegExReplace(B_Ahk,"`amis)\s+;.*?$")   ; Remove InlineComments
  B_Ahk := RegExReplace(B_Ahk, "`amis)\)\s*\{","){") ; Remove Space between ) and { Also removes the newline between functioncall() and {
  B_Ahk := RegExReplace(B_Ahk, "`amis)^\s*") ; Remove indentation
  B_Ahk := RegExReplace(B_Ahk, "`amis)\s*$") ; Remove WhiteSpace at the end of the line
  For , L_Value in ["**","+","-","~","&","?",":",":=",".=","+=","-=","//"] { ; Operators
    B_Ahk := StrReplace(B_Ahk," " L_Value " ",L_Value) ; Remove  spaces
    B_Ahk := StrReplace(B_Ahk," " L_Value    ,L_Value) ; Remove  spaces
    B_Ahk := StrReplace(B_Ahk,    L_Value " ",L_Value) ; Remove  spaces
    }
    
  L_StartPos := 1
  While L_FoundPos := RegExMatch(B_Ahk,"`amis)(\w+)(?<!Ox\w{6})(:=|\+=|\.=)",&L_OutputVar,L_StartPos) { ; Variable Assignments
    L_StartPos := L_FoundPos + 8
    L_Hex := CreateHex()
    B_Ahk := StrReplace(B_Ahk,L_OutputVar[1],L_Hex)
    }
    ; MsgBox(L_OutputVar[1], A_ThisFunc, 262144)
  L_StartPos := 1
  While L_FoundPos := RegExMatch(B_Ahk,"`amis)&(\w+)(\?|,|\))",&L_OutputVar,L_StartPos) { ; Function parameters
    L_StartPos := L_FoundPos + 8 ; 8 lenght of hex
    If RegExMatch(L_OutputVar[1],"Ox\w{6}") ; Skip If already converted
       Continue   ;MsgBox("Cancel? " L_OutputVar[1], A_ThisFunc, 262144)
    L_Hex := CreateHex()
    B_Ahk := StrReplace(B_Ahk,L_OutputVar[1],L_Hex)
    }
    ; MsgBox(L_OutputVar[1], A_ThisFunc, 262144)
	L_RegexFunc  := "i)^(Static\s)?(?P<Function>\w+)[(](?:.*[)](?=\s*(\{|=>)))" ; Added => 

  L_StartPos := 1
  While L_FoundPos := RegExMatch(B_Ahk,"mi)^(Static\s)?(?P<Function>\w+)[(](?:.*[)](?=\s*(\{|=>)))",&L_OutputVar,L_StartPos) { ; Function parameters
    L_StartPos := L_FoundPos + 8 ; 8 lenght of hex
    If RegExMatch(L_OutputVar.Function,"Ox\w{6}") ; Skip If already converted
       Continue   ;MsgBox("Cancel? " L_OutputVar[1], A_ThisFunc, 262144)
    If L_OutputVar.Function ~= "i)(__New|__Get|__Set|__Call|__Item|__Enum|__Delete)"
      Continue
    L_Hex := CreateHex()
    B_Ahk := StrReplace(B_Ahk,L_OutputVar.Function,L_Hex)
    ; MsgBox(L_OutputVar.Function, A_ThisFunc, 262144)
    }
  B_Ahk := RegExReplace(B_Ahk, "`ami)^[ `t\R]*\R+") ; Remove empty lines
  }
CreateHex(){ 
  Static S_mHex := Map() 
  While (L_Hex := Format("Ox{: 06X}", Random(0x000000, 0xFFFFFF)),S_mHex.Has(L_Hex))
    Continue
  S_mHex[L_Hex] := 1
  Return  L_Hex
  }
User avatar
andymbody
Posts: 937
Joined: 02 Jul 2017, 23:47

Re: Script Dehumanizer

15 Nov 2023, 14:57

Cool... thanks... I will play with it later.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: Script Dehumanizer

15 Nov 2023, 19:12

The approach I use and implemented some months ago is the following :

The "encryption" function replaces common ASCII characters with emojis. It looks totally like gibberish.

Then the decryption function loads the ahk file to be "décrypted" and then replaces all those emojis back to ASCII. Runs the script and deletes it. So you barely have a chance to catch the file.

I made this more complicated than this, but this is the main part.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: Archimede and 13 guests