Skip to content

Instantly share code, notes, and snippets.

@TwinFuture
Created April 26, 2017 17:35
Show Gist options
  • Save TwinFuture/ee7a53d4c33a3e4cb45f4489121e056a to your computer and use it in GitHub Desktop.
Save TwinFuture/ee7a53d4c33a3e4cb45f4489121e056a to your computer and use it in GitHub Desktop.
signing
using System;
using System.Security.Cryptography;
using System.Text;
using LKWD.WebService.Debug;
namespace LKWD.WebService
{
// Token: 0x02000167 RID: 359
public static class SessionToken
{
// Token: 0x06000A5A RID: 2650 RVA: 0x0005F7D4 File Offset: 0x0005D9D4
public static string Generate(int lAPIVersion, string lSocialNextworkID, string lSecret, DateTime lServerTime)
{
if (lAPIVersion >= 10)
{
byte[] bytes = Encoding.Unicode.GetBytes(lSocialNextworkID);
bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, bytes);
lSocialNextworkID = Encoding.UTF8.GetString(bytes);
}
lSocialNextworkID = SessionToken.MobileManglerUserName(lSocialNextworkID);
string lString = string.Concat(new string[]
{
lServerTime.Day.ToString("D2"),
"76",
lServerTime.Year.ToString("D4"),
"99",
lServerTime.Month.ToString("D2"),
"86"
});
string text = SessionToken.NumericalString(lSocialNextworkID);
text = SessionToken.RepeatString(text, 100);
string text2 = SessionToken.RepeatString(lString, 100);
string text3 = string.Empty;
string text4 = string.Empty;
int startIndex = int.Parse(text.Substring(text.Length - 4, 4)) % 15;
int startIndex2 = int.Parse(text.Substring(text.Length - 5, 4)) % 15;
int num = int.Parse(text.Substring(text.Length - 6, 4)) % 6;
int num2 = int.Parse(text.Substring(text.Length - 3, 2)) % 3;
int startIndex3 = int.Parse(text.Substring(text.Length - 5, 3)) % 15;
int num3 = int.Parse(text.Substring(text.Length - 6, 3)) % 6;
int startIndex4 = int.Parse(text.Substring(text.Length - 7, 4)) % 15;
text = text.Substring(startIndex, 50);
string text5 = SessionToken.m_Salt.Substring(startIndex2, 50);
string text6 = text2.Substring(startIndex3, 50);
string text7 = lSecret.Substring(startIndex4, 50);
for (int i = 0; i < 50; i++)
{
num = (num + 1) % 6;
num3 = (num3 + 1) % 6;
int num4 = num * 10;
int num5 = num3 * 10;
text3 += SessionToken.m_Conversion[int.Parse(text[i].ToString()) + num4];
text3 += text5[i];
text3 += SessionToken.m_Conversion[int.Parse(text6[49 - i].ToString()) + num5];
text3 += text7[49 - i];
}
MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
for (int j = 0; j < 2 + num2; j++)
{
byte[] array = Encoding.UTF8.GetBytes(text3);
array = mD5CryptoServiceProvider.ComputeHash(array);
StringBuilder stringBuilder = new StringBuilder();
byte[] array2 = array;
for (int k = 0; k < array2.Length; k++)
{
byte b = array2[k];
stringBuilder.Append(b.ToString("x2").ToLower());
}
text4 = stringBuilder.ToString();
text3 += text4;
}
return text4;
}
// Token: 0x06000A5B RID: 2651 RVA: 0x0005FAE8 File Offset: 0x0005DCE8
private static string RepeatString(string lString, int lCharacters)
{
string text = string.Empty;
if (!string.IsNullOrEmpty(lString))
{
while (text.Length < lCharacters)
{
text += lString;
}
}
else
{
Logger.LogError("WebservicesBase : Repeat String FAILED!");
}
return text;
}
// Token: 0x06000A5C RID: 2652 RVA: 0x0005FB30 File Offset: 0x0005DD30
private static string NumericalString(string lString)
{
string text = string.Empty;
for (int i = 0; i < lString.Length; i++)
{
text += ((int)(lString[i] % '\n')).ToString();
}
return text;
}
// Token: 0x06000A5D RID: 2653 RVA: 0x0005FB74 File Offset: 0x0005DD74
private static string MobileManglerUserName(string lName)
{
byte[] bytes = Encoding.UTF8.GetBytes(lName);
string text = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(string.Empty));
char c = SessionToken.m_Salt[bytes.Length % SessionToken.m_Salt.Length];
for (int i = 0; i < bytes.Length; i++)
{
text += (char)bytes[i];
if (i % 3 == 0)
{
text += c;
}
}
return text;
}
// Token: 0x040006E2 RID: 1762
private static char[] m_Conversion = new char[]
{
'w',
'e',
'r',
't',
'y',
'u',
'i',
'o',
'p',
'a',
's',
'd',
'f',
'g',
'h',
'j',
'k',
'l',
'z',
'x',
'c',
'v',
'b',
'n',
'm',
'Q',
'E',
'R',
'T',
'Y',
'U',
'I',
'O',
'P',
'A',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
'L',
'Z',
'X',
'C',
'V',
'B',
'N',
'M',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
};
// Token: 0x040006E3 RID: 1763
private static string m_Salt = "!A*3&k^3(d&P$W@9,q:2=5#V!z.1[M7;F}4)0*O*h{8|d~f]7[L^r@K)4&b+Q-g>5_v|T<X%p!9=3}S^s";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment