forked from FuzzySecurity/Sharp-Suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
469bd91
commit 9c2f31f
Showing
10 changed files
with
644 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PickmansModel", "PickmansModel\PickmansModel.csproj", "{19657BE4-51CA-4A85-8AB1-F6666008B1F3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{19657BE4-51CA-4A85-8AB1-F6666008B1F3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{19657BE4-51CA-4A85-8AB1-F6666008B1F3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{19657BE4-51CA-4A85-8AB1-F6666008B1F3}.Debug|Any CPU.ActiveCfg = Release|Any CPU | ||
{19657BE4-51CA-4A85-8AB1-F6666008B1F3}.Debug|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pickman/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pickmans/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{19657BE4-51CA-4A85-8AB1-F6666008B1F3}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>PickmansModel</RootNamespace> | ||
<AssemblyName>PickmansModel</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</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="CommandLine, Version=1.9.3.15, Culture=neutral, PublicKeyToken=null"> | ||
<HintPath>..\packages\CommandLineParser.1.9.3.15\lib\CommandLine.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="hCrypto.cs" /> | ||
<Compile Include="hPickman.cs" /> | ||
<Compile Include="hPipeTransport.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using CommandLine; | ||
|
||
namespace PickmansModel | ||
{ | ||
internal class Program | ||
{ | ||
//Byte[] bEnc = hPickman.toAES("IamThePass!", hPickman.StringToUTF32("Hello, this is a test!")); | ||
//Console.WriteLine("Got --> " + Convert.ToBase64String(bEnc)); | ||
// | ||
//Byte[] bDec = hPickman.fromAES("IamThePass!", bEnc); | ||
//Console.WriteLine("Dec --> " + hPickman.UTF32ToString(bDec)); | ||
|
||
// Args | ||
private class argOptions | ||
{ | ||
[Option("h", "host")] | ||
public String sHost { get; set; } | ||
|
||
[Option("p", "pipe")] | ||
public String sPipe { get; set; } | ||
|
||
[Option("a", "aes")] | ||
public String sAES { get; set; } | ||
|
||
[Option("m", "message")] | ||
public String sMessage { get; set; } | ||
|
||
[Option("s", "server")] | ||
public Boolean bServer { get; set; } | ||
} | ||
|
||
public static void Main(string[] args) | ||
{ | ||
argOptions argOptions = new argOptions(); | ||
if (CommandLineParser.Default.ParseArguments(args, argOptions)) | ||
{ | ||
if (!String.IsNullOrEmpty(argOptions.sPipe) || !String.IsNullOrEmpty(argOptions.sAES) || !String.IsNullOrEmpty(argOptions.sMessage)) | ||
{ | ||
if (argOptions.bServer) | ||
{ | ||
hPipeTransport.initServerPipe(argOptions.sPipe, argOptions.sAES); | ||
} | ||
else | ||
{ | ||
if (!String.IsNullOrEmpty(argOptions.sHost)) | ||
{ | ||
hPipeTransport.initClientPipe(argOptions.sPipe, argOptions.sAES, argOptions.sHost); | ||
} | ||
else | ||
{ | ||
hPipeTransport.initClientPipe(argOptions.sPipe, argOptions.sAES); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("[!] Failed to parse args.."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Reflection; | ||
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("PickmansModel")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("PickmansModel")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[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("19657BE4-51CA-4A85-8AB1-F6666008B1F3")] | ||
|
||
// 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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace PickmansModel | ||
{ | ||
public class hCrypto | ||
{ | ||
public static hPickman.AES_KEY_MAT ComputeSha256KeyMat(String sPass) | ||
{ | ||
hPickman.AES_KEY_MAT oKeyMat = new hPickman.AES_KEY_MAT(); | ||
Encoding enc = Encoding.UTF8; | ||
|
||
SHA256 sha256 = new SHA256CryptoServiceProvider(); | ||
oKeyMat.bKey = sha256.ComputeHash(enc.GetBytes(sPass)); | ||
// Hash sPass reverse | ||
oKeyMat.bIV = sha256.ComputeHash(enc.GetBytes(new String(sPass.Reverse().ToArray()))); | ||
Array.Resize(ref oKeyMat.bIV, 16); | ||
|
||
return oKeyMat; | ||
} | ||
|
||
public static Byte[] toAES(String sPass, Byte[] bMessage) | ||
{ | ||
// Key mat | ||
hPickman.AES_KEY_MAT oKeyMat = ComputeSha256KeyMat(sPass); | ||
|
||
// Encrypt | ||
using (AesManaged aes = new AesManaged()) | ||
{ | ||
aes.Key = oKeyMat.bKey; | ||
aes.IV = oKeyMat.bIV; | ||
|
||
ICryptoTransform enc = aes.CreateEncryptor(aes.Key, aes.IV); | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
using (CryptoStream cs = new CryptoStream(ms, enc, CryptoStreamMode.Write)) | ||
{ | ||
using (BinaryWriter sw = new BinaryWriter(cs)) | ||
{ | ||
sw.Write(bMessage); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static Byte[] toAES(hPickman.ECDH_SHARED_KEY_MAT oKeyMat, Byte[] bMessage) | ||
{ | ||
using (AesManaged aes = new AesManaged()) | ||
{ | ||
aes.Key = oKeyMat.bDerivedKey; | ||
aes.IV = oKeyMat.bIV; | ||
|
||
ICryptoTransform enc = aes.CreateEncryptor(aes.Key, aes.IV); | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
using (CryptoStream cs = new CryptoStream(ms, enc, CryptoStreamMode.Write)) | ||
{ | ||
using (BinaryWriter sw = new BinaryWriter(cs)) | ||
{ | ||
sw.Write(bMessage); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static Byte[] fromAES(String sPass, Byte[] bMessage) | ||
{ | ||
// Key mat | ||
hPickman.AES_KEY_MAT oKeyMat = ComputeSha256KeyMat(sPass); | ||
|
||
// Encrypt | ||
using (Aes aes = Aes.Create()) | ||
{ | ||
aes.Key = oKeyMat.bKey; | ||
aes.IV = oKeyMat.bIV; | ||
|
||
ICryptoTransform dec = aes.CreateDecryptor(aes.Key, aes.IV); | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
using (CryptoStream cs = new CryptoStream(ms, dec, CryptoStreamMode.Write)) | ||
{ | ||
using (BinaryWriter sw = new BinaryWriter(cs)) | ||
{ | ||
sw.Write(bMessage); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static Byte[] fromAES(hPickman.ECDH_SHARED_KEY_MAT oKeyMat, Byte[] bMessage) | ||
{ | ||
using (Aes aes = Aes.Create()) | ||
{ | ||
aes.Key = oKeyMat.bDerivedKey; | ||
aes.IV = oKeyMat.bIV; | ||
|
||
ICryptoTransform dec = aes.CreateDecryptor(aes.Key, aes.IV); | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
using (CryptoStream cs = new CryptoStream(ms, dec, CryptoStreamMode.Write)) | ||
{ | ||
using (BinaryWriter sw = new BinaryWriter(cs)) | ||
{ | ||
sw.Write(bMessage); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static ECDiffieHellmanCng initECDH() | ||
{ | ||
ECDiffieHellmanCng ecdh = new ECDiffieHellmanCng(); | ||
ecdh.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; | ||
ecdh.HashAlgorithm = CngAlgorithm.Sha256; | ||
|
||
return ecdh; | ||
} | ||
|
||
public static hPickman.ECDH_SHARED_KEY_MAT deriveECDH(ECDiffieHellmanCng oECDH, Byte[] bPKey) | ||
{ | ||
hPickman.ECDH_SHARED_KEY_MAT oShared = new hPickman.ECDH_SHARED_KEY_MAT(); | ||
CngKey remoteKey = CngKey.Import(bPKey, CngKeyBlobFormat.EccPublicBlob); | ||
|
||
SHA256 sha256 = new SHA256CryptoServiceProvider(); | ||
oShared.bDerivedKey = oECDH.DeriveKeyMaterial(remoteKey); | ||
oShared.bIV = sha256.ComputeHash(oShared.bDerivedKey); | ||
Array.Resize(ref oShared.bIV, 16); | ||
|
||
return oShared; | ||
} | ||
} | ||
} |
Oops, something went wrong.