aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2018-03-13 12:55:07 +0100
committermarcinzelent <zelent.marcin@gmail.com>2018-03-13 12:55:07 +0100
commit42756ffc428100db786e56553f4e2ea4b50ba785 (patch)
treefcbfc93517bdaf78331e6fccc8aba801b926dbab
parent54749b4012cddd9e80f26971dcf45fc352aead26 (diff)
Added client.
-rwxr-xr-xPassCrackerClient/.gitattributes63
-rwxr-xr-xPassCrackerClient/.gitignore261
-rwxr-xr-xPassCrackerClient/PassCrackerClient.sln25
-rwxr-xr-xPassCrackerClient/PassCrackerClient/App.config6
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Cracking.cs164
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Models/UserInfo.cs38
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs32
-rwxr-xr-xPassCrackerClient/PassCrackerClient/PassCrackerClient.csproj57
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Program.cs95
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs36
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs80
-rwxr-xr-xPassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs42
12 files changed, 899 insertions, 0 deletions
diff --git a/PassCrackerClient/.gitattributes b/PassCrackerClient/.gitattributes
new file mode 100755
index 0000000..1ff0c42
--- /dev/null
+++ b/PassCrackerClient/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# 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
new file mode 100755
index 0000000..3c4efe2
--- /dev/null
+++ b/PassCrackerClient/.gitignore
@@ -0,0 +1,261 @@
+## 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
new file mode 100755
index 0000000..77d20b4
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient.sln
@@ -0,0 +1,25 @@
+
+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
new file mode 100755
index 0000000..731f6de
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
+ </startup>
+</configuration> \ No newline at end of file
diff --git a/PassCrackerClient/PassCrackerClient/Cracking.cs b/PassCrackerClient/PassCrackerClient/Cracking.cs
new file mode 100755
index 0000000..dac44a7
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Cracking.cs
@@ -0,0 +1,164 @@
+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
+ {
+ /// <summary>
+ /// The algorithm used for encryption.
+ /// Must be exactly the same algorithm that was used to encrypt the passwords in the password file
+ /// </summary>
+ private readonly HashAlgorithm _messageDigest;
+
+ public Cracking()
+ {
+ _messageDigest = new SHA1CryptoServiceProvider();
+ //_messageDigest = new MD5CryptoServiceProvider();
+ // seems to be same speed
+ }
+
+ /// <summary>
+ /// Runs the password cracking algorithm
+ /// </summary>
+ public List<UserInfoClearText> RunCracking(string [] dictionary)
+ {
+ Stopwatch stopwatch = Stopwatch.StartNew();
+
+ List<UserInfo> userInfos =
+ PasswordFileHandler.ReadPasswordFile("passwords.txt");
+ Console.WriteLine("passwd opeend");
+
+ List<UserInfoClearText> result = new List<UserInfoClearText>();
+
+ for(int i = 0; i < dictionary.Length; i++)
+ {
+ String dictionaryEntry = dictionary[i];
+ IEnumerable<UserInfoClearText> 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;
+ }
+
+ /// <summary>
+ /// Generates a lot of variations, encrypts each of the and compares it to all entries in the password file
+ /// </summary>
+ /// <param name="dictionaryEntry">A single word from the dictionary</param>
+ /// <param name="userInfos">List of (username, encrypted password) pairs from the password file</param>
+ /// <returns>A list of (username, readable password) pairs. The list might be empty</returns>
+ private IEnumerable<UserInfoClearText> CheckWordWithVariations(String dictionaryEntry, List<UserInfo> userInfos)
+ {
+ List<UserInfoClearText> result = new List<UserInfoClearText>(); //might be empty
+
+ String possiblePassword = dictionaryEntry;
+ IEnumerable<UserInfoClearText> partialResult = CheckSingleWord(userInfos, possiblePassword);
+ result.AddRange(partialResult);
+
+ String possiblePasswordUpperCase = dictionaryEntry.ToUpper();
+ IEnumerable<UserInfoClearText> partialResultUpperCase = CheckSingleWord(userInfos, possiblePasswordUpperCase);
+ result.AddRange(partialResultUpperCase);
+
+ String possiblePasswordCapitalized = StringUtilities.Capitalize(dictionaryEntry);
+ IEnumerable<UserInfoClearText> partialResultCapitalized = CheckSingleWord(userInfos, possiblePasswordCapitalized);
+ result.AddRange(partialResultCapitalized);
+
+ String possiblePasswordReverse = StringUtilities.Reverse(dictionaryEntry);
+ IEnumerable<UserInfoClearText> partialResultReverse = CheckSingleWord(userInfos, possiblePasswordReverse);
+ result.AddRange(partialResultReverse);
+
+ for (int i = 0; i < 100; i++)
+ {
+ String possiblePasswordEndDigit = dictionaryEntry + i;
+ IEnumerable<UserInfoClearText> partialResultEndDigit = CheckSingleWord(userInfos, possiblePasswordEndDigit);
+ result.AddRange(partialResultEndDigit);
+ }
+
+ for (int i = 0; i < 100; i++)
+ {
+ String possiblePasswordStartDigit = i + dictionaryEntry;
+ IEnumerable<UserInfoClearText> 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<UserInfoClearText> partialResultStartEndDigit = CheckSingleWord(userInfos, possiblePasswordStartEndDigit);
+ result.AddRange(partialResultStartEndDigit);
+ }
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Checks a single word (or rather a variation of a word): Encrypts and compares to all entries in the password file
+ /// </summary>
+ /// <param name="userInfos"></param>
+ /// <param name="possiblePassword">List of (username, encrypted password) pairs from the password file</param>
+ /// <returns>A list of (username, readable password) pairs. The list might be empty</returns>
+ private IEnumerable<UserInfoClearText> CheckSingleWord(IEnumerable<UserInfo> 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<UserInfoClearText> results = new List<UserInfoClearText>();
+
+ 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;
+ }
+
+ /// <summary>
+ /// Compares to byte arrays. Encrypted words are byte arrays
+ /// </summary>
+ /// <param name="firstArray"></param>
+ /// <param name="secondArray"></param>
+ /// <returns></returns>
+ private static bool CompareBytes(IList<byte> firstArray, IList<byte> 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
new file mode 100755
index 0000000..e83c14c
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Models/UserInfo.cs
@@ -0,0 +1,38 @@
+using System;
+
+namespace PassCrackerClient.Models
+{
+ /// <summary>
+ /// 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
+ /// </summary>
+ [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
new file mode 100755
index 0000000..c4642fa
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Models/UserInfoClearText.cs
@@ -0,0 +1,32 @@
+using System;
+
+namespace PassCrackerClient.Models
+{
+ /// <summary>
+ /// Username + password in clear text (that is human readable)
+ /// </summary>
+ 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
new file mode 100755
index 0000000..96d0a6c
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/PassCrackerClient.csproj
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{7BC51616-6005-4C56-8AFC-71D495B9926B}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>PassCrackerClient</RootNamespace>
+ <AssemblyName>PassCrackerClient</AssemblyName>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Cracking.cs" />
+ <Compile Include="Models\UserInfo.cs" />
+ <Compile Include="Models\UserInfoClearText.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Utilities\PasswordFileHandler.cs" />
+ <Compile Include="Utilities\StringUtilities.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/PassCrackerClient/PassCrackerClient/Program.cs b/PassCrackerClient/PassCrackerClient/Program.cs
new file mode 100755
index 0000000..7bf3859
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Program.cs
@@ -0,0 +1,95 @@
+using PassCrackerClient.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PassCrackerClient
+{
+ class Program
+ {
+ private static StreamReader sr;
+ private static StreamWriter sw;
+ static void Main(string[] args)
+ {
+ TcpClient clientSocket = new TcpClient("192.168.3.163", 6789);
+ NetworkStream ns = clientSocket.GetStream();
+ sr = new StreamReader(ns);
+ sw = new StreamWriter(ns);
+ sw.AutoFlush = true;
+
+ string data = GetData();
+ string dictionary = ParseData(data);
+ string[,] splitDictionary = SplitDictionary(dictionary);
+
+ List<UserInfoClearText> result;
+ for(int i = 0; i < 5; i++)
+ {
+ int rowLength = splitDictionary.GetLength(i);
+ string[] chunk = new string[rowLength];
+ for (int j = 0; j < rowLength; j++)
+ chunk[j] = splitDictionary[i, j];
+ Task.Run(() => result = DecryptPassword(chunk));
+ }
+ }
+
+ private static string GetData()
+ {
+ string data = "";
+
+ while (true)
+ {
+ string message = sr.ReadLine();
+ if (message != "") data += message;
+ else break;
+ }
+
+ return data;
+ }
+
+ private static string ParseData(string data)
+ {
+ var splitData = data.Split('\n');
+
+ if (splitData[0] == "DPCP 1.0")
+ {
+ File.WriteAllText("password.txt", splitData[1]);
+ File.WriteAllText("dictionary.txt", splitData[2]);
+ }
+
+ return splitData[2];
+ }
+
+ private static string[,] SplitDictionary(string dictionary)
+ {
+ string[] dicWords = dictionary.Split('\n');
+ int dicWordsLength = dicWords.Length;
+ string[,] splitDictionary = new string[5,dicWordsLength/5];
+ int offset = 0;
+ int j = 0;
+
+ for(int i = 0; i < 5; i = i++)
+ {
+ while(j < dicWordsLength / 5)
+ {
+ splitDictionary[i,j] = dicWords[j + offset];
+ j++;
+ }
+ offset += dicWordsLength / 5;
+ }
+
+ return splitDictionary;
+ }
+
+ private static List<UserInfoClearText> 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
new file mode 100755
index 0000000..5e98225
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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
new file mode 100755
index 0000000..9c60ae5
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Utilities/PasswordFileHandler.cs
@@ -0,0 +1,80 @@
+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<char, byte> Converter = CharToByte;
+
+ /// <summary>
+ /// With this method you can make you own password file
+ /// </summary>
+ /// <param name="filename">Name of password file</param>
+ /// <param name="usernames">List of usernames</param>
+ /// <param name="passwords">List of passwords in clear text</param>
+ /// <exception cref="ArgumentException">if usernames and passwords have different lengths</exception>
+ 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);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Reads all the username + encrypted password from the password file
+ /// </summary>
+ /// <param name="filename">the name of the password file</param>
+ /// <returns>A list of (username, encrypted password) pairs</returns>
+ public static List<UserInfo> ReadPasswordFile(String filename)
+ {
+ List<UserInfo> result = new List<UserInfo>();
+
+ 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<char, byte> GetConverter()
+ {
+ return Converter;
+ }
+
+ /// <summary>
+ /// Converting a char to a byte can be done in many ways.
+ /// This is one way ...
+ /// </summary>
+ /// <param name="ch"></param>
+ /// <returns></returns>
+ 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
new file mode 100755
index 0000000..bb38bda
--- /dev/null
+++ b/PassCrackerClient/PassCrackerClient/Utilities/StringUtilities.cs
@@ -0,0 +1,42 @@
+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();
+ }
+ }
+}