BorderGame
All Nostale Cryptography - Versione stampabile

+- BorderGame (https://www.bordergame.it)
+-- Forum: NosTale (/Forum-NosTale)
+--- Forum: Server Privati Nostale (/Forum-Server-Privati-Nostale)
+--- Discussione: All Nostale Cryptography (/Thread-All-Nostale-Cryptography)



All Nostale Cryptography - Ð3V!L - 08-04-2013 03:15 AM

Dato che ci sono più discussioni a riguardo ma incomplete,
apro questa discussione dove posto tutte le crittografie di nostale..

posto sia quelle in NET che quelle in C++ (alcune fatte da me, alcune fatte da altri)

Login Decryption (Ð3V!L, C++)
Codice:
std::string loginDecrypt(std::string str)
{
    std::string dec_str;
    for (int i = 0; i < str.size(); i++) { dec_str += str[i] - 0xF ^ 0xC3; }
    return dec_str;
}

Login Encryption (trollface, C++)
Codice:
std::string EncryptLoginPacket(std::string str)
{
    std::string encrypted_string;

    for (int i = 0; i < str.length(); i++) { encrypted_string += str[i] + 0xF; }

    return encrypted_string += 0x19;
}

Password Hash Decryption (Ð3V!L, C++) -- BUG FIXED
Codice:
std::string LoginPassDecrypt(std::string tmp)
{
    try
    {
        bool equal = tmp.size() % 2 == 0 ? true : false;
        std::string str = equal == true ? tmp.erase(0,3) : tmp.erase(0, 4);
        std::string dec_pass;
        for(int i = 0; i < str.size(); i += 2) { dec_pass += str[i]; }
        
        if(dec_pass.size() % 2 != 0)
        {
            str.clear();
            dec_pass.clear();
            str = tmp.erase(0, 2);
            for(int i = 0; i < str.size(); i += 2) { dec_pass += str[i]; }
        }
        
        std::string temp = dec_pass;
        dec_pass.clear();
        for(int i = 0; i < temp.size(); i++)
        {
            dec_pass += temp[i];
            if (i % 2 && i != 0) dec_pass += " ";
        }

        std::stringstream ss(dec_pass);
        dec_pass.clear();
        
        int convert;
        while ( ss >> std::hex >> convert)
        {
            dec_pass.push_back(convert);
        }

        return dec_pass;
    }
    catch (...)
    {
        return "-1";
    }
}

Session Packet Decryption (trollface, C++)
Codice:
std::string DecryptSessionPacket(std::string str)
{
    std::string    encrypted_string;

    for (int i = 1; i < str.length(); i++)
    {
        if (str[i] == 0xE) { return encrypted_string; }

                          unsigned char firstbyte = str[i] - 0xF;
        unsigned char secondbyte = firstbyte;
        secondbyte &= 0xF0;
        firstbyte =    firstbyte - secondbyte;
        secondbyte >>=    0x4;

        switch (secondbyte)
        {
        case 0:
            encrypted_string +=    ' ';
        break;

        case 1:
            encrypted_string +=    ' ';
        break;

        case 2:
            encrypted_string +=    '-';
        break;

        case 3:
            encrypted_string +=    '.';
        break;

        default:
            secondbyte += 0x2C;
            encrypted_string +=    secondbyte;
        break;
        }

        switch (firstbyte)
        {
        case 0:
            encrypted_string +=    ' ';
        break;

        case 1:
            encrypted_string += ' ';
        break;

        case 2:
            encrypted_string += '-';
        break;

        case 3:
            encrypted_string += '.';
        break;

        default:
            firstbyte += 0x2C;
            encrypted_string +=    firstbyte;
        break;
        }
    }

    return encrypted_string;
}

Game Packet Decryption (Part 1) (trollface, C++)
Codice:
std::string DecryptGamePacket(int session_id, unsigned char *str, int length)
{
    std::string encrypted_string = "";
    int session_key = session_id & 0xFF;
    unsigned char session_number = session_id >> 6;
    session_number &= 0xFF;
    session_number &= 0x80000003;

    switch (session_number)
    {
    case 0:
        for (int i = 0; i < length; i++)
        {
                unsigned char firstbyte = session_key + 0x40;
                unsigned char highbyte = str[i] - firstbyte;
                encrypted_string += highbyte;
        }
    break;

    case 1:
        for (int i = 0; i < length; i++)
        {
                unsigned char firstbyte = session_key + 0x40;
                unsigned char highbyte = str[i] + firstbyte;
                encrypted_string += highbyte;
        }
    break;

    case 2:
        for (int i = 0; i < length; i++)
        {
                unsigned char firstbyte = session_key + 0x40;
                unsigned char highbyte = str[i] - firstbyte ^ 0xC3;
                encrypted_string += highbyte;
        }
    break;

    case 3:
        for (int i = 0; i < length; i++)
        {
                unsigned char firstbyte = session_key + 0x40;
                unsigned char highbyte = str[i] + firstbyte ^ 0xC3;
                encrypted_string += highbyte;
        }
    break;

    default:
        encrypted_string += 0xF;
    break;
    }

    std::vector<std::string> temp = split(encrypted_string, 0xFF);
    std::string save = "";

    for (int i = 0; i < temp.size(); i++)
    {
        save += DecryptGamePacket2(temp[i].c_str());
        save += 0xFF;
    }

    return save;
}

Game Packet Decryption (Part 2) (trollface, C++)
Codice:
std::string DecryptGamePacket2(unsigned char str[])
{
    std::string decrypted_string;
    char table[] = {' ','-','.','0','1','2','3','4','5','6','7','8','9','n'};
    int count = 0;

    for (count = 0; count < strlen(str); )
    {
        if (str[count] <= 0x7A)
        {
            unsigned char len = str[count];

            for (int i = 0; i < (int)len; i++)
            {
                count++;
                decrypted_string += str[count] ^ 0xFF;
            }

            count++;
        } else
        {
            unsigned char len = str[count];
            len &= 0x7F;

            for (int i = 0; i < (int)len;)
            {
                count++;

                unsigned char highbyte = str[count];
                highbyte &= 0xF0;
                highbyte >>= 0x4;

                unsigned char lowbyte = str[count];
                lowbyte &= 0x0F;

                if (highbyte != 0x0 && highbyte != 0xF)
                {
                    decrypted_string += table[highbyte-1];
                    i++;
                }

                if (lowbyte != 0x0 && lowbyte != 0xF)
                {
                    decrypted_string += table[lowbyte-1];
                    i++;
                }
            }
            count ++;
        }
    }

    return decrypted_string;
}

Game Packet Encrypt (trollface, C++)
Codice:
std::string EncryptGamePacket(string str)
{
    std::string encrypted_string;
    std::vector<std::string> buffer;

    buffer = split(str, ' ');
    encrypted_string +=    buffer[0].length();

    for (int i = 0 ; i < str.length(); i++)
    {
        if (i == buffer[0].length())
        {
            int    size = str.length() - buffer[0].length();
            encrypted_string +=    size;
        }

        encrypted_string +=    str[i] ^ 0xFF;
    }

    return encrypted_string += 0xFF;
}

Login Packet Decrypt (Ð3V!L, C#)
Codice:
public static string LoginDecrypt(byte[] tmp, int size)
{
    try
    {
        for (int i = 0; i < size; i++)
        {
            tmp[i] = (byte)(tmp[i] - 0xF ^ 0xC3);
        }
        return Encoding.ASCII.GetString(tmp).Substring(0, size);
    }
    catch
    {
        return "error";
    }
}

Login Packet Encrypt (Ð3V!L, C#)
Codice:
public static byte[] LoginEncrypt(string str)
{
    try
    {
        str += " ";
        byte[] tmp = new byte[str.Length + 1];
        tmp = Encoding.ASCII.GetBytes(str);
        for (int i = 0; i < str.Length; i++)
        {
            tmp[i] = Convert.ToByte(str[i] + 15);
        }
        tmp[tmp.Length-1] = 25;
        return tmp;
    }
    catch
    {
        return new byte[0];
    }
}

Password Hash Decrypt (Ð3V!L, C#) -- BUG FIXED
Codice:
public static string LoginPassDecrypt(string tmp)
{
    try
    {
        bool equal = tmp.Length % 2 == 0 ? true : false;
        string str = equal == true ? tmp.Remove(0, 3) : tmp.Remove(0, 4);
    
        string dec_pass = string.Empty;
        for (int i = 0; i < str.Length; i += 2) { dec_pass += str[i]; }
    
        if (dec_pass.Length % 2 != 0)
        {
            str = dec_pass = string.Empty;
            str = tmp.Remove(0, 2);
            for (int i = 0; i < str.Length; i += 2) { dec_pass += str[i]; }
        }

        StringBuilder temp = new StringBuilder();
        for (int i = 0; i < dec_pass.Length; i += 2) { temp.Append(Convert.ToChar(Convert.ToUInt32(dec_pass.Substring(i, 2), 16))); }
        dec_pass = temp.ToString();
    
        return dec_pass;
    }
    catch
    {
        return "-1";
    }
}

Game Session Decrypt (Ð3V!L, C#) -- OLD CLIENT
Codice:
public static byte[] GameSessionDecrypt(byte[] data)
{
    try
    {
        byte[] tmp = new byte[data.Length];
        for(int i = 0; i < data.Length; i++)
            tmp[i] = (byte)(data[i] - 0x0F);
        return tmp;
    }
    catch
    {
        return new byte[0];
    }
}

la discussione è in continuo aggiornamento..


RE: All Nostale Cryptography - iCloud - 08-04-2013 03:28 PM

Wau quindi riesci a decriptarmi password? xD


RE: All Nostale Cryptography - Ð3V!L - 08-04-2013 03:34 PM

(08-04-2013 03:28 PM)iCloud Ha scritto:  Wau quindi riesci a decriptarmi password? xD

non capisco cosa centri col tema di questa discussione..
è la crittografia del server, la password hash decryption l'ho sistemata dato che in alcuni casi si buggava.. ora si puo fare un login server corretto.


RE: All Nostale Cryptography - iCloud - 08-04-2013 05:42 PM

Si lo so è per il proprio retro ;P <3 sono un burlone ahhaha


RE: All Nostale Cryptography - Ð3V!L - 08-04-2013 11:10 PM

(08-04-2013 05:42 PM)iCloud Ha scritto:  Si lo so è per il proprio retro ;P <3 sono un burlone ahhaha

se lo sai che senso ha scrivere

(08-04-2013 03:28 PM)iCloud Ha scritto:  Wau quindi riesci a decriptarmi password? xD

segnalo per spam dato che è l'unica spiegazione data.

AGGIUNTA CRITTOGRAFIA (SESSION DECRYPT) DEL VECCHIO CLIENT (2008) Big Grin


RE: All Nostale Cryptography - Nagasci - 09-04-2013 06:14 PM

(08-04-2013 05:42 PM)iCloud Ha scritto:  Si lo so è per il proprio retro ;P <3 sono un burlone ahhaha
Avvertimento per spam, cerca di star attento la prossima volta.


RE: All Nostale Cryptography - Ð3V!L - 11-04-2013 03:52 PM

UP!! =D


RE: All Nostale Cryptography - Lord Freud - 08-05-2013 10:30 PM

Avvertimento a @[Ð3V!L] per spam, se devi uppare dev'esserci una novità nel post iniziale, non solo per fare notorietà al thread.


RE: All Nostale Cryptography - Ð3V!L - 08-05-2013 11:54 PM

(08-05-2013 10:30 PM)Lord Freud Ha scritto:  Avvertimento a @[Ð3V!L] per spam, se devi uppare dev'esserci una novità nel post iniziale, non solo per fare notorietà al thread.

ehm l'avevo aggiornato 2 giorni prima dell'up, poi per via del lag tremendo non avevo uppato e l'ho fatto dopo 2 giorni è.é @[Zarta] (avevo inserito la crittografia vecchia)