Advertisement
smoc

MD5 Accounts program

Oct 31st, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.45 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using System.Security;
  9. using System.Security.Cryptography;
  10. using System.Net;
  11. using System.Text.RegularExpressions;
  12.  
  13. namespace md5Generator
  14. {
  15.     class Program
  16.     {
  17.         static string[] fUsr;
  18.         static string nUsr;
  19.         static string[] cHash;
  20.         static string nHash;
  21.         static bool log = false;
  22.         static int lineFound;
  23.         static string cPassHash;
  24.         static string usrAddr= "C:\\Users\\atlan\\Documents\\accs\\usrs.txt";
  25.         static string lstAddr = "C:\\Users\\atlan\\Documents\\accs\\lst.txt";
  26.         static string usrsFile = System.IO.File.ReadAllText("C:\\Users\\atlan\\Documents\\accs\\usrs.txt");
  27.         static string lstFile = System.IO.File.ReadAllText("C:\\Users\\atlan\\Documents\\accs\\lst.txt");
  28.         static string nWrd;
  29.         static string uname;
  30.         static string pword;
  31.         static void Main(string[] args)
  32.         {
  33.             Console.Title = "MD5 Accounts program - By smoc";
  34.             existCheck("");
  35.             Console.ForegroundColor = ConsoleColor.White;
  36.             while (true)
  37.             {
  38.                 if (log == false)
  39.                 {
  40.                     Console.WriteLine("1. Create account.");
  41.                     Console.WriteLine("2. Login to a current account.");
  42.  
  43.                     Console.WriteLine();
  44.                     Console.Write(" > ");
  45.                     string inp = Console.ReadLine();
  46.                     if (inp == "1")
  47.                     {
  48.                         createAcc("");
  49.                     }
  50.                     else if (inp == "2")
  51.                     {
  52.                         login("");
  53.                     }
  54.                     else if (inp == "/admin")
  55.                     {
  56.                         admin("");
  57.                     }
  58.                 }
  59.                 else
  60.                 {
  61.                     Console.WriteLine("1. Youtube.");
  62.                     Console.WriteLine("2. Facebook.");
  63.                     Console.WriteLine("2. Smoc.");
  64.  
  65.                     Console.WriteLine();
  66.                     Console.Write(" > ");
  67.                     string inp = Console.ReadLine();
  68.                     if (inp == "1")
  69.                     {
  70.                         System.Diagnostics.Process.Start("http://youtube.com/");
  71.                         Console.ReadKey();
  72.                     }
  73.                     else if (inp == "2")
  74.                     {
  75.                         System.Diagnostics.Process.Start("http://facebook.com/");
  76.                         Console.ReadKey();
  77.                     }
  78.                     else if (inp == "3")
  79.                     {
  80.                         System.Diagnostics.Process.Start("http://smoc.pw/");
  81.                         Console.ReadKey();
  82.                     } else if (inp == "/quit")
  83.                     {
  84.                         log = false;
  85.                         Thread.Sleep(300);
  86.                     }
  87.                 }
  88.             }
  89.         }
  90.         static void admin(string text)
  91.         {
  92.             Console.ForegroundColor = ConsoleColor.Yellow;
  93.             Console.Write("Root password > ");
  94.             string ps = Console.ReadLine();
  95.             if (ps == "admin")
  96.             {
  97.                 Console.ForegroundColor = ConsoleColor.Cyan;
  98.                 while (true) {
  99.                     Console.WriteLine("1. Show all users & hashes.");
  100.                     Console.WriteLine("2. Show all passes & hashes.");
  101.  
  102.                     Console.WriteLine();
  103.                     Console.Write(" > ");
  104.                     string vro = Console.ReadLine();
  105.                     if (vro == "1")
  106.                     {
  107.                         Console.Write(usrsFile);
  108.                         Console.WriteLine();
  109.                     }
  110.                     else if (vro == "2")
  111.                     {
  112.                         Console.Write(lstFile);
  113.                         Console.WriteLine();
  114.                     }
  115.                     else if (vro == "/quit")
  116.                     {
  117.                         Thread.Sleep(300);
  118.                         Console.Clear();
  119.                         break;
  120.                     }
  121.                 }
  122.                 Console.ForegroundColor = ConsoleColor.White;
  123.             } else
  124.             {
  125.                 Console.WriteLine("Incorrect password.");
  126.                 Console.ForegroundColor = ConsoleColor.White;
  127.             }
  128.         }
  129.         static void existCheck(string args)
  130.         {
  131.             Console.ForegroundColor = ConsoleColor.Cyan;
  132.             Console.Clear();
  133.             Console.WriteLine("Checking for directories...");
  134.             Thread.Sleep(500);
  135.             if (File.Exists(usrAddr))
  136.             {
  137.                 if (File.Exists(lstAddr))
  138.                 {
  139.                     Console.Clear();
  140.                     Console.WriteLine("USRS Directory exists.");
  141.                     Thread.Sleep(300);
  142.                     Console.WriteLine("LST Directory exists.");
  143.                     Thread.Sleep(300);
  144.                 }
  145.             }
  146.             else
  147.             {
  148.                 Console.Clear();
  149.                 Console.WriteLine("Directories do not exist, creating them now...");
  150.                 Thread.Sleep(300);
  151.                 Directory.CreateDirectory("C:\\Users\\atlan\\Documents\\aids\\");
  152.                 File.Create("C:\\Users\\atlan\\Documents\\acc\\usrs.txt");
  153.                 File.Create("C:\\Users\\atlan\\Documents\\accs\\lst.txt");
  154.                 Thread.Sleep(300);
  155.             }
  156.             Console.Clear();
  157.             Console.ForegroundColor = ConsoleColor.White;
  158.         }
  159.         static string md5Gen(string text)
  160.         {
  161.             MD5 hash = new MD5CryptoServiceProvider();
  162.             hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(text));
  163.             byte[] result = hash.Hash;
  164.             StringBuilder strBldr = new StringBuilder();
  165.             for (int i = 0; i < result.Length; i++)
  166.             {
  167.                 strBldr.Append(result[i].ToString("x2"));
  168.             }
  169.             return strBldr.ToString();
  170.         }
  171.         static void login(string args)
  172.         {
  173.             Console.Write("Username: ");
  174.             uname = Console.ReadLine();
  175.             Console.Write("Password: ");
  176.             pword = Console.ReadLine();
  177.             while (true)
  178.             {
  179.                 if (usrsFile.Contains(uname))
  180.                 {
  181.                     if (lstFile.Contains(pword))
  182.                     {
  183.                         cPassHash = md5Gen(pword);
  184.                         checkHash(cPassHash);
  185.                         break;
  186.                     } else
  187.                     {
  188.                         Console.WriteLine("Error...");
  189.                         break;
  190.                     }
  191.                 }
  192.                 else
  193.                 {
  194.                     Console.WriteLine("Error, incorrect username or password.");
  195.                     Console.Write("Username: ");
  196.                     uname = Console.ReadLine();
  197.                     Console.Write("Password: ");
  198.                     pword = Console.ReadLine();
  199.                 }
  200.             }
  201.         }
  202.         static void createAcc(string args)
  203.         {
  204.             Console.Write("Username: ");
  205.             string unameReg = Console.ReadLine();
  206.             Console.Write("Password: ");
  207.             string pwordReg = Console.ReadLine();
  208.             Console.Write("Re-Enter Password: ");
  209.             string pwordRegCheck = Console.ReadLine();
  210.             while (true)
  211.             {
  212.                 if (pwordReg == pwordRegCheck)
  213.                 {
  214.                     break;
  215.                 } else
  216.                 {
  217.                     Console.WriteLine();
  218.                     Console.WriteLine("Incorrect, please enter passwords that are the same.");
  219.                     Thread.Sleep(1000);
  220.                     Console.Clear();
  221.                     Console.Write("Password: ");
  222.                     pwordReg = Console.ReadLine();
  223.                     Console.Write("Re-Enter Password: ");
  224.                     pwordRegCheck = Console.ReadLine();
  225.                 }
  226.             }
  227.             while (true) {
  228.                 if (System.IO.File.ReadAllText("C:\\Users\\atlan\\Documents\\accs\\usrs.txt").Contains(unameReg))
  229.                 {
  230.                     Console.Write("That username is taken, please choose another username: ");
  231.                     unameReg = Console.ReadLine();
  232.                 }
  233.                 else
  234.                 {
  235.                     break;
  236.                 }
  237.             }
  238.             string pwordHash = md5Gen(pwordReg);
  239.             string newWrd = "\n" + pwordHash + " " + pwordReg;
  240.             string newAcc = "\n" + pwordHash + ":" + unameReg;
  241.             System.IO.File.AppendAllText("C:\\Users\\atlan\\Documents\\accs\\usrs.txt", newAcc);
  242.             if (System.IO.File.ReadAllText("C:\\Users\\atlan\\Documents\\accs\\lst.txt").Contains(newWrd))
  243.             {
  244.             }
  245.             else
  246.             {
  247.                 System.IO.File.AppendAllText("C:\\Users\\atlan\\Documents\\accs\\lst.txt", newWrd);
  248.             }
  249.             Console.ForegroundColor = ConsoleColor.Green;
  250.             Console.WriteLine("Account successfully created.");
  251.             Console.ForegroundColor = ConsoleColor.White;
  252.             Thread.Sleep(1000);
  253.             Console.Clear();
  254.         }
  255.         static void checkHash(string args)
  256.         {
  257.             //Word file
  258.             int counter = 0;
  259.             TextReader tr = new StreamReader(lstAddr);
  260.             int lineAmount = File.ReadLines(lstAddr).Count();
  261.             string[] ListLines = new string[lineAmount];
  262.             for (int i = 0; i < lineAmount; i++)
  263.             {
  264.                 ListLines[i] = tr.ReadLine();
  265.                 if (ListLines[i].Contains(cPassHash))
  266.                 {
  267.                     nHash = ListLines[i];
  268.                     cHash = nHash.Split(' ');
  269.                     nHash = cHash[0];
  270.                 }
  271.                 counter++;
  272.             }
  273.             //User file
  274.             counter = 0;
  275.             tr = new StreamReader(usrAddr);
  276.             lineAmount = File.ReadLines(usrAddr).Count();
  277.             ListLines = new string[lineAmount];
  278.             for (int i = 0; i < lineAmount; i++)
  279.             {
  280.                 ListLines[i] = tr.ReadLine();
  281.                 if (ListLines[i].Contains(nHash))
  282.                 {
  283.                     nUsr = ListLines[i];
  284.                     fUsr = nUsr.Split(':');
  285.                     nUsr = fUsr[1];
  286.                     if(nUsr == uname)
  287.                     {
  288.                         log = true;
  289.                         Console.ForegroundColor = ConsoleColor.Green;
  290.                         Console.WriteLine("Successfully logged in.");
  291.                         Thread.Sleep(100);
  292.                         Console.Title = "MD5 Accounts program - By smoc | Logged in as " + uname;
  293.                         Console.ForegroundColor = ConsoleColor.White;
  294.                     } else
  295.                     {
  296.                         Console.ForegroundColor = ConsoleColor.Red;
  297.                         Thread.Sleep(100);
  298.                         Console.WriteLine("Password and/or username incorrect!");
  299.                         Console.ForegroundColor = ConsoleColor.White;
  300.                         break;
  301.                     }
  302.                 }
  303.                 counter++;
  304.             }
  305.         }
  306.     }
  307. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement