开发者

Does anyone recognize this cipher algorithm?

开发者 https://www.devze.com 2023-03-31 14:43 出处:网络
I found myself in a desperate situation trying to understand the algorithm below. Does anyone recognize it?

I found myself in a desperate situation trying to understand the algorithm below. Does anyone recognize it?

It comes from a decompiled assembly. I am writing a PHP website开发者_Go百科 front-end application and need to use passwords generated by this terrible piece of code as credentials to log in.

public static void Crypt(string ThisCle, string Buffer, long BufferLength)
{
    int index = 1;
    do
    {
        WUC.cry[index] = char.MinValue;
        checked { ++index; }
    }
    while (index <= 32000);
    WUC.cle = Conversions.ToCharArrayRankOne(ThisCle);
    WUC.si = 0;
    WUC.x1a2 = 0;
    WUC.i = 0;
    WUC.j = 0;
    WUC.l = 0;
    while ((long) WUC.j <= checked (BufferLength - 1L))
    {
        byte num1 = checked ((byte) Strings.Asc(Strings.Mid(Buffer, WUC.j + 1, 1)));
        WUC.Assemble();
        WUC.cfc = WUC.inter >> 8;
        WUC.cfd = WUC.inter & (int) byte.MaxValue;
        WUC.compte = 0;
        do
        {
            WUC.cle[WUC.compte] = Strings.Chr(Strings.Asc(WUC.cle[WUC.compte]) ^ (int) num1);
            checked { ++WUC.compte; }
        }
        while (WUC.compte <= 15);
        byte num2 = checked ((byte) ((int) num1 ^ (WUC.cfc ^ WUC.cfd)));
        byte num3 = (byte) ((uint) num2 >> 4);
        byte num4 = checked ((byte) ((int) num2 & 15));
        char ch;
        switch (num3)
        {
            case (byte) 0:
                ch = 'a';
                break;
            case (byte) 1:
                ch = 'b';
                break;
            case (byte) 2:
                ch = 'c';
                break;
            case (byte) 3:
                ch = 'd';
                break;
            case (byte) 4:
                ch = 'e';
                break;
            case (byte) 5:
                ch = 'f';
                break;
            case (byte) 6:
                ch = 'g';
                break;
            case (byte) 7:
                ch = 'h';
                break;
            case (byte) 8:
                ch = 'i';
                break;
            case (byte) 9:
                ch = 'j';
                break;
            case (byte) 10:
                ch = 'k';
                break;
            case (byte) 11:
                ch = 'l';
                break;
            case (byte) 12:
                ch = 'm';
                break;
            case (byte) 13:
                ch = 'n';
                break;
            case (byte) 14:
                ch = 'o';
                break;
            case (byte) 15:
                ch = 'p';
                break;
        }
        WUC.cry[checked (WUC.j * 2)] = ch;
        switch (num4)
        {
            case (byte) 0:
                ch = 'a';
                break;
            case (byte) 1:
                ch = 'b';
                break;
            case (byte) 2:
                ch = 'c';
                break;
            case (byte) 3:
                ch = 'd';
                break;
            case (byte) 4:
                ch = 'e';
                break;
            case (byte) 5:
                ch = 'f';
                break;
            case (byte) 6:
                ch = 'g';
                break;
            case (byte) 7:
                ch = 'h';
                break;
            case (byte) 8:
                ch = 'i';
                break;
            case (byte) 9:
                ch = 'j';
                break;
            case (byte) 10:
                ch = 'k';
                break;
            case (byte) 11:
                ch = 'l';
                break;
            case (byte) 12:
                ch = 'm';
                break;
            case (byte) 13:
                ch = 'n';
                break;
            case (byte) 14:
                ch = 'o';
                break;
            case (byte) 15:
                ch = 'p';
                break;
        }
        WUC.cry[checked (WUC.j * 2 + 1)] = ch;
        checked { ++WUC.j; }
    }
}

There's a "Decrpyt" method working in a similar way. The ciphers are 16 chars long.


This looks like it could be the original (Delphi) source:

http://files.codes-sources.com/fichier_fullscreen.aspx?id=45245&f=pc1.pas&lang=en

It's a PC1 cipher, look here for some implementations in other languages.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号