public static void GameOutput(object sender, System.Diagnostics.DataReceivedEventArgs args) { if (!string.IsNullOrEmpty(args.Data)) { ConsoleLogger.LogData(args.Data, "Game"); } }
private void button2_Click(object sender, EventArgs e) { if (!IsInputOK(textBox1.Text, textBox2.Text)) { return; } WebClient wc = new WebClient(); wc.Proxy = null; ConsoleLogger.LogData("Poskusam ustvarit novega userja..."); string result = wc.DownloadString("https://minecraft.knuples.net/new.php?user="******"&pass="******"&mail=" + textBox3.Text + "&hwid=" + getFingerprint()); ConsoleLogger.LogData("Dobil nazaj: " + result); if (result != "OK") { label6.Text = "Username ze obstaja"; label6.Show(); textBox1.Text = ""; timer2.Enabled = true; ConsoleLogger.LogData("Ze obstaja!"); return; } label6.Text = "Uspesno registriran"; label6.ForeColor = Color.Lime; label6.Show(); timer4.Enabled = true; button3_Click(sender, e); }
private void SaveConfig() { ConsoleLogger.LogData("Shranjujem config..."); if (checkBox1.Checked) { config.SetValue("user", textBox1.Text); config.SetValue("pass", textBox2.Text); config.SetValue("remember", "1"); } else { config.SetValue("user", ""); config.SetValue("pass", ""); config.SetValue("remember", "0"); } if (checkBox2.Checked) { config.SetValue("autologin", "1"); } else { config.SetValue("autologin", "0"); } config.FlushConfig(); }
private void timer3_Tick(object sender, EventArgs e) { if (gameticks == 900) { gameticks = 0; WebClient wc = new WebClient(); wc.Proxy = null; ConsoleLogger.LogData("900 tickov preteklo, reauth!"); try { wc.DownloadString("https://minecraft.knuples.net/auth.php?user="******"&pass="******"&hwid=" + getFingerprint()); } catch (Exception ex) { ConsoleLogger.LogData("Ne gre reauth, Error? He?", "OnTick"); ConsoleLogger.LogData("** " + ex.Message, "OnTick"); } } if (game.HasExited) { ConsoleLogger.LogData("Java je sla k rakom zvizgat, zakljucujem!"); if (!ConsoleLogger.debugscreen.Visible) { Application.Exit(); Environment.Exit(0); } else { timer3.Enabled = false; ConsoleLogger.debugscreen.closeonexit = true; } } gameticks++; }
public void ResetMirrors() { ConsoleLogger.LogData("Restart mirrorjev, default!"); mirrors = new Dictionary <string, string>(); mirrors.Add("main", "https://minecraft.knuples.net/updates/"); this.SetVar("TIMEOUT", "0"); this.SetVar("MIRROR", "main"); }
private void DetectJava() { string command = "java"; System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = command; startInfo.UseShellExecute = true; process.StartInfo = startInfo; try { process.Start(); process.WaitForExit(); hasjava = true; ConsoleLogger.LogData("Java in PATH, good.", 1); } catch { // No java? That's bad. Windows mogoc? PATH f****d up? // Ker to je Windows, kjer je cudez da kaj dejansko dela po planu! if (!loonix) { ConsoleLogger.LogData("Jave ne najdem v PATH. Tole je ziher Windows."); string progfiles = Environment.GetEnvironmentVariable("ProgramFiles"); string jpath = null; if (Directory.Exists(progfiles + "\\Java")) { jpath = progfiles + "\\Java"; } else if (Directory.Exists(progfiles + " (x86)\\Java")) { jpath = progfiles + " (x86)\\Java"; } if (jpath != null) { foreach (string path in Directory.GetDirectories(jpath)) { if (File.Exists(path + "\\bin\\java.exe")) { javaname = path + "\\bin\\java.exe"; hasjava = true; break; } } } if (hasjava) { ConsoleLogger.LogData("Najdu javo v: " + javaname); } else { ConsoleLogger.LogData("Ne najdem jave, f**k!"); } } }; }
public void UpdateStatus(string status) { if (this.updwindow != null) { try { this.updwindow.Invoke(updwindow.setstatus, status); } catch (Exception e) { } } ConsoleLogger.LogData(status, 2); }
public void SetVar(string key, string value) { string spam; if (this.vars.TryGetValue(key, out spam)) { ConsoleLogger.LogData(key + "=" + value); this.vars[key] = value; } else { ConsoleLogger.LogData("[NEW] " + key + "=" + value); this.vars.Add(key, value); } }
static void Main() { int p = (int)Environment.OSVersion.Platform; if ((p == 4) || (p == 6) || (p == 128)) { isloonix = true; } else { isloonix = false; } ConsoleLogger.debugscreen = null; System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object appsend, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { var caroot = new X509Certificate(LameLauncher.Properties.Resources.caroot); if (caroot.Issuer == certificate.Issuer) { return(true); } if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None) { return(true); } if ((Form1.config != null) && (Form1.config.GetValue("ignoressl", "0") == "1")) { return(true); } ConsoleLogger.LogData("Certificate error: " + sslPolicyErrors.ToString(), "Program"); ConsoleLogger.LogData("Fault certificate: " + certificate.ToString(), "Program"); return(false); }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
public static void LogData(string par1, int frame) { ConsoleLogger.LogData(par1, GetCurrentMethod(frame)); }
public static void LogData(string par1) { ConsoleLogger.LogData(par1, 2); }
public Form1() { InitializeComponent(); variables = new VarStorage(); variables.SetValue("version", version); ConsoleLogger.debugscreen = new DebugScr(); ConsoleLogger.debugscreen.Show(); bool hide = true; string chdir = ""; if ((File.Exists("ll-debugme")) || (File.Exists("ll-debugme.txt"))) { hide = false; } if (Environment.GetCommandLineArgs().Length >= 2) { string[] cmdline = Environment.GetCommandLineArgs(); int i = 1; while (i < cmdline.Length) { if (cmdline[i] == "--debug") { hide = false; } else if (cmdline[i] == "--dir") { chdir = cmdline[(i + 1)]; } i++; } } if (hide) { ConsoleLogger.debugscreen.Hide(); } this.KeyPreview = true; ConsoleLogger.LogData("LL " + Form1.version + " @ " + Environment.GetCommandLineArgs()[0], "Main"); ConsoleLogger.LogData("Environment fingerprint: " + getFingerprint()); dec = -50; offline = false; hasjava = false; Updater upd = new Updater("."); loonix = Updater.IsLoonix(); string os = "Windoze"; javaname = "java"; string fd = "\\"; if (loonix) { fd = "/"; os = "Linux"; } variables.SetValue("fd", fd); string installpath = ""; string tempdir = ""; if (!loonix) { installpath = Environment.GetEnvironmentVariable("APPDATA") + fd + "LameCraft"; tempdir = Environment.GetEnvironmentVariable("TEMP"); } else { installpath = Environment.GetEnvironmentVariable("HOME") + fd + ".LameCraft"; tempdir = "/tmp"; } if (chdir != "") { installpath = chdir; } variables.SetValue("lldir", installpath); ConsoleLogger.LogData("OS: " + os, "Main"); ConsoleLogger.LogData("MCIP: " + installpath, "Main"); ConsoleLogger.LogData("TMP: " + tempdir, "Main"); if (!Directory.Exists(installpath)) { Directory.CreateDirectory(installpath); } Directory.SetCurrentDirectory(installpath); config = new ConfigFile("launcher.cfg"); label4.Text = "LameLauncher version: " + version + ", Minecraft: " + upd.GetCurrentVersion() + ", " + os; button3.Location = new Point(button3.Location.X + 400, button3.Location.Y); button2.Location = new Point(button2.Location.X + 400, button2.Location.Y); label5.Location = new Point(label5.Location.X + 400, label5.Location.Y); textBox3.Location = new Point(textBox3.Location.X + 400, textBox3.Location.Y); DetectJava(); if (hasjava) { label6.Hide(); } if (config.GetValue("offlinemode", "0") == "0") { try { ConsoleLogger.LogData("Cekiram dosegljivost auth serverja...", "Main"); upd.GetHTTPFile("https://minecraft.knuples.net/auth.php?ping=1", tempdir + fd + "deleteme.mclauncher.auth.chk", 1500); File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk"); } catch (Exception e) { ConsoleLogger.LogData("*** AUTH SERVER NEDOSEGLJIV ***", "Main"); ConsoleLogger.LogData(e.Message, "Main"); ConsoleLogger.LogData("Delujem v offline nacinu!", "Main"); offline = true; } if ((config.GetValue("chkupdate", "1") == "1") && (!offline)) { bool isupdate = false; try { // This is so important, we can't mess this up! ConsoleLogger.LogData("Cekiram za update launcherja...", "Main"); upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os, tempdir + fd + "deleteme.mclauncher.update.chk" + version, 300, 1); File.Delete(tempdir + fd + "deleteme.mclauncher.update.chk"); UpdateWindow uw = new UpdateWindow(); uw.NewStatus("Launcher ima nov update, downloadam..."); ConsoleLogger.LogData("Launcher ima nov update!", "Main"); isupdate = true; uw.runthread = false; uw.Show(); Application.DoEvents(); string ofile = tempdir + fd + "deleteme." + version + "mclauncher.update.exe"; Application.DoEvents(); upd.GetHTTPFile("https://minecraft.knuples.net/updates/launcher/" + version + "." + os + ".bin", ofile, 1000); uw.Hide(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; startInfo.FileName = ofile; startInfo.Arguments = Environment.GetCommandLineArgs()[0]; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = startInfo; proc.Start(); Application.Exit(); Environment.Exit(0); } catch { /** WTF JE BLO TO, SHIT, SHIT, SHIT, DO TEGA NEBI SMELO PRIT! * Konec je z nami, fertik smo, adijo, zbrisi system32 in zvali krivdo * na Windowse. Po možnosti poišči še vse .doc in .jpg fajle in jih zbriši, * da se bo mel user za kaj sekirat, razen tega kak ne more minecrafta igrat **/ if (isupdate) { MessageBox.Show("Poskusal downloadat update, ampak mi nekako ni uspelo.\nProsim, prenesi update s strani!"); Environment.Exit(1); } /* Ali pa crashni aplikacijo. Jup, to bi tudi šlo. */ Application.Exit(); } int ntries = 0; while (testForMinecraftUpdate(upd)) { ntries++; ConsoleLogger.LogData("Retesting for update..."); if (ntries > 10) { MessageBox.Show("Dal že deset iteracij poskusa updejta skozi. Nekaj je hudo narobe.\nProsim kontaktiraj admine!"); Application.Exit(); Environment.Exit(0); } } } } else { ConsoleLogger.LogData("Hoces offline nacin? Tudi prav!", "Main"); offline = true; } if (offline) { checkBox2.Visible = false; linkLabel1.Visible = false; label7.Visible = true; checkBox1.Location = new Point(171, checkBox1.Location.Y); } if (config.GetValue("remember", "1") == "1") { textBox1.Text = config.GetValue("user", ""); textBox2.Text = config.GetValue("pass", ""); checkBox1.Checked = true; } if (config.GetValue("autologin", "1") == "1") { checkBox2.Checked = true; } ConsoleLogger.LogData("Init koncan, fire away!", "Main"); }
private void button1_Click(object sender, EventArgs e) { if (!offline) { if (!IsInputOK(textBox1.Text, textBox2.Text)) { return; } WebClient wc = new WebClient(); wc.Proxy = null; ConsoleLogger.LogData("Poskusam auth...", "AuthBTN"); string result = wc.DownloadString("https://minecraft.knuples.net/auth.php?user="******"&pass="******"&hwid=" + getFingerprint()); if (result != "OK") { ConsoleLogger.LogData("Nope, ne bo slo", "AuthBTN"); label6.Text = "Napacen username in/ali password"; label6.Show(); textBox2.Text = ""; timer2.Enabled = true; return; } } else { ConsoleLogger.LogData("Smo offline nacinu, delam fake auth!", "AuthBTN"); } ConsoleLogger.LogData("OK, je kulj, zaganjam!", "AuthBTN"); button1.Text = "Zaganjam..."; button1.Refresh(); this.Refresh(); SaveConfig(); gameticks = 0; System.Threading.Thread.Sleep(1000); game = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = javaname; startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; string ds = ";"; if (loonix) { ds = ":"; } variables.SetValue("serverstr", ""); if ((checkBox2.Checked) && (!offline)) { variables.SetValue("serverstr", " --server server.minecraft.knuples.net"); } string classpath = ""; string[] files = Directory.GetFiles(config.GetValue("classpath", @"$LLDIR", variables)); for (int i = 0; i < files.Length; i++) { if (files[i].Substring(files[i].Length - 4) == ".jar") { classpath = classpath + files[i] + ds; } } variables.SetValue("classpath", classpath); string lnchargs = config.GetValue("launchargs", ""); ConsoleLogger.LogData("CONFIGARGS: " + lnchargs, "AuthBTN"); variables.SetValue("user", textBox1.Text); startInfo.Arguments = variables.ProcessString(lnchargs); ConsoleLogger.LogData("Zaganjam javo z komando: ", "AuthBTN"); ConsoleLogger.LogData(startInfo.FileName + " " + startInfo.Arguments, "AuthBTN"); game.StartInfo = startInfo; game.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(Form1.GameOutput); game.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(Form1.GameOutput); game.Start(); game.BeginOutputReadLine(); game.BeginErrorReadLine(); this.Hide(); timer4.Enabled = true; }
public void GetHTTPFile(string url, string file, int tiemout, int maxtries) { if (File.Exists(file)) { File.Delete(file); } Stream output = null; if (file != null) { output = File.Create(file); } bool close = true; int tries = 0; while (true) { try { tries++; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = tiemout; request.Proxy = null; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); if ((this.updwindow != null) && (tries == 1)) { this.updwindow.Invoke(updwindow.newprogress, ""); } int count = 0; int totalread = 0; byte[] buffer = new byte[8192]; do { count = resStream.Read(buffer, 0, buffer.Length); totalread = totalread + count; if (response.ContentLength > 0) { if (this.updwindow != null) { this.updwindow.Invoke(updwindow.newprogress, Math.Round(((double)totalread / (double)response.ContentLength) * 100D, 3).ToString() + " %"); } } if ((count != 0) && (output != null)) { output.Write(buffer, 0, count); } }while (count > 0); break; } catch (Exception e) { close = false; if (output != null) { output.Close(); } if ((this.updwindow != null) && (tries == 1)) { this.updwindow.Invoke(updwindow.newprogress, ""); } if (tries > maxtries) { throw new Exception(e.Message, e); } else { File.Delete(file); if (file != null) { output = File.Create(file); } close = true; } ConsoleLogger.LogData("Download failo: " + e.Message, "GetHTTPFile"); } } if (close) { if (output != null) { output.Close(); } if (this.updwindow != null) { this.updwindow.Invoke(updwindow.newprogress, ""); } } }