Date: 2014-04-11 09:41 (UTC)
From: [identity profile] dmarck.livejournal.com
У меня сто лет как лежит перловый фильтр stdin-stdout, которые только и делает, что декодирует type7

Date: 2014-04-11 09:42 (UTC)
From: [identity profile] dadv.livejournal.com
Выложи в каменте? :-)

Date: 2014-04-11 10:35 (UTC)
From: [identity profile] dmarck.livejournal.com
#!/usr/bin/perl -w
# $Id: cisco-decrypt.pl,v 1.1.1.1 2002/09/02 16:37:35 marck Exp $
#
# Credits for orginal code and description hobbit@avian.org,
# SPHiXe, .mudge et al. and for John Bashinski <jbash@cisco.com>
# for Cisco IOS password encryption facts.
#
# Use for any malice or illegal purposes strictly prohibited!
#

@xlat = ( 0x64, 0x73, 0x66, 0x64, 0x3b, 0x6b, 0x66, 0x6f, 0x41,
          0x2c, 0x2e, 0x69, 0x79, 0x65, 0x77, 0x72, 0x6b, 0x6c,
          0x64, 0x4a, 0x4b, 0x44, 0x48, 0x53 , 0x55, 0x42 );

while (<>) {
        if (/(password|md5)\s+7\s+([\da-f]+)/io) {
            if (!(length($2) & 1)) {
                $ep = $2; $dp = "";
                ($s, $e) = ($2 =~ /^(..)(.+)/o);
                for ($i = 0; $i < length($e); $i+=2) {
                    $dp .= sprintf "%c",hex(substr($e,$i,2))^$xlat[$s++];
                }
                s/7\s+$ep/$dp/;
            }
        }
        print;
}

Date: 2014-04-11 13:00 (UTC)
From: [identity profile] fuflolog.livejournal.com
Cisco Type 7 - очень примитивная штука. Первые две цифры пароля - десятичное смещение в таблице. Далее выбирай из таблицы, применяй XOR и будет тебе ASCII. Вот тебе вариант на Visual Basic (он немного более хитропопый, чем у Cisco - позволяет читать таблицу и в обратную сторону)


' Decrypt the string
'
Function Decrypt(strSource As String, intMethod As Integer) As String
Dim strInputString As String, lLen As Long

On Error GoTo TheDecErrorHandler

' Check input
strInputString = Trim(strSource)
lLen = Len(strInputString)
' The string shall be at least four characters long and must have even number of characters
If lLen < 4 Or lLen Mod 2 <> 0 Then
    Decrypt = ""
    Exit Function
End If

' Only 0 (left -> right and 1 (right <- left) are allowed
If intMethod <> 0 Then intMethod = 1

' Hash Table
Dim strHexHash() As String, lLastHashNum As Long
strHexHash = Split("0x64,0x73,0x66,0x64,0x3b,0x6b,0x66,0x6f,0x41,0x2c,0x2e,0x69,0x79,0x65,0x77,0x72,0x6b,0x6c,0x64,0x4a,0x4b,0x44,0x48,0x53,0x55,0x42,0x73,0x67,0x76,0x63,0x61,0x36,0x39,0x38,0x33,0x34,0x6e,0x63,0x78,0x76,0x39,0x38,0x37,0x33,0x32,0x35,0x34,0x6b,0x3b,0x66,0x67,0x38,0x37", ",")

lLastHashNum = UBound(strHexHash)

' Index - must be Numeric and Dec
Dim strIndex As String, lIdx As Long

strIndex = Mid(strInputString, 1, 2)
If Not IsNumeric(strIndex) Then
    Decrypt = ""
    Exit Function
End If

lIdx = CLng(strIndex)

' Index must fit the array
If lIdx < 0 Or lIdx > lLastHashNum Then
    Decrypt = ""
    Exit Function
End If

' Decrypt
Dim strOutputString As String, l As Long, strSourceChar As String, intChar As Integer, intHash As Integer, intXORChar As Integer, strDestChar As String

For l = 3 To lLen Step 2
    
    ' Source char
    strSourceChar = Mid(strInputString, l, 2)
    
    ' Dec character
    intChar = CInt("&H" & strSourceChar)
    
    ' Hash from the array
    intHash = CInt(Replace(strHexHash(lIdx), "0x", "&H"))
    
    ' XOR
    intXORChar = intChar Xor intHash
    
    ' Dest character
    strDestChar = Chr(intXORChar)
    
    strOutputString = strOutputString & strDestChar
    
    ' Move around the hash table
    If intMethod = 0 Then
        lIdx = lIdx + 1
        If lIdx > lLastHashNum Then lIdx = 0
    Else
        lIdx = lIdx - 1
        If lIdx < 0 Then lIdx = lLastHashNum
    End If
    
Next l

Decrypt = strOutputString
Exit Function

TheDecErrorHandler:
Decrypt = ""
End Function

Edited Date: 2014-04-11 13:15 (UTC)

Date: 2014-04-11 13:23 (UTC)
From: [identity profile] fuflolog.livejournal.com
Мне в свое время попался перловый скрипт, в котором таблица была вдвое длинее.

Profile

dadv: (Default)
Choose your future

July 2024

M T W T F S S
12 34567
891011121314
15161718192021
22232425262728
293031    

Tags

Style Credit

Powered by Dreamwidth Studios