Advertisement
Guest User

Untitled

a guest
May 27th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.93 KB | None | 0 0
  1. using KeepOnGoing.Properties;
  2. using Microsoft.Win32;
  3. using System;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Media;
  7. using System.Net;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Windows.Forms;
  12.  
  13. namespace KeepOnGoing
  14. {
  15.     internal class Program
  16.     {
  17.         public static StreamWriter writer;
  18.  
  19.         public static string user;
  20.  
  21.         public static string pass;
  22.  
  23.         public static string level;
  24.  
  25.         public static string hint = "Level 4 Tip:look for me in the Registry!";
  26.  
  27.         public static string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\account.txt";
  28.  
  29.         private static RegistryKey key;
  30.  
  31.         public static void SignUp()
  32.         {
  33.             Console.ForegroundColor = ConsoleColor.Yellow;
  34.             Console.WriteLine("Welcome to KeepOnGoing!");
  35.             Console.WriteLine(string.Concat(new string[]
  36.             {
  37.                 "In this challenge you have to pass 5 levels , but first-let's sign-up!",
  38.                 Environment.NewLine,
  39.                 Environment.NewLine,
  40.                 "Remember-once you have signed up you cannot sign up anymore!",
  41.                 Environment.NewLine,
  42.                 "Your user details are unique and cannot be changed in the future."
  43.             }));
  44.             while (true)
  45.             {
  46.                 Console.ForegroundColor = ConsoleColor.Green;
  47.                 Console.WriteLine("Enter your new username : ");
  48.                 Console.ForegroundColor = ConsoleColor.White;
  49.                 Program.user = Console.ReadLine();
  50.                 Console.ForegroundColor = ConsoleColor.Green;
  51.                 Console.WriteLine("Enter your new Password : ");
  52.                 Console.ForegroundColor = ConsoleColor.White;
  53.                 Program.pass = Console.ReadLine();
  54.                 bool flag = string.IsNullOrEmpty(Program.user) || string.IsNullOrEmpty(Program.pass);
  55.                 if (!flag)
  56.                 {
  57.                     break;
  58.                 }
  59.                 Console.ForegroundColor = ConsoleColor.Red;
  60.                 Console.WriteLine("No empty fields please!" + Environment.NewLine);
  61.             }
  62.             WebRequest webRequest = WebRequest.Create("http://1fxpchallenge.esy.es/index.php?action=insert&user=" + Program.user + "&pass=" + Program.pass);
  63.             WebResponse response = webRequest.GetResponse();
  64.             string a;
  65.             using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
  66.             {
  67.                 a = streamReader.ReadToEnd();
  68.             }
  69.             bool flag2 = a == "insert";
  70.             if (flag2)
  71.             {
  72.                 Program.writer = new StreamWriter(Program.path);
  73.                 Program.writer.WriteLine(Program.user);
  74.                 Program.writer.WriteLine(Program.pass);
  75.                 Program.writer.WriteLine("1");
  76.                 Program.writer.Close();
  77.                 File.SetAttributes(Program.path, FileAttributes.Hidden);
  78.                 Console.WriteLine("The challenge has started!");
  79.                 Console.ForegroundColor = ConsoleColor.Yellow;
  80.                 Console.WriteLine("Goodluck from Fxp");
  81.             }
  82.             else
  83.             {
  84.                 Console.WriteLine("somthing went wrong...");
  85.             }
  86.             Console.ReadKey();
  87.             Environment.Exit(0);
  88.         }
  89.  
  90.         public static string NeedUpdate(string level)
  91.         {
  92.             int num = 0;
  93.             Settings.Default.needupdate = true;
  94.             Settings.Default.Save();
  95.             File.SetAttributes(Program.path, FileAttributes.Normal);
  96.             Program.writer = new StreamWriter(Program.path);
  97.             Program.writer.WriteLine(Program.user);
  98.             Program.writer.WriteLine(Program.pass);
  99.             bool flag = level == "Done";
  100.             if (flag)
  101.             {
  102.                 Program.writer.WriteLine(level);
  103.             }
  104.             else
  105.             {
  106.                 num = Convert.ToInt32(level);
  107.                 Program.writer.WriteLine(++num);
  108.             }
  109.             Program.writer.Close();
  110.             File.SetAttributes(Program.path, FileAttributes.Hidden);
  111.             return num.ToString();
  112.         }
  113.  
  114.         public static int DecreaseTries()
  115.         {
  116.             int num = Convert.ToInt32(Program.key.GetValue("tries"));
  117.             Program.key.SetValue("tries", --num);
  118.             return num;
  119.         }
  120.  
  121.         public static void level4()
  122.         {
  123.             Program.key = Registry.CurrentUser.OpenSubKey("KeepOnGoing", RegistryKeyPermissionCheck.ReadWriteSubTree);
  124.             Console.ForegroundColor = ConsoleColor.Yellow;
  125.             Console.WriteLine("From now on,you have only 100 attempts to win this level");
  126.             Console.WriteLine("Change it at least to 200!");
  127.             Console.WriteLine("Tip: a reflector/hex editor might help");
  128.             Program.key = Registry.CurrentUser.OpenSubKey("KeepOnGoing", RegistryKeyPermissionCheck.ReadWriteSubTree);
  129.             int i = Convert.ToInt32(Program.key.GetValue("tries"));
  130.             while (i < 200)
  131.             {
  132.                 bool flag = i < 1;
  133.                 if (flag)
  134.                 {
  135.                     Console.ForegroundColor = ConsoleColor.Red;
  136.                     Console.WriteLine("Sorry,but you have consumed all the attempts");
  137.                     Console.Read();
  138.                     Environment.Exit(0);
  139.                 }
  140.                 else
  141.                 {
  142.                     Console.ReadLine();
  143.                     i = Program.DecreaseTries();
  144.                     Console.WriteLine("You have only " + i + " attempts.");
  145.                 }
  146.             }
  147.             Console.WriteLine(Environment.NewLine + Environment.NewLine + Environment.NewLine);
  148.             Console.ForegroundColor = ConsoleColor.Green;
  149.             Console.WriteLine("Congratulations,You made it! lets move on to level the final stage!");
  150.             Program.level = Program.NeedUpdate(Program.level);
  151.             Program.level5();
  152.         }
  153.  
  154.         public static string Base64Decode(string base64EncodedData)
  155.         {
  156.             byte[] bytes = Convert.FromBase64String(base64EncodedData);
  157.             return Encoding.UTF8.GetString(bytes);
  158.         }
  159.  
  160.         public static void level3()
  161.         {
  162.             Console.WriteLine("Convert the following phase to ternary");
  163.             Console.BackgroundColor = ConsoleColor.Red;
  164.             Console.ForegroundColor = ConsoleColor.White;
  165.             Console.WriteLine("\r\n      if (x > 1)\r\n      Console.WriteLine(\"Congratulations\");\r\n      else\r\n      Console.WriteLine(\"Try again please\");\r\n");
  166.             Console.BackgroundColor = ConsoleColor.Black;
  167.             string text = "Console.WriteLine(x > 1 ? \"Congratulations\" : \"Try again please\");";
  168.             string text2 = Console.ReadLine();
  169.             while (!text2.Trim().Equals(text.Trim()))
  170.             {
  171.                 Console.ForegroundColor = ConsoleColor.Red;
  172.                 Console.WriteLine("Incorrect.Please try again.");
  173.                 Console.ForegroundColor = ConsoleColor.White;
  174.                 text2 = Console.ReadLine();
  175.             }
  176.             Console.ForegroundColor = ConsoleColor.Green;
  177.             Console.WriteLine("Congratulations,You made it! lets move on to level 4!");
  178.             RegistryKey registryKey = Registry.CurrentUser.CreateSubKey("KeepOnGoing", RegistryKeyPermissionCheck.ReadWriteSubTree);
  179.             registryKey.SetValue("tries", 100);
  180.             Program.level = Program.NeedUpdate(Program.level);
  181.             Program.level4();
  182.         }
  183.  
  184.         public static void level5()
  185.         {
  186.             Console.ForegroundColor = ConsoleColor.Green;
  187.             Console.WriteLine("Wow" + Environment.NewLine);
  188.             Console.WriteLine("I must admit-i wouldn't belive you'll reach the final stage!");
  189.             Console.WriteLine("Just Press enter to win...");
  190.             string a = Console.ReadLine();
  191.             while (a != "enter")
  192.             {
  193.                 Console.ForegroundColor = ConsoleColor.Red;
  194.                 Console.WriteLine("Damnn you are so close!");
  195.                 a = Console.ReadLine();
  196.             }
  197.             SoundPlayer soundPlayer = new SoundPlayer(Resources.sound);
  198.             soundPlayer.Play();
  199.             Console.ForegroundColor = ConsoleColor.Green;
  200.             Console.WriteLine("Woah!Unbelievable!");
  201.             Console.WriteLine("You have won!!!");
  202.             Console.WriteLine("Fxp is proud of you!");
  203.             Thread.Sleep(5000);
  204.             Program.NeedUpdate("Done");
  205.             Program.FinalReward();
  206.         }
  207.  
  208.         public static void FinalReward()
  209.         {
  210.             Console.ForegroundColor = ConsoleColor.Green;
  211.             Console.WriteLine("In order to achieve the reward you will have to enter your Fxp Nickname");
  212.             Console.WriteLine("Fill it carefully");
  213.             string text = "";
  214.             string a = "n";
  215.             while (a != "y")
  216.             {
  217.                 Console.WriteLine("Enter your nickname:");
  218.                 text = Console.ReadLine();
  219.                 Console.WriteLine("Are you sure that this is your Fxp user?" + Environment.NewLine + "Type y or n");
  220.                 a = Console.ReadLine();
  221.             }
  222.             File.AppendAllText(Program.path, text);
  223.             WebRequest webRequest = WebRequest.Create(string.Concat(new string[]
  224.             {
  225.                 "http://1fxpchallenge.esy.es/index.php?action=update&user=",
  226.                 Program.user,
  227.                 "&pass=",
  228.                 Program.pass,
  229.                 "&nick=",
  230.                 text,
  231.                 "&level=Done"
  232.             }));
  233.             WebResponse response = webRequest.GetResponse();
  234.             string a2;
  235.             using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
  236.             {
  237.                 a2 = streamReader.ReadToEnd();
  238.             }
  239.             bool flag = a2 == "nick";
  240.             if (flag)
  241.             {
  242.                 Console.WriteLine(string.Concat(new string[]
  243.                 {
  244.                     "Thank you for participating in the challenge,",
  245.                     text,
  246.                     ".",
  247.                     Environment.NewLine,
  248.                     "We all wish you happy passover:)"
  249.                 }));
  250.                 Program.CleanUp();
  251.             }
  252.         }
  253.  
  254.         public static void level2()
  255.         {
  256.             string text = string.Concat(File.ReadLines("settings.txt"));
  257.             bool flag = Program.Base64Decode(text).Equals("can_play=true");
  258.             if (flag)
  259.             {
  260.                 Console.ForegroundColor = ConsoleColor.Green;
  261.                 Console.WriteLine("Congratulations,You made it! lets move on to level 3!");
  262.                 Console.ForegroundColor = ConsoleColor.White;
  263.                 Program.level = Program.NeedUpdate(Program.level);
  264.                 Program.level3();
  265.             }
  266.             else
  267.             {
  268.                 Console.ForegroundColor = ConsoleColor.Red;
  269.                 Console.WriteLine("Oh,it seems like somthing went wrong in the settings...");
  270.                 Console.WriteLine("Try to fix it so you can keep on playing.....");
  271.                 Console.ForegroundColor = ConsoleColor.White;
  272.                 Console.WriteLine(text);
  273.                 Thread.Sleep(1000000);
  274.             }
  275.         }
  276.  
  277.         public static void CleanUp()
  278.         {
  279.             Console.WriteLine("Cleaning up");
  280.             Process.Start(new ProcessStartInfo
  281.             {
  282.                 Arguments = "/C choice /C Y /N /D Y /T 0 & Del \"" + Application.ExecutablePath + "\"",
  283.                 WindowStyle = ProcessWindowStyle.Hidden,
  284.                 CreateNoWindow = true,
  285.                 FileName = "cmd.exe"
  286.             });
  287.         }
  288.  
  289.         public static int UpdateLevel(string level)
  290.         {
  291.             WebRequest webRequest = WebRequest.Create(string.Concat(new string[]
  292.             {
  293.                 "http://1fxpchallenge.esy.es/index.php?action=update&user=",
  294.                 Program.user,
  295.                 "&pass=",
  296.                 Program.pass,
  297.                 "&level=",
  298.                 level
  299.             }));
  300.             WebResponse response = webRequest.GetResponse();
  301.             string a;
  302.             using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
  303.             {
  304.                 a = streamReader.ReadToEnd();
  305.             }
  306.             bool flag = a == "update";
  307.             int result;
  308.             if (flag)
  309.             {
  310.                 result = 0;
  311.             }
  312.             else
  313.             {
  314.                 result = -1;
  315.             }
  316.             return result;
  317.         }
  318.  
  319.         private static void Main(string[] args)
  320.         {
  321.             bool flag = !File.Exists(Program.path);
  322.             if (flag)
  323.             {
  324.                 Program.SignUp();
  325.             }
  326.             else
  327.             {
  328.                 StreamReader streamReader = new StreamReader(Program.path);
  329.                 Program.user = streamReader.ReadLine().Trim();
  330.                 Program.pass = streamReader.ReadLine().Trim();
  331.                 Program.level = streamReader.ReadLine().Trim();
  332.                 try
  333.                 {
  334.                     object obj = streamReader.ReadLine().Trim();
  335.                     Console.WriteLine("Seems like you've already won...");
  336.                     Console.Read();
  337.                     streamReader.Close();
  338.                 }
  339.                 catch
  340.                 {
  341.                     streamReader.Close();
  342.                     bool flag2 = Program.level == "1";
  343.                     if (flag2)
  344.                     {
  345.                         bool flag3 = args.Length != 2;
  346.                         if (flag3)
  347.                         {
  348.                             Console.WriteLine("Usage [username] [password]");
  349.                             Environment.Exit(0);
  350.                         }
  351.                         bool flag4 = args[0].Trim() == Program.user && args[1].Trim() == Program.pass;
  352.                         if (flag4)
  353.                         {
  354.                             Console.ForegroundColor = ConsoleColor.Green;
  355.                             Console.WriteLine("Congratulations,You made it! lets move on to level 2");
  356.                             Console.WriteLine("..........");
  357.                             Program.level = Program.NeedUpdate(Program.level);
  358.                             File.WriteAllText("settings.txt", "Y2FuX3BsYXk9ZmFsc2U=");
  359.                             Program.level2();
  360.                         }
  361.                         else
  362.                         {
  363.                             Console.WriteLine("wrong Username/Password");
  364.                         }
  365.                     }
  366.                     else
  367.                     {
  368.                         bool flag5 = Program.level.ToString() != "Done";
  369.                         if (flag5)
  370.                         {
  371.                             bool needupdate = Settings.Default.needupdate;
  372.                             if (needupdate)
  373.                             {
  374.                                 Program.UpdateLevel(Program.level);
  375.                                 Settings.Default.needupdate = false;
  376.                                 Settings.Default.Save();
  377.                             }
  378.                             string name = "level" + Program.level.ToString();
  379.                             Type typeFromHandle = typeof(Program);
  380.                             MethodInfo method = typeFromHandle.GetMethod(name);
  381.                             method.Invoke(null, null);
  382.                         }
  383.                         else
  384.                         {
  385.                             Program.FinalReward();
  386.                         }
  387.                     }
  388.                 }
  389.             }
  390.         }
  391.     }
  392. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement