 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tic
Joined: 22 Apr 2007 Posts: 1336
|
Posted: Fri Sep 28, 2007 11:37 am Post subject: AHKompile v1.01 - Automated secure compiling |
|
|
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
}
|
|
|
| Back to top |
|
 |
Thalon
Joined: 12 Jul 2005 Posts: 640
|
Posted: Fri Sep 28, 2007 2:45 pm Post subject: |
|
|
| 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
SacredVault |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1149 Location: USA
|
Posted: Fri Sep 28, 2007 2:50 pm Post subject: |
|
|
| 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. _________________
 |
|
| Back to top |
|
 |
olfen
Joined: 04 Jun 2005 Posts: 99 Location: Stuttgart, Germany
|
Posted: Fri Sep 28, 2007 6:11 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1336
|
Posted: Fri Sep 28, 2007 6:20 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
olfen
Joined: 04 Jun 2005 Posts: 99 Location: Stuttgart, Germany
|
Posted: Fri Sep 28, 2007 6:30 pm Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1336
|
Posted: Fri Sep 28, 2007 7:13 pm Post subject: |
|
|
| 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) |
|
| Back to top |
|
 |
olfen
Joined: 04 Jun 2005 Posts: 99 Location: Stuttgart, Germany
|
Posted: Fri Sep 28, 2007 7:22 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Oct 16, 2007 8:34 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|