Update Program.cs

This commit is contained in:
AdminTest0 2022-08-08 10:52:29 +08:00 committed by GitHub
parent e197d29b33
commit 6e6545010e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,77 +22,76 @@ namespace WeChatGetKey
{ {
//Console.ReadKey(); //Console.ReadKey();
} }
Console.WriteLine("[+] Done."); Console.WriteLine("[+] Done");
} }
private static void ReadTest() private static void ReadTest()
{ {
List<int> SupportList = null;
Process WeChatProcess = null; Process WeChatProcess = null;
Process[] WeChatProcessName = Process.GetProcessesByName("WeChat"); foreach (Process ProcessesName in Process.GetProcessesByName("WeChat"))
List<int> list = null;
foreach (Process WeChatProcess2 in WeChatProcessName)
{ {
WeChatProcess = WeChatProcess2; WeChatProcess = ProcessesName;
Console.WriteLine("[+] WeChatProcessPID: " + WeChatProcess2.Id.ToString()); Console.WriteLine("[+] WeChatProcessPID: " + WeChatProcess.Id.ToString());
foreach (object obj in WeChatProcess2.Modules) foreach (object obj in WeChatProcess.Modules)
{ {
ProcessModule processModule = (ProcessModule)obj; ProcessModule processModule = (ProcessModule)obj;
if (processModule.ModuleName == "WeChatWin.dll") if (processModule.ModuleName == "WeChatWin.dll")
{ {
Program.WeChatWinBaseAddress = processModule.BaseAddress; Program.WeChatWinBaseAddress = processModule.BaseAddress;
string fileVersion = processModule.FileVersionInfo.FileVersion; string FileVersion = processModule.FileVersionInfo.FileVersion;
Console.WriteLine("[+] WeChatVersion: " + fileVersion); Console.WriteLine("[+] WeChatVersion: " + FileVersion);
if (!Program.versionlist.TryGetValue(fileVersion, out list)) if (!Program.VersionList.TryGetValue(FileVersion, out SupportList))
{ {
Console.WriteLine("[-] WeChat Current Version Is: " + fileVersion + " Not Support"); Console.WriteLine("[-] WeChat Current Version Is: " + FileVersion + " Not Support");
return; return;
} }
break; break;
} }
} }
if (list == null) if (SupportList == null)
{ {
Console.WriteLine("[-] WeChat Base Address Get Faild"); Console.WriteLine("[-] WeChat Base Address Get Faild");
} }
else else
{ {
int WeChatName = (int)Program.WeChatWinBaseAddress + list[0]; int WeChatKey = (int)Program.WeChatWinBaseAddress + SupportList[4];
string HexKey = Program.GetHex(WeChatProcess.Handle, (IntPtr)WeChatKey);
if (string.IsNullOrWhiteSpace(HexKey))
{
Console.WriteLine("[-] WeChat Is Run, But Maybe No Login");
return;
}
else
{
int WeChatName = (int)Program.WeChatWinBaseAddress + SupportList[0];
Console.WriteLine("[+] WeChatName: " + Program.GetName(WeChatProcess.Handle, (IntPtr)WeChatName, 100)); Console.WriteLine("[+] WeChatName: " + Program.GetName(WeChatProcess.Handle, (IntPtr)WeChatName, 100));
int WeChatAccount = (int)Program.WeChatWinBaseAddress + list[1]; int WeChatAccount = (int)Program.WeChatWinBaseAddress + SupportList[1];
string Account = Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatAccount); string Account = Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatAccount);
if (string.IsNullOrWhiteSpace(Account)) if (string.IsNullOrWhiteSpace(Account))
{ {
Console.WriteLine("[-] WeChatAccount: Can't Get User Account, Maybe No Login or User Is No Set Account"); Console.WriteLine("[-] WeChatAccount: Maybe User Is No Set Account");
} }
else else
{ {
Console.WriteLine("[+] WeChatAccount: " + Program.GetAccount(WeChatProcess.Handle, (IntPtr)WeChatAccount, 100)); Console.WriteLine("[+] WeChatAccount: " + Program.GetAccount(WeChatProcess.Handle, (IntPtr)WeChatAccount, 100));
} }
int WeChatMobile = (int)Program.WeChatWinBaseAddress + list[2]; int WeChatMobile = (int)Program.WeChatWinBaseAddress + SupportList[2];
string Mobile = Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatMobile); string Mobile = Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatMobile);
if (string.IsNullOrWhiteSpace(Mobile)) if (string.IsNullOrWhiteSpace(Mobile))
{ {
Console.WriteLine("[-] WeChatMobile: Can't Get User Mobile, Maybe No Login or User Is No Binding Mobile"); Console.WriteLine("[-] WeChatMobile: Maybe User Is No Binding Mobile");
} }
else else
{ {
Console.WriteLine("[+] WeChatMobile: " + Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatMobile, 100)); Console.WriteLine("[+] WeChatMobile: " + Program.GetMobile(WeChatProcess.Handle, (IntPtr)WeChatMobile, 100));
} }
int WeChatMail = (int)Program.WeChatWinBaseAddress + list[3]; int WeChatMail = (int)Program.WeChatWinBaseAddress + SupportList[3];
string Mail = Program.GetMail(WeChatProcess.Handle, (IntPtr)WeChatMail); string Mail = Program.GetMail(WeChatProcess.Handle, (IntPtr)WeChatMail);
if (string.IsNullOrWhiteSpace(Mail) != false){} if (string.IsNullOrWhiteSpace(Mail) != false) { }
else else
{ {
Console.WriteLine("[+] WeChatMail: " + Program.GetMail(WeChatProcess.Handle, (IntPtr)WeChatMail, 100)); Console.WriteLine("[+] WeChatMail: " + Program.GetMail(WeChatProcess.Handle, (IntPtr)WeChatMail, 100));
} }
int WeChatKey = (int)Program.WeChatWinBaseAddress + list[4];
string HexKey = Program.GetHex(WeChatProcess.Handle, (IntPtr)WeChatKey);
if (string.IsNullOrWhiteSpace(HexKey))
{
Console.WriteLine("[-] WeChatKey: WeChat Is Run, But Maybe No Login");
return;
}
else
{
Console.WriteLine("[+] WeChatKey: " + HexKey); Console.WriteLine("[+] WeChatKey: " + HexKey);
} }
} }
@ -201,7 +200,7 @@ namespace WeChatGetKey
public static extern int GetModuleHandleA(string moduleName); public static extern int GetModuleHandleA(string moduleName);
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, int lpNumberOfBytesRead); public static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int nSize, int lpNumberOfBytesRead);
public static Dictionary<string, List<int>> versionlist = new Dictionary<string, List<int>> public static Dictionary<string, List<int>> VersionList = new Dictionary<string, List<int>>
{ {
{ {
"3.2.1.154", "3.2.1.154",