Created
July 4, 2018 18:36
-
-
Save LatinSuD/aab03067add1d92f327795c4586231bb to your computer and use it in GitHub Desktop.
Winbox Launcher in AutoHotKey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; REQUISITOS: | |
; Autohotkey 1.1.23 (o superior) | |
; Copiar a c:\winbox este script junto con: | |
; AutoXYWH.ahk | |
; BinReadWrite.ahk | |
; Hex.ahk | |
; Winbox.exe (una version reciente de Winbox) | |
; Generated by AutoGUI 2.2.6a | |
#NoEnv | |
#SingleInstance Force | |
SetWorkingDir %A_ScriptDir% | |
#Include %A_ScriptDir%\AutoXYWH.ahk | |
Gui +Resize | |
Gui Add, Text, x11 y13 w57 h23 +0x200, Búsqueda: | |
Gui Add, Edit, hWndhEdit1 x70 y15 w464 h21 vbusqueda gBUSCAR | |
Gui Add, ListView, hWndhSysListView1 x12 y54 w523 h394 vMyListView gDobleClick, IP|User|Notas|Indice | |
Gui Show, w545 h459, Winbox Launcher | |
Return | |
GuiSize: | |
If (A_EventInfo == 1) { | |
Return | |
} | |
AutoXYWH("w", hEdit1) | |
AutoXYWH("wh", hSysListView1) | |
;;;;;;;Return | |
; Do not edit above this line | |
SetWorkingDir,c:\winbox | |
#include c:\winbox\BinReadWrite.ahk | |
#include c:\winbox\Hex.ahk | |
; Leer archivo | |
ruta := A_AppData . "\Mikrotik\Winbox\Addresses.cdb" | |
;ruta := "c:\kkd\aa\kkf" | |
f := OpenFileForRead(ruta) | |
tocho = "" | |
ReadFromFile(f,tocho,0) | |
hex = "" | |
Bin2Hex(hex,tocho) | |
CloseFile(f) | |
semaforo := 0 | |
; Gestionar teclas | |
WM_KEYDOWN := 0x100, WM_SYSKEYDOWN := 0x104 | |
OnMessage( WM_KEYDOWN, "HandleMessage" ) | |
OnMessage( WM_SYSKEYDOWN, "HandleMessage" ) | |
Return | |
HandleMessage( wp, lp, msg, hwnd ) | |
{ | |
; 38 / 40 up down | |
; 13 intro | |
; 27 esc | |
;ControlFocus, Edit1, Winbox Launcher | |
if ( wp = 27 ) { | |
ExitApp | |
} | |
if ( wp = 38 ) { | |
ControlGetFocus, enfocado, Winbox Launcher | |
if (enfocado = "Edit1") { | |
GuiControl, Focus, MyListView | |
LV_Modify(0,"-Select") | |
LV_Modify(1,"Focus Select") | |
} | |
} else | |
if ( wp = 40 ) { | |
ControlGetFocus, enfocado, Winbox Launcher | |
if (enfocado = "Edit1") { | |
GuiControl, Focus, MyListView | |
LV_Modify(0,"-Select") | |
LV_Modify(1,"Focus Select") | |
} | |
} else | |
if ( wp = 13 ) { | |
actual := LV_GetNext(0) | |
if not actual { | |
Return | |
} | |
LV_GetText(ip, actual, 1) | |
LV_GetText(login, actual, 2) | |
LV_GetText(indice, actual, 4) | |
global passes | |
pass := passes[indice] | |
Run winbox %ip% %login% %pass% | |
;WinSetTitle, "VK: " . %ip% . " L " . %passx% | |
;WinSetTitle, % "VK: " . actual | |
} else { | |
ControlGetFocus, enfocado, Winbox Launcher | |
if (enfocado = "SysListView321") { | |
GuiControl, Focus, Edit1 | |
} | |
} | |
} | |
Return | |
BUSCAR: | |
Gui, Submit, NoHide | |
; MsgBox %busqueda% | |
LV_Delete() | |
; Parsear IP | |
;StringReplace,ip,busqueda,winbox:// | |
;StringReplace,ip,ip,/ | |
busq := busqueda | |
busqh := str2hex(busq) | |
;MsgBox,%ip% | |
;MsgBox %A_AppData% | |
; Preparar la busqueda de la IP | |
;len := FHex(StrLen(ip), 2) | |
;busq := "01000021" . len . str2hex(ip) | |
ptr_registro := 4 | |
TochoLen := StrLen(hex) | |
login := "x " | |
cuenta := 1 | |
global passes | |
passes := [] | |
While ptr_registro < TochoLen/2 { | |
len_reg:=FDec(SubStr(hex,ptr_registro*2+3,2) . SubStr(hex,ptr_registro*2+1,2) ) | |
if ( len_reg = 0 ) { | |
break | |
} | |
encontrado := 0 | |
registro := SubStr(hex,ptr_registro*2+1, len_reg*2) | |
; buscar "notas" | |
pos2 := InStr(registro,"04000021") | |
tmp3 := pos2+8 | |
len_notas := FDec(SubStr(registro,tmp3,2)) | |
notas_hex := SubStr(registro,pos2+10,len_notas*2) | |
notas := Hex2Text(notas_hex) | |
if (InStr(notas, busq) > 0) { | |
encontrado := 1 | |
} | |
; buscar "ip" | |
pos2 := InStr(registro,"01000021") | |
tmp3 := pos2+8 | |
len_ip := FDec(SubStr(registro,tmp3,2)) | |
ip_hex := SubStr(registro,pos2+10,len_ip*2) | |
ip := Hex2Text(ip_hex) | |
if (InStr(ip, busq) > 0) { | |
encontrado := 1 | |
} | |
; buscar "login" | |
pos2 := InStr(registro,"02000021") | |
tmp3 := pos2+8 | |
len_login := FDec(SubStr(registro,tmp3,2)) | |
login_hex := SubStr(registro,pos2+10,len_login*2) | |
login := Hex2Text(login_hex) | |
if (InStr(login, busq) > 0) { | |
encontrado := 1 | |
} | |
; buscar "pass" | |
pos2 := InStr(registro,"03000021") | |
tmp3 := pos2+8 | |
len_pass := FDec(SubStr(registro,tmp3,2)) | |
pass_hex := SubStr(registro,pos2+10,len_pass*2) | |
pass := Hex2Text(pass_hex) | |
passes[cuenta]:=pass | |
if ( encontrado > 0 ) { | |
LV_Add("",ip,login,notas,cuenta) | |
} | |
cuenta := cuenta + 1 | |
ptr_registro := ptr_registro + len_reg + 4 | |
} | |
Sleep 500 | |
LV_ModifyCol(1,"AutoHdr") | |
LV_ModifyCol(2,"AutoHdr") | |
LV_ModifyCol(3,"AutoHdr") | |
LV_ModifyCol(4,0) | |
; Detectar si la variable ha cambiado sobre la marcha y volver a buscar | |
busq2 := busqueda | |
Sleep 100 | |
Gui Submit, NoHide | |
if (busq2 <> busqueda) { | |
goto BUSCAR | |
} | |
Return | |
DobleClick: | |
actual := LV_GetNext(0) | |
if not actual { | |
Return | |
} | |
LV_GetText(ip, actual, 1) | |
LV_GetText(login, actual, 2) | |
LV_GetText(indice, actual, 4) | |
global passes | |
pass := passes[indice] | |
Run winbox %ip% %login% %pass% | |
Return | |
#IfWinActive Winbox Launcher | |
Esc::ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment