|
You last visited: Today at 03:56
Advertisement
[PHP - CLIENT] Login Cryptography
Discussion on [PHP - CLIENT] Login Cryptography within the Nostale forum part of the MMORPGs category.
10/31/2013, 13:19
|
#16
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
Because you don't understand that encrypt of client is opposite of decrypt (server) and viceversa
|
|
|
10/31/2013, 13:36
|
#17
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
yes i understood that but why encrypt is not the opposite of decrypt?
I understand that is the oposite beetween client and server but i don't understand that encrypt isn't the oposite of decrypt...
|
|
|
10/31/2013, 14:27
|
#18
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
std::string Decrypt(char *tmp, int bytes)
{
std::string dec_str;
for (int i = 0; i < bytes; i++) { dec_str += tmp[i] - 0xF ^ 0xC3; }
return dec_str;
}
opposite is
function packet_enc($packet)
{
$str_enc = "";
for($i = 0; $i < strlen($packet); $i++)
$str_enc .= chr((ord($packet[$i])^195) + 15);
return $str_enc .= chr(216);
}
std::string c_Cryptography::Encrypt(std::string tmp)
{
std::string enc_str;
for (unsigned int i = 0; i < tmp.size(); i++) { enc_str += tmp[i] + 0xF; }
return enc_str += 0x19;
}
opposite is
function packet_dec($packet)
{
$str_dec = "";
for($i = 0; $i < strlen($packet); $i++)
$str_dec .= chr(ord($packet[$i]) - 15);
return $str_dec;
}
|
|
|
10/31/2013, 15:20
|
#19
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
ok thanks i was comparing bad^^.
I try to make a c# emulator...
when i use my encrypt fonction with this string "Hi!" the return is : 8712048 is it good?
it's for the socket.send i thinks the good function is :
std::string c_Cryptography::Encrypt(std::string tmp)
{
std::string enc_str;
for (unsigned int i = 0; i < tmp.size(); i++) { enc_str += tmp[i] + 0xF; }
return enc_str += 0x19;
}
am i right?
|
|
|
10/31/2013, 20:42
|
#20
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
it's c++ not c#..
u need convert the function for your language ( in this case c# )..
|
|
|
10/31/2013, 20:58
|
#21
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
I know i converted but i'm note sure it's good^^ i just want to know if your function with "Hi!" in argument return : 8712048 if it's good my function is good too.
|
|
|
11/01/2013, 02:07
|
#22
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
I dont know but i think of no.. try to paste, here, your code ( function in c# )..
I already converted it in c# then i can say you if your encrypt/decrypt work or not..
PS. If u want work there aren't problems, we are here for help you..
|
|
|
11/01/2013, 12:53
|
#23
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
this is my function :
public static byte[] encrypter(string packet)
{
string enc_str = string.Empty;
byte[] test = new byte[packet.Length];
int i;
for (i = 0; i < packet.Length; i++)
{
enc_str += (char)(packet[(int)i] + 15);
test[i] = Convert.ToByte((char)enc_str[(int)i]);
}
return test;
}
|
|
|
11/01/2013, 14:27
|
#24
|
elite*gold: 20
Join Date: Jan 2012
Posts: 766
Received Thanks: 645
|
Quote:
Originally Posted by 0Lucifer0
this is my function :
public static byte[] encrypter(string packet)
{
string enc_str = string.Empty;
byte[] test = new byte[packet.Length];
int i;
for (i = 0; i < packet.Length; i++)
{
enc_str += (char)(packet[(int)i] + 15);
test[i] = Convert.ToByte((char)enc_str[(int)i]);
}
return test;
}
|
Much code lol, try this...
Code:
public satic byte[] Encrypt(string packet)
{
byte[] ret = new byte[packet.Lenght];
for(int i = 0; i < packet.Lenght; i++){ret[i] = (int)packet[i] + 0xF;}
return ret;
}
I didn't tryed but will work
|
|
|
11/01/2013, 17:54
|
#25
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
"Much" I know it at the first time it was short but i add something in order to test^^ (thats why my variable is test^^)
I will try it^^
it seems to be the exactly same result : 8712048 with "Hi!" in argument
Code:
public static byte[] encrypter(string packet)
{
byte[] ret = new byte[packet.Length];
for(int i = 0; i < packet.Length; i++){ret[i] = (byte)((int)packet[i] + 15);}
return ret;
}
|
|
|
11/01/2013, 20:49
|
#26
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
Code:
public static string LoginDecrypt(byte[] tmp, int size)
{
for (int i = 0; i < size; i++) tmp[i] = (byte)(tmp[i] - 0xF ^ 0xC3);
return Encoding.ASCII.GetString(tmp).Substring(0, size);
}
public static byte[] LoginEncrypt(string str)
{
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;
}
public static string LoginPassDecrypt(string tmp)
{
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;
}
my ( old old old ) cryptography functions, there is useless code ( i know) but u can clean it..
and it's for game server
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
public class Encrypt
{
public static byte[] EncryptGamePacket(string str)
{
try
{
string encrypted_string = "";
List<string> buffer = new List<string>(str.Split(' '));
encrypted_string += Others.getextendedascii(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 += Convert.ToChar(size);
}
encrypted_string += Others.getextendedascii(str[i] ^ 0xFF);
}
encrypted_string += Others.getextendedascii(0xFF);
byte[] ret = Others.ToByte(encrypted_string);
return ret;
}
catch (Exception ex)
{
throw;
}
}
}
public class Decrypt
{
public static string DecryptGamePacket2(byte[] str)
{
try
{
string decrypted_string = "";
char[] table = { ' ', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'n' };
int count = 0;
for (count = 0; count < Others.strlen(str); )
{
if (str[count] <= 0x7A)
{
byte len = str[count];
for (int i = 0; i < (int)len; i++)
{
count++;
decrypted_string += Others.getextendedascii((count < str.Length ? str[count] : 0) ^ 0xFF);
}
int x = decrypted_string[1];
count++;
}
else
{
byte len = str[count];
len &= 0x7F;
for (int i = 0; i < (int)len; )
{
count++;
byte highbyte = str[count];
highbyte &= 0xF0;
highbyte >>= 0x4;
byte 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;
}
catch (Exception ex)
{
throw;
}
}
public static string DecryptGamePacket(int session_id, byte[] str, int length)
{
try
{
string encrypted_string = "";
int session_key = session_id & 0xFF;
byte session_number = Convert.ToByte(session_id >> 6);
session_number &= 0xFF;
session_number &= Convert.ToByte(0x80000003);
switch (session_number)
{
case 0:
for (int i = 0; i < length; i++)
{
byte firstbyte = Convert.ToByte(session_key + 0x40);
byte highbyte = Convert.ToByte(str[i] - firstbyte);
encrypted_string += highbyte;
}
break;
case 1:
for (int i = 0; i < length; i++)
{
byte firstbyte = Convert.ToByte(session_key + 0x40);
byte highbyte = Convert.ToByte(str[i] + firstbyte);
encrypted_string += highbyte;
}
break;
case 2:
for (int i = 0; i < length; i++)
{
byte firstbyte = Convert.ToByte(session_key + 0x40);
byte highbyte = Convert.ToByte(str[i] - firstbyte ^ 0xC3);
encrypted_string += highbyte;
}
break;
case 3:
for (int i = 0; i < length; i++)
{
byte firstbyte = Convert.ToByte(session_key + 0x40);
byte highbyte = Convert.ToByte(str[i] + firstbyte ^ 0xC3);
encrypted_string += highbyte;
}
break;
default:
encrypted_string += 0xF;
break;
}
List<string> temp = new List<string>(encrypted_string.Split(Others.getextendedascii(0xFF)[0]));
string save = "";
for (int i = 0; i < temp.Count; i++)
{
save += DecryptGamePacket2(Others.StringToByteArray(temp[i]));
save += 0xFF;
}
return save;
}
catch (Exception ex)
{
throw;
}
}
public static string DecryptSessionPacket(byte[] _str)
{
try
{
string str = Others.ToString(_str);
string encrypted_string = "";
for (int i = 1; i < str.Length; i++)
{
if (str[i] == 0xE) { return encrypted_string; }
byte firstbyte = Convert.ToByte(str[i] - 0xF);
byte secondbyte = firstbyte;
secondbyte &= 0xF0;
firstbyte = Convert.ToByte(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 += Others.getextendedascii(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 += Others.getextendedascii(firstbyte);
break;
}
}
return encrypted_string;
}
catch (Exception ex)
{
throw;
}
}
}
public class Others
{
public static string getextendedascii(int x)
{
var e = Encoding.GetEncoding("Windows-1252");
var s = e.GetString(new byte[] { Convert.ToByte(x) });
return s;
}
public static byte[] ToByte(string str)
{
return ASCIIEncoding.ASCII.GetBytes(str);
}
public static string ToString(byte[] tmp)
{
return ASCIIEncoding.ASCII.GetString(tmp);
}
public static unsafe int strlen(byte[] s)
{
if (s == null)
{
//Throw error
}
int length = 0;
fixed (byte* pStr = s)
{
length = *(((int*)pStr) - 1);
}
return length;
}
public static byte[] StringToByteArray(string str)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetBytes(str);
}
public static string ByteArrayToString(byte[] arr)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetString(arr);
}
}
}
good luck guy !
|
|
|
11/01/2013, 20:59
|
#27
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
thanks ;D i was forgotten : tmp[tmp.Length-1] = 25; and know it's better^^
Sorry for my bad english(i'm french)
PS: there is an error in your function encrypt : Convert.ToByte(str[i] + 15)
if(str[i] > 112)
=> 112+15 = 127
and a byte is a number beetween 0 and 127
the encrypt system don't work for pqrstuvwxyz
^^ i will try to fix tomorrow and i will post my fix.
this is my unencryptor :
Code:
public static string unencrypter(byte[] packet, int bytes)
{
string dec = string.Empty;
char[] chars = new char[bytes];
int test = 0;
for (int i = 0; i < bytes; i++)
{
chars[(int)i] = (char)(packet[(int)i]);
test = (((int)chars[i] - 15) ^ 195);
if (test < 0) test = (test % 256) + 256;
dec += (char)test;
}
return dec;
}
if you see an error tell me
|
|
|
11/02/2013, 01:10
|
#28
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
How i already said, if somebody want study i help..
|
|
|
11/02/2013, 12:50
|
#29
|
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,018
|
this is a fix for your function convert :
Code:
public static byte[] StringToByteArray(string str)
{
return Encoding.GetEncoding(1252).GetBytes(str);
}
public static string ByteArrayToString(byte[] arr)
{
return Encoding.GetEncoding(1252).GetString(arr);
}
|
|
|
11/02/2013, 13:37
|
#30
|
elite*gold: 0
Join Date: Aug 2013
Posts: 154
Received Thanks: 166
|
 im happy that you work to this project.. have you skype ? if yes, give me your contact that i'll add you
|
|
|
 |
|
Similar Threads
|
Auth Cryptography
02/01/2013 - CO2 Private Server - 3 Replies
i Wonder if the Auth Cryptography has changed at patch 5698 cuz i couldnt login into My Pserver ... after checking PasswordSeed (1059) & Login (1052) & Auth Response (1055) .. none of them has changed
Regards
Shadowman123
|
Game Cryptography ??
09/22/2012 - CO2 Programming - 0 Replies
Hello :)
coders
my project (Proxy bot) i need help to Update The encryption
auth crypto is working but the problem in game crypto
i tried 2 proxy's encryption and it stuck when logging in game server
help ?
currently proxy is works 100% but doesnt give the right packets
thanks.
edit : im not sure maybe the auth encryption are also does not decrypt correctly
|
Help with cryptography
05/16/2012 - CO2 Programming - 10 Replies
Hello ppl, so ive been learning general hacking methods for quite a decent while now, first i started out with small things such as memory hacks and then i started learning even more which led me to packet sniffing and that led me to the idea of fiddling around with conquer. Now that ive had a chance to play around with it i decided to hook the connect function of the game and i was successful at doing so, i also managed to get the client to connect to my socket first rather than connect to the...
|
Password Cryptography
03/03/2011 - CO2 Private Server - 13 Replies
#Problem solved
Thank You everybody, I Appreciate this.
|
Client Server Cryptography?
07/14/2009 - Archlord - 7 Replies
i was wondering, the communication between alefcient and the game server is encrypted, and alefclient binary seems to use Cryptography API (CNG) with most of its functions like:
BCryptCloseAlgorithmProvider
BCryptCreateHash
BCryptDecrypt
BCryptDeriveKey
BCryptDestroyHash
BCryptDestroyKey
BCryptDestroySecret
BCryptDuplicateHash
|
All times are GMT +1. The time now is 03:56.
|
|