From 7e2a8dbd051b94115672cf22cc66ef09ba8376ca Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 17 Mar 2018 15:30:15 +0100 Subject: .NET Core is cool! --- PassCrackerClient/.gitattributes | 63 ----- PassCrackerClient/.gitignore | 261 --------------------- PassCrackerClient/PassCrackerClient.sln | 25 -- PassCrackerClient/PassCrackerClient/App.config | 6 - PassCrackerClient/PassCrackerClient/Cracking.cs | 164 ------------- .../PassCrackerClient/Models/UserInfo.cs | 38 --- .../PassCrackerClient/Models/UserInfoClearText.cs | 32 --- .../PassCrackerClient/PassCrackerClient.csproj | 57 ----- PassCrackerClient/PassCrackerClient/Program.cs | 116 --------- .../PassCrackerClient/Properties/AssemblyInfo.cs | 36 --- .../Utilities/PasswordFileHandler.cs | 80 ------- .../PassCrackerClient/Utilities/StringUtilities.cs | 42 ---- 12 files changed, 920 deletions(-) delete mode 100755 PassCrackerClient/.gitattributes delete mode 100755 PassCrackerClient/.gitignore delete mode 100755 PassCrackerClient/PassCrackerClient.sln delete mode 100755 PassCrackerClient/PassCrackerClient/App.config delete mode 100755 PassCrackerClient/PassCrackerClient/Cracking.cs delete mode 100755 PassCrackerClient/PassCrackerClient/Models/UserInfo.cs delete mode 100755 PassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs delete mode 100755 PassCrackerClient/PassCrackerClient/PassCrackerClient.csproj delete mode 100755 PassCrackerClient/PassCrackerClient/Program.cs delete mode 100755 PassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs delete mode 100755 PassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs delete mode 100755 PassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs (limited to 'PassCrackerClient') diff --git a/PassCrackerClient/.gitattributes b/PassCrackerClient/.gitattributes deleted file mode 100755 index 1ff0c42..0000000 --- a/PassCrackerClient/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/PassCrackerClient/.gitignore b/PassCrackerClient/.gitignore deleted file mode 100755 index 3c4efe2..0000000 --- a/PassCrackerClient/.gitignore +++ /dev/null @@ -1,261 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -project.fragment.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -#*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc \ No newline at end of file diff --git a/PassCrackerClient/PassCrackerClient.sln b/PassCrackerClient/PassCrackerClient.sln deleted file mode 100755 index 77d20b4..0000000 --- a/PassCrackerClient/PassCrackerClient.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PassCrackerClient", "PassCrackerClient\PassCrackerClient.csproj", "{7BC51616-6005-4C56-8AFC-71D495B9926B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7BC51616-6005-4C56-8AFC-71D495B9926B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BC51616-6005-4C56-8AFC-71D495B9926B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BC51616-6005-4C56-8AFC-71D495B9926B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BC51616-6005-4C56-8AFC-71D495B9926B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1EED0474-D173-418C-9DC7-46790D8DEEBE} - EndGlobalSection -EndGlobal diff --git a/PassCrackerClient/PassCrackerClient/App.config b/PassCrackerClient/PassCrackerClient/App.config deleted file mode 100755 index 731f6de..0000000 --- a/PassCrackerClient/PassCrackerClient/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/PassCrackerClient/PassCrackerClient/Cracking.cs b/PassCrackerClient/PassCrackerClient/Cracking.cs deleted file mode 100755 index dac44a7..0000000 --- a/PassCrackerClient/PassCrackerClient/Cracking.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System.Diagnostics; -using PassCrackerClient.Models; -using PassCrackerClient.Utilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; - -namespace PassCrackerClient -{ - public class Cracking - { - /// - /// The algorithm used for encryption. - /// Must be exactly the same algorithm that was used to encrypt the passwords in the password file - /// - private readonly HashAlgorithm _messageDigest; - - public Cracking() - { - _messageDigest = new SHA1CryptoServiceProvider(); - //_messageDigest = new MD5CryptoServiceProvider(); - // seems to be same speed - } - - /// - /// Runs the password cracking algorithm - /// - public List RunCracking(string [] dictionary) - { - Stopwatch stopwatch = Stopwatch.StartNew(); - - List userInfos = - PasswordFileHandler.ReadPasswordFile("passwords.txt"); - Console.WriteLine("passwd opeend"); - - List result = new List(); - - for(int i = 0; i < dictionary.Length; i++) - { - String dictionaryEntry = dictionary[i]; - IEnumerable partialResult = CheckWordWithVariations(dictionaryEntry, userInfos); - result.AddRange(partialResult); - } - - stopwatch.Stop(); - Console.WriteLine(string.Join(", ", result)); - Console.WriteLine("Out of {0} password {1} was found ", userInfos.Count, result.Count); - Console.WriteLine(); - Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed); - - return result; - } - - /// - /// Generates a lot of variations, encrypts each of the and compares it to all entries in the password file - /// - /// A single word from the dictionary - /// List of (username, encrypted password) pairs from the password file - /// A list of (username, readable password) pairs. The list might be empty - private IEnumerable CheckWordWithVariations(String dictionaryEntry, List userInfos) - { - List result = new List(); //might be empty - - String possiblePassword = dictionaryEntry; - IEnumerable partialResult = CheckSingleWord(userInfos, possiblePassword); - result.AddRange(partialResult); - - String possiblePasswordUpperCase = dictionaryEntry.ToUpper(); - IEnumerable partialResultUpperCase = CheckSingleWord(userInfos, possiblePasswordUpperCase); - result.AddRange(partialResultUpperCase); - - String possiblePasswordCapitalized = StringUtilities.Capitalize(dictionaryEntry); - IEnumerable partialResultCapitalized = CheckSingleWord(userInfos, possiblePasswordCapitalized); - result.AddRange(partialResultCapitalized); - - String possiblePasswordReverse = StringUtilities.Reverse(dictionaryEntry); - IEnumerable partialResultReverse = CheckSingleWord(userInfos, possiblePasswordReverse); - result.AddRange(partialResultReverse); - - for (int i = 0; i < 100; i++) - { - String possiblePasswordEndDigit = dictionaryEntry + i; - IEnumerable partialResultEndDigit = CheckSingleWord(userInfos, possiblePasswordEndDigit); - result.AddRange(partialResultEndDigit); - } - - for (int i = 0; i < 100; i++) - { - String possiblePasswordStartDigit = i + dictionaryEntry; - IEnumerable partialResultStartDigit = CheckSingleWord(userInfos, possiblePasswordStartDigit); - result.AddRange(partialResultStartDigit); - } - - for (int i = 0; i < 10; i++) - { - for (int j = 0; j < 10; j++) - { - String possiblePasswordStartEndDigit = i + dictionaryEntry + j; - IEnumerable partialResultStartEndDigit = CheckSingleWord(userInfos, possiblePasswordStartEndDigit); - result.AddRange(partialResultStartEndDigit); - } - } - - return result; - } - - /// - /// Checks a single word (or rather a variation of a word): Encrypts and compares to all entries in the password file - /// - /// - /// List of (username, encrypted password) pairs from the password file - /// A list of (username, readable password) pairs. The list might be empty - private IEnumerable CheckSingleWord(IEnumerable userInfos, String possiblePassword) - { - char[] charArray = possiblePassword.ToCharArray(); - byte[] passwordAsBytes = Array.ConvertAll(charArray, PasswordFileHandler.GetConverter()); - - byte[] encryptedPassword = _messageDigest.ComputeHash(passwordAsBytes); - //string encryptedPasswordBase64 = System.Convert.ToBase64String(encryptedPassword); - - List results = new List(); - - foreach (UserInfo userInfo in userInfos) - { - if (CompareBytes(userInfo.EntryptedPassword, encryptedPassword)) //compares byte arrays - { - results.Add(new UserInfoClearText(userInfo.Username, possiblePassword)); - Console.WriteLine(userInfo.Username + " " + possiblePassword); - } - } - return results; - } - - /// - /// Compares to byte arrays. Encrypted words are byte arrays - /// - /// - /// - /// - private static bool CompareBytes(IList firstArray, IList secondArray) - { - //if (secondArray == null) - //{ - // throw new ArgumentNullException("firstArray"); - //} - //if (secondArray == null) - //{ - // throw new ArgumentNullException("secondArray"); - //} - if (firstArray.Count != secondArray.Count) - { - return false; - } - for (int i = 0; i < firstArray.Count; i++) - { - if (firstArray[i] != secondArray[i]) - return false; - } - return true; - } - - } -} diff --git a/PassCrackerClient/PassCrackerClient/Models/UserInfo.cs b/PassCrackerClient/PassCrackerClient/Models/UserInfo.cs deleted file mode 100755 index e83c14c..0000000 --- a/PassCrackerClient/PassCrackerClient/Models/UserInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; - -namespace PassCrackerClient.Models -{ - /// - /// username + encrypted password. - /// In the password file we store username + encrypted password. - /// The encrypted password is a byte array (cannot be written to the password file) - /// This must be Base64 encoded (converted to a string) before written to the file - /// - [Serializable] - class UserInfo - { - public String Username { get; set; } - public String EntryptedPasswordBase64 { get; set; } - public byte[] EntryptedPassword { get; set; } - - public UserInfo(String username, String entryptedPasswordBase64) - { - if (username == null) - { - throw new ArgumentNullException("username"); - } - if (entryptedPasswordBase64 == null) - { - throw new ArgumentNullException("entryptedPasswordBase64"); - } - Username = username; - EntryptedPasswordBase64 = entryptedPasswordBase64; - EntryptedPassword = Convert.FromBase64String(entryptedPasswordBase64); - } - - public override string ToString() - { - return Username + ":" + EntryptedPasswordBase64; - } - } -} diff --git a/PassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs b/PassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs deleted file mode 100755 index c4642fa..0000000 --- a/PassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace PassCrackerClient.Models -{ - /// - /// Username + password in clear text (that is human readable) - /// - public class UserInfoClearText - { - public String UserName { get; set; } - public String Password { get; set; } - - public UserInfoClearText(string username, string password) - { - if (username == null) - { - throw new ArgumentNullException("username"); - } - if (password == null) - { - throw new ArgumentNullException("password"); - } - UserName = username; - Password = password; - } - - public override string ToString() - { - return UserName + ": " + Password; - } - } -} diff --git a/PassCrackerClient/PassCrackerClient/PassCrackerClient.csproj b/PassCrackerClient/PassCrackerClient/PassCrackerClient.csproj deleted file mode 100755 index 96d0a6c..0000000 --- a/PassCrackerClient/PassCrackerClient/PassCrackerClient.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - - Debug - AnyCPU - {7BC51616-6005-4C56-8AFC-71D495B9926B} - Exe - PassCrackerClient - PassCrackerClient - v4.6.1 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/PassCrackerClient/PassCrackerClient/Program.cs b/PassCrackerClient/PassCrackerClient/Program.cs deleted file mode 100755 index 45f0309..0000000 --- a/PassCrackerClient/PassCrackerClient/Program.cs +++ /dev/null @@ -1,116 +0,0 @@ -using PassCrackerClient.Models; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Sockets; - -namespace PassCrackerClient -{ - class Program - { - const int NumberOfTasks = 5; - - private static StreamReader sr; - private static StreamWriter sw; - - static void Main(string[] args) - { - Console.Write("Connecting to server... "); - TcpClient clientSocket = new TcpClient("127.0.0.1", 6789); - NetworkStream ns = clientSocket.GetStream(); - Console.Write("OK\n"); - sr = new StreamReader(ns); - sw = new StreamWriter(ns); - sw.AutoFlush = true; - - Console.Write("Getting data from the server... "); - string data = GetData(); - if (data != "") Console.Write("OK\n"); - - Console.Write("Parsing data... "); - string dictionary = ParseData(data); - if (dictionary != "") Console.Write("OK\n"); - - Console.Write("Splitting dictionary... "); - string[,] splitDictionary = SplitDictionary(dictionary); - if (splitDictionary[0,0] != "") Console.Write("OK\n"); - - List result = new List(); - for(int i = 0; i < NumberOfTasks; i++) - { - Console.Write("Running task no." + (i + 1) + "...\n" ); - int rowLength = splitDictionary.GetLength(1); - string[] chunk = new string[rowLength]; - for (int j = 0; j < rowLength; j++) - chunk[j] = splitDictionary[i, j]; - result = DecryptPassword(chunk); - } - if (result.Count != 0) - { - sw.WriteLine(result[0].ToString()); - } - else - { - sw.WriteLine("Nothing Found!"); - } - } - - private static string GetData() - { - string data = ""; - - while (true) - { - string message = sr.ReadLine(); - if (message != "") data += message + "\n"; - else break; - } - - return data; - } - - private static string ParseData(string data) - { - var splitData = data.Split('\n'); - - if (splitData[0] == "DPCP 1.0") - { - splitData[1] = splitData[1].Replace('|', '\n'); - File.WriteAllText("passwords.txt", splitData[1]); - File.WriteAllText("dictionary.txt", splitData[2]); - } - - return splitData[2]; - } - - private static string[,] SplitDictionary(string dictionary) - { - string[] dicWords = dictionary.Split('|'); - int dicWordsLength = dicWords.Length; - string[,] splitDictionary = new string[NumberOfTasks,dicWordsLength/NumberOfTasks]; - int offset = 0; - int j = 0; - - for (int i = 0; i < NumberOfTasks; i++) - { - while (j < dicWordsLength/NumberOfTasks) - { - splitDictionary[i, j] = dicWords[j + offset]; - j++; - } - offset += dicWordsLength/NumberOfTasks; - j = 0; - } - - return splitDictionary; - } - - private static List DecryptPassword(string[] dictionary) - { - Cracking cracker = new Cracking(); - var result = cracker.RunCracking(dictionary); - - return result; - } - } -} diff --git a/PassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs b/PassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs deleted file mode 100755 index 5e98225..0000000 --- a/PassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("PassCrackerClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PassCrackerClient")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7bc51616-6005-4c56-8afc-71d495b9926b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs b/PassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs deleted file mode 100755 index 9c60ae5..0000000 --- a/PassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using PassCrackerClient.Models; - -namespace PassCrackerClient.Utilities -{ - class PasswordFileHandler - { - private static readonly Converter Converter = CharToByte; - - /// - /// With this method you can make you own password file - /// - /// Name of password file - /// List of usernames - /// List of passwords in clear text - /// if usernames and passwords have different lengths - public static void WritePasswordFile(String filename, String[] usernames, String[] passwords) - { - HashAlgorithm messageDigest = new SHA1CryptoServiceProvider(); - if (usernames.Length != passwords.Length) - { - throw new ArgumentException("usernames and passwords must be same lengths"); - } - using (FileStream fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write)) - using (StreamWriter sw = new StreamWriter(fs)) - { - for (int i = 0; i < usernames.Length; i++) - { - byte[] passwordAsBytes = Array.ConvertAll(passwords[i].ToCharArray(), GetConverter()); - byte[] encryptedPassword = messageDigest.ComputeHash(passwordAsBytes); - String line = usernames[i] + ":" + Convert.ToBase64String(encryptedPassword) + "\n"; - sw.WriteLine(line); - } - } - } - - /// - /// Reads all the username + encrypted password from the password file - /// - /// the name of the password file - /// A list of (username, encrypted password) pairs - public static List ReadPasswordFile(String filename) - { - List result = new List(); - - FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); - using (StreamReader sr = new StreamReader(fs)) - { - - while (!sr.EndOfStream) - { - String line = sr.ReadLine(); - String[] parts = line.Split(":".ToCharArray()); - UserInfo userInfo = new UserInfo(parts[0], parts[1]); - result.Add(userInfo); - } - return result; - } - } - - public static Converter GetConverter() - { - return Converter; - } - - /// - /// Converting a char to a byte can be done in many ways. - /// This is one way ... - /// - /// - /// - private static byte CharToByte(char ch) - { - return Convert.ToByte(ch); - } - } -} \ No newline at end of file diff --git a/PassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs b/PassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs deleted file mode 100755 index bb38bda..0000000 --- a/PassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Linq; -using System.Text; - -namespace PassCrackerClient.Utilities -{ - class StringUtilities - { - public static String Capitalize(String str) - { - if (str == null) - { - throw new ArgumentNullException("str"); - } - if (str.Trim().Length == 0) - { - return str; - } - String firstLetterUppercase = str.Substring(0, 1).ToUpper(); - String theRest = str.Substring(1); - return firstLetterUppercase + theRest; - } - - public static String Reverse(String str) - { - if (str == null) - { - throw new ArgumentNullException("str"); - } - if (str.Trim().Length == 0) - { - return str; - } - StringBuilder reverseString = new StringBuilder(); - for (int i = 0; i < str.Length; i++) - { - reverseString.Append(str.ElementAt(str.Length - 1 - i)); - } - return reverseString.ToString(); - } - } -} -- cgit v1.2.3