Classe em .Net para gerar as passwords de routers D-Link

Descobri por acaso um artigo que continha informação que era útil para um projecto meu.
Como o meu projecto utiliza a tecnologia .Net, aproveitei para rescrever a função que aqui disponibilizo para o caso de ser útil para alguém.

Public Class dlink
    Private mac_ As String
    Public Sub New(ByVal mac As String)
        mac_ = mac
    End Sub
 
    Public Function generate() As String
        Dim password(20) As String
        For i = 0 To mac_.Length - 1
            Select Case i
                Case 0
                    password(1) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 1
                    password(3) = dictionary(mac_.Substring(i, 1))
                    password(12) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 2
                    password(5) = dictionary(mac_.Substring(i, 1))
                    password(17) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 3
                    password(7) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 4
                    password(9) = dictionary(mac_.Substring(i, 1))
                    password(18) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 5
                    password(11) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 6
                    password(10) = dictionary(mac_.Substring(i, 1))
                    password(13) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 7
                    password(8) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 8
                    password(6) = dictionary(mac_.Substring(i, 1))
                    password(14) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 9
                    password(15) = dictionary(mac_.Substring(i, 1))
                    password(4) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 10
                    password(2) = dictionary(mac_.Substring(i, 1))
                    password(19) = dictionary(mac_.Substring(i, 1))
                    Exit Select
                Case 11
                    password(0) = dictionary(mac_.Substring(i, 1))
                    password(16) = dictionary(mac_.Substring(i, 1))
                    Exit Select
            End Select
        Next
        Return Join(password, "")
    End Function
 
    Private Function dictionary(ByVal letter As Char) As Char
        Select Case letter.ToString.ToUpper
            Case "1"
                Return "r"
                Exit Select
            Case "2"
                Return "q"
                Exit Select
            Case "3"
                Return "a"
                Exit Select
            Case "4"
                Return "H"
                Exit Select
            Case "5"
                Return "N"
                Exit Select
            Case "6"
                Return "p"
                Exit Select
            Case "7"
                Return "d"
                Exit Select
            Case "8"
                Return "S"
                Exit Select
            Case "9"
                Return "Y"
                Exit Select
            Case "0"
                Return "X"
                Exit Select
            Case "A"
                Return "w"
                Exit Select
            Case "B"
                Return "8"
                Exit Select
            Case "C"
                Return "6"
                Exit Select
            Case "D"
                Return "2"
                Exit Select
            Case "E"
                Return "1"
                Exit Select
            Case "F"
                Return "5"
                Exit Select
            Case Else
                Return " "
        End Select
 
    End Function
End Class

A classe é muito simples de usar:

dim myDlink as new dlink("aabbccddee")
myDlink.generate()

Não se esqueçam que aceder a redes sem a devida permissão é crime punível por lei!

Leave a Reply

Your email address will not be published.