Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Security.Cryptography;
- namespace ocC
- {
- class Program
- {
- class cFound
- {
- public string szUser;
- public string szPass;
- }
- static void PrintHelp()
- {
- System.Console.WriteLine(
- "OsCommerce Password Cracker\r\n" +
- "Usage: " + System.AppDomain.CurrentDomain.FriendlyName +
- " filetocrack -wl <wordlist>"
- );
- }
- static void Main(string[] args)
- {
- if (args.Length != 2)
- {
- PrintHelp();
- return;
- }
- if (File.Exists(args[0]) == false)
- {
- System.Console.WriteLine("Input file not found.");
- return;
- }
- if (File.Exists(args[1]) == false)
- {
- System.Console.WriteLine("Wordlist not found.");
- return;
- }
- List<cFound> FoundPasswords = new List<cFound>();
- StreamReader srInput = new StreamReader(args[0]);
- string szLine;
- int iLineNum = 0;
- while ((szLine = srInput.ReadLine()) != null)
- {
- iLineNum++;
- if ((szLine.Count(f => f == ':')) < 2)
- {
- System.Console.WriteLine("Invalid line in file (" + iLineNum + ")");
- continue;
- }
- string szUser = szLine.Substring(0, szLine.IndexOf(":"));
- string szSalt = szLine.Substring(szLine.LastIndexOf(":") + 1);
- string szPass = szLine.Substring(szLine.IndexOf(":", szUser.Length) + 1, szLine.Length - szUser.Length - szSalt.Length - 2);
- System.Console.WriteLine("Trying " + szUser + ":" + szPass);
- StreamReader srWL = new StreamReader(args[1]);
- string szWLLine;
- while ((szWLLine = srWL.ReadLine()) != null)
- {
- using (MD5 md5Hash = MD5.Create())
- {
- string szHash = szWLLine.Insert(0, szSalt);
- if (GetMd5Hash(md5Hash, szHash) != szPass)
- continue;
- else
- {
- cFound tmp = new cFound();
- tmp.szPass = szWLLine;
- tmp.szUser = szUser;
- FoundPasswords.Add(tmp);
- System.Console.WriteLine("Password for " + szUser + ":" + szPass + " = " + szWLLine);
- break;
- }
- }
- }
- srWL.Close();
- }
- srInput.Close();
- foreach (cFound FoundPw in FoundPasswords)
- {
- System.Console.WriteLine(FoundPw.szUser + ":" + FoundPw.szPass);
- }
- }
- static string GetMd5Hash(MD5 md5Hash, string input)
- {
- // Convert the input string to a byte array and compute the hash.
- byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
- // Create a new Stringbuilder to collect the bytes
- // and create a string.
- StringBuilder sBuilder = new StringBuilder();
- // Loop through each byte of the hashed data
- // and format each one as a hexadecimal string.
- for (int i = 0; i < data.Length; i++)
- {
- sBuilder.Append(data[i].ToString("x2"));
- }
- // Return the hexadecimal string.
- return sBuilder.ToString();
- }
- }
- }
Add Comment
Please, Sign In to add comment