Option Explicit
'=================================================
' º Nombre : mParseKeys.bas
' º Version : 2.0
' º Autor : Milton Candelero
' º Alias : ElementalCode
' º Pais : Argentina
' º Fecha : 13/OCT/2011
' º Dedicado a: El amor de mi vida
' º Licencia : GNU PUBLIC LICENCE v.3 (Or higher)
'=================================================
' This file is part of Open Nod32 Keyfinder.
'
' Open Nod32 Keyfinder is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or any later version.
'
' Open Nod32 Keyfinder is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with Open Nod32 Keyfinder. If not, see <http://www.gnu.org/licenses/>.
Function ParseKeys(ByVal sHTML As String, ByRef sUser() As String, ByRef sPass() As String)
'Constantes para los patterns de busqueda
Const USERPATTERN As String = "(?:EAV|TRIAL|ESS)-\d{8}"
Const PASSPATTERN As String = "(?:[pP]?assword:? |[pP]?assword:?|nod32key:)(\w{10})"
'Declarar variables para RegExp
Dim oREuser As RegExp
Dim oREpass As RegExp
'Variables para las colecciones de resultados
Dim oMCuser As MatchCollection
Dim oMCpass As MatchCollection
'Variables para las coincidencias
Dim oMuser As Match
Dim oMpass As Match
'Variables para los indices de las strings de salida _
y previamente la cantidad de repeticiones (ahorro variables)
Dim cU As Byte
Dim cP As Byte
'Crear los objetos del RegExp User y analizar
Set oREuser = New RegExp
With oREuser
.Global = True
.Pattern = USERPATTERN
Set oMCuser = .Execute(sHTML)
End With
'Crear los objetos del ExpReg Pass y analizar
Set oREpass = New RegExp
With oREpass
.Global = True
.Pattern = PASSPATTERN
Set oMCpass = .Execute(sHTML)
End With
'Dimensionar el array
cU = oMCuser.Count - 1
ReDim sUser(cU) As String
cU = 0 ' Vuelvo a cero para seguir usando esta variable.
'Guardar Resultados user
For Each oMuser In oMCuser
sUser(cU) = oMuser
cU = cU + 1
Next
'Dimensionar el array
cP = oMCpass.Count - 1
ReDim sPass(cP) As String
cP = 0 ' Vuelvo a cero para seguir usando esta variable.
'Guardar Resultados pass
For Each oMpass In oMCpass
sPass(cP) = oMpass.SubMatches(0)
cP = cP + 1
Next
'Destruir RegExp para ahorrar memoria y porque queda lindo :D
Set oREuser = Nothing
Set oREpass = Nothing
End Function