AutoHotkey Community

It is currently May 25th, 2012, 4:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: September 28th, 2007, 11:37 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
This is extreme beta, as there are many things I would want to implement, but am finding it difficult to proceed as currently listviews are too weak.

Supports drag and drop for folders and files. Will allow randomly generated secure passwords based on findings from Thalon.

Useful for large projects as constant recompiling can be quickened and passwords automated.

Thanks to Thalon for giving me the information on passwords necessary for this and majkinetor for icon dialogue.

Update:

1.01 - Trailing quoatation removed when password specified. added ability to move up and down to choose order of compilation. Finds ahk2exe.exe for registry.

Code:
;#############################################################################################################
;#############################################################################################################

;AHKompile v1.01 by Tariq Porter

;#############################################################################################################
;#############################################################################################################

#Persistent
#SingleInstance, Force
DetectHiddenWindows, On
SetTitleMatchMode, Regex
SetTitleMatchMode, Slow
SetWinDelay, 0
Process, Priority,, High
SetBatchLines, 0

AppName := "AHKompile"
VersionNumber := "1.01"
Space := "                                                                          "
RegRead, Compiler, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Ahk2Exe.exe


1RString := "#$'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~"
OddBall := "ß§°´²³äöü"
StringSplit, 1RStringArray, 1RString
StringSplit, OddBallArray, OddBall

;#############################################################################################################

Gui, 1: Add, ListView, x10 y10 w680 h300 vMyListView gMyListView NoSort -LV0x10 NoSortHdr +AltSubmit Count10 Checked, Compile | Icon | AHK%Space% | Password%Space%
LV_ModifyCol(3, "AutoHdr Left")

Gui, 1: Add, Button, x10 y330 w75 r1 -Multi -Wrap gClear, &Clear
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gDelete, &Delete
Gui, 1: Add, Button, x+10 y330 w75 r1 -Multi -Wrap gGenerate, &Generate
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gIcon, &Icon...
Gui, 1: Add, Button, x+40 y330 w75 r1 -Multi -Wrap gMoveUp, &MoveUp
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gMoveDown, &MoveDown
Gui, 1: Add, Button, x+245 y330 w75 r1 -Multi -Wrap gCompile, &Compile
Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap gExit, &Exit

Gui, 1: Show, w700 h405, %AppName% settings - %VersionNumber%
Return

;#############################################################################################################

MoveUp:
RowHighlighted := LV_GetNext(0,"Focused")

If RowHighlighted = 1
Return

Direction := RowHighlighted - 1
GoSub, Move
Return

;#############################################################################################################

MoveDown:
RowHighlighted := LV_GetNext(0,"Focused")
Direction := RowHighlighted + 1
GoSub, Move
Return

;#############################################################################################################

Move:
If RowHighlighted <= 0
Return

NumberRows := LV_GetCount()

If NumberRows = 1
Return

NextChecked := LV_GetNext(RowHighlighted-1, "Checked")
If NextChecked = %RowHighlighted%
NextChecked = 1
Else
NextChecked = 0

LV_GetText(AHK, RowHighlighted, 3)
LV_GetText(Password, RowHighlighted, 4)

LV_Delete(RowHighlighted)
If NextChecked = 1
LV_Insert(Direction, "Check Focus Select Vis Col3", AHK, Password)
Else
LV_Insert(Direction, "Focus Select Vis Col3", AHK, Password)
Return

;#############################################################################################################

Delete:
Gui, 1: Submit, NoHide
NumberRows := LV_GetCount()

RowNumber =
Loop
{
    RowNumber := LV_GetNext(0)
   
    If !RowNumber
    Break
   
   LV_Delete(RowNumber)
}
Return

;#############################################################################################################

Clear:
LV_Delete()
Return

;#############################################################################################################

Compile:
CheckFocus = Checked
GoSub, CheckEnable

BatContents =
Loop, %ActiveNum%
{
   LV_GetText(Source, CheckedBox%A_Index%, 3)      ; Source
   LV_GetText(Password, CheckedBox%A_Index%, 4)   ; Password
   
   If Password
   FullPassword := " /pass " . """" . Password . """"
   
   BatContents .= """" . Compiler . """" . " /in " . """" . Source """" . FullPassword . " /nodecompile`n"
}
BatContents .= "del " . """" . A_ScriptDir . "\compile.bat" . """"
;MsgBox, %BatContents%

FileDelete, %A_ScriptDir%\compile.bat
FileAppend, %BatContents%, %A_ScriptDir%\compile.bat
Run, %COMSPEC% /c "%A_ScriptDir%\compile.bat"   ; ,,Hide can be added when script finished
Return

;#############################################################################################################

CheckEnable:
Gui, 99: Submit, NoHide

NumberRows := LV_GetCount()

ActiveNum =
RowNumber = 0
Loop
{   
   If CheckFocus = Checked
   CheckedBox%A_Index% := LV_GetNext(RowNumber, "Checked")
   If CheckFocus = Selected
   CheckedBox%A_Index% := LV_GetNext(RowNumber)
   RowNumber := CheckedBox%A_Index%
   
   If !CheckedBox%A_Index%
   Break

   ActiveNum++
}
Return

;#############################################################################################################

Exit:
ExitApp
Return

;#############################################################################################################

MyListView:
Return

;#############################################################################################################

Icon:
NumRows := LV_GetCount()
RowHighlighted := LV_GetNext(0,"Focused")
hwndA := DllCall("GetActiveWindow")
CmnDlg_ChooseIcon(icon, idx, hwndA)
ImageListID := IL_Create(10, 10)
;LV_SetImageList(ImageListID)            ; Not implemented until icon can be moved to 3rd column
;IL_Add(ImageListID, icon, idx)
;LV_Modify(RowHighlighted, "Col3 Icon1")
Return

;#############################################################################################################

Generate:

CheckFocus = Selected
GoSub, CheckEnable

Loop, %ActiveNum%
{
   Loop, %OddBallArray0%
   Random, 1ON%A_Index%, 1, 30

   2RString =
   Loop
   {
      If A_Index in %ON1%,%1ON2%,%1ON3%,%1ON4%,%1ON5%,%1ON6%,%1ON7%,%1ON8%,%1ON9%
      {
         Random, 2ON, 1, %OddBallArray0%
         2RString .= OddBallArray%2ON%
      }
      Else
      {
         Random, RNum, 1, %1RStringArray0%
         2RString .= 1RStringArray%RNum%
      }   
   
      If StrLen(2RString) >= 30
      Break
   }   
   
   LV_Modify(CheckedBox%A_index%, "Col4", 2RString)
}   
Return

;#############################################################################################################

GuiDropFiles:
Gui, 1: -Redraw
Loop, Parse, A_GuiEvent, `n
{
   Loop, %A_LoopField%\*.ahk, 0, 1
   LV_ADD("Col3 Check", A_LoopFileFullPath)

   SplitPath, A_LoopField,,, Extension
   If Extension = ahk
   LV_ADD("Col3 Check", A_LoopField)
}
LV_ModifyCol(3, "AutoHdr")
LV_ModifyCol(4, "AutoHdr")
Gui, 1: +Redraw
Return

;#############################################################################################################

CmnDlg_ChooseIcon(ByRef sIcon, ByRef idx, hGui=0)
{     
   global      
   idx--

    VarSetCapacity(wIcon, 1025, 0)
    If sIcon
    {
        r := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "Str", sIcon, "Int", StrLen(sIcon), "UInt", &wIcon, "Int", 1025)

        If !r
        Return false
    }
   
   r := DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "str", "shell32.dll"), "Uint", 62), "uint", hGui, "uint", &wIcon, "uint", 1025, "intp", idx)
   If !r
    Return false

   len := DllCall("lstrlenW", "UInt", &wIcon)
   VarSetCapacity(sIcon, len, 0)
   r := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", &wIcon, "Int", len, "Str", sIcon, "Int", len, "UInt", 0, "UInt", 0)

    If !r
    Return false

   idx++
   
    Return true
}
 


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 2:45 pm 
Offline

Joined: July 12th, 2005, 1:21 pm
Posts: 633
Quote:
Finds ahk2exe.exe for registry.
You should obey, that it isn't necessary to use the AHK-installer. Some users here will therefore not have the registry entry. Maybe there should be a FileSelectFile for the case that the registry-item doesn't exist...

Thalon

_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 2:50 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Thalon wrote:
You should obey, that it isn't necessary to use the AHK-installer. Some users here will therefore not have the registry entry. Maybe there should be a FileSelectFile for the case that the registry-item doesn't exist...

Agreed, as I am one of the above.

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 6:11 pm 
Offline

Joined: June 4th, 2005, 1:30 am
Posts: 113
Location: Stuttgart, Germany
Hmm... I don't really understand what this is all about. The password chosen doesn't make any difference, when reading the ahk source from process memory, and there is many ways to do that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 6:20 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
olfen wrote:
Hmm... I don't really understand what this is all about. The password chosen doesn't make any difference, when reading the ahk source from process memory, and there is many ways to do that.


yes but this isnt for stopping it being read from memory, this stops decompilation with methods that are currently used. I am working on stopping the program being read from memory


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 6:30 pm 
Offline

Joined: June 4th, 2005, 1:30 am
Posts: 113
Location: Stuttgart, Germany
tic wrote:
I am working on stopping the program being read from memory
I doubt that this is possible. How do you want to prevent dumping of RAM?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 7:13 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1832
Quote:
I doubt that this is possible. How do you want to prevent dumping of RAM?


come on. use a bit of imagination. you dont need to prevent the dumping of ram. you just need to make it so none of these programs will be able to run whilst your program is running (finding these programs with on-access scan of memory)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2007, 7:22 pm 
Offline

Joined: June 4th, 2005, 1:30 am
Posts: 113
Location: Stuttgart, Germany
tic wrote:
come on. use a bit of imagination. you dont need to prevent the dumping of ram. you just need to make it so none of these programs will be able to run whilst your program is running (finding these programs with on-access scan of memory)
Execution of AHK script code detecting memory dumping procedures can easily be circumvented by creating the myscript.exe process suspended using simple WinAPI.
Process memory can be read before AHK script is processed.

Edit: I just tried with a debugger: a compiled AHK's process memory can easily be put into RAM, to read its AHK source from memory, without giving any AHK protection code the chance to ever run.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2007, 8:34 am 
This is reminiscent of a debate that raged back and forth on the AutoIt website.

The trick is you have to convert the English readable script into something non-readable and coded, but can still be executable. This way doing a memory dump does you no good, because what is there looks like jibberish.

You need code obfuscation. It makes cracking code harder, but not impossible. You can never really protect code because it needs to execute as machine language which is convertable into assembly language. A person that understand assembly language can always figure out what it was doing, though it may take a long time and be really hard. Anyway, obfuscation is a first step.

However, to completely tighten this up, you have to modifiy Autohotkey itself versus just making an obfuscation script.


Report this post
Top
  
Reply with quote  
PostPosted: May 11th, 2009, 10:57 pm 
Offline

Joined: May 11th, 2009, 10:43 pm
Posts: 1
At best I am a novice with AHK, so forgive my ignorance. I have a number of small AHK scripts that compile into separate EXEs so AHKcompile is a great tool for quickly processing all of my files. I am looking to do 2 things:

1. Enable the selection of a different icon (Mostly single Icon file, all in .ico format) for each AHK I have selected to compile.

2. Save a configuration file so I can reprocess my list of files as necessary. (and load/modify said file accordingly)

To that end: I see this thread has been idle for quite a while and I am wondering if these things can be done due to the quoted text below and the fact that the comment in the code below hasn't been addressed.

Can anyone help me out?

tic wrote:
This is extreme beta, as there are many things I would want to implement, but am finding it difficult to proceed as currently listviews are too weak.


Code:
Icon:
NumRows := LV_GetCount()
RowHighlighted := LV_GetNext(0,"Focused")
hwndA := DllCall("GetActiveWindow")
CmnDlg_ChooseIcon(icon, idx, hwndA)
ImageListID := IL_Create(10, 10)
;LV_SetImageList(ImageListID)            ; Not implemented until icon can be moved to 3rd column
;IL_Add(ImageListID, icon, idx)
;LV_Modify(RowHighlighted, "Col3 Icon1")
Return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, Google Feedfetcher, Rajat, sarevok9, Wicked, XX0 and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group