Skip to content

Commit

Permalink
Miscellaneous changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devsecboy committed Nov 24, 2018
1 parent a552a39 commit b23b262
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 7,734 deletions.
46 changes: 32 additions & 14 deletions MachineKey/AspDotNetWrapper/AspDotNetWrapper/AspDotNetWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,54 @@ static void Main(string[] args)
}
else
{
byte[] protectedData = DefinePurpose.GetProtectedData(strCookieValue);
if (protectedData != null)
if (File.Exists(strKeysFilePath))
{
byte[] clearData = EncryptDecrypt.DecryptData(protectedData, strKeysFilePath, strValidationAlgorithm, strDecryptionAlgorithm);
if (clearData != null)
byte[] protectedData = DefinePurpose.GetProtectedData(strCookieValue);
if (protectedData != null)
{
DataWriter.WritePurposeToFile(strPurpose);
DataWriter.WriteOtherDataToFile(DefinePurpose.enumPurpose, clearData);
byte[] clearData = EncryptDecrypt.DecryptData(protectedData, strKeysFilePath, strValidationAlgorithm, strDecryptionAlgorithm);
if (clearData != null)
{
DataWriter.WritePurposeToFile(strPurpose);
DataWriter.WriteOtherDataToFile(DefinePurpose.enumPurpose, clearData);
}
}
else
{
Console.Write("Failed to get protected data!!");
}
}
else
{
Console.Write("Failed to get protected data!!");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\n\nKey path file {0} not found!!\n", strKeysFilePath);
Console.ResetColor();
}
}
}
else
{
if (strDecryptedTxtFilePath == null)
if (strDecryptDataFilePath == null)
{
Options.GetUsage(false);
}
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nEncryptedData");
Console.WriteLine("-------------");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(EncryptDecrypt.EncryptData());
Console.ResetColor();
if (File.Exists(strDecryptDataFilePath))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nEncryptedData");
Console.WriteLine("-------------");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(EncryptDecrypt.EncryptData(strDecryptDataFilePath));
Console.ResetColor();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("\n\nDecryptedText.txt File not found!!\n");
Console.ResetColor();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ namespace NotSoSecure.AspDotNetWrapper
{
class DataWriter
{
public static string strDecryptedTxtFilePath = AppDomain.CurrentDomain.BaseDirectory + "DecryptedText.txt";

public static void WriteKeysToFile(string strValidationKey, string strDecryptionKey, string strValidationAlgorithm, string strDecryptionAlgorithm, byte [] byteEncryptionIV)
{
if (File.Exists(strDecryptedTxtFilePath))
File.Delete(strDecryptedTxtFilePath);
if (File.Exists(AspDotNetWrapper.strDecryptedTxtFilePath))
File.Delete(AspDotNetWrapper.strDecryptedTxtFilePath);

using (FileStream streamWriter = new FileStream(strDecryptedTxtFilePath, FileMode.OpenOrCreate, FileAccess.Write))
using (FileStream streamWriter = new FileStream(AspDotNetWrapper.strDecryptedTxtFilePath, FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] byteData = Encoding.ASCII.GetBytes(ContantValue.strDecryptionKey + strDecryptionKey);
streamWriter.Write(byteData, 0, byteData.Length);
Expand Down Expand Up @@ -45,7 +43,7 @@ public static void WriteKeysToFile(string strValidationKey, string strDecryption

public static void WritePurposeToFile(string strPurpose)
{
using (FileStream streamWriter = new FileStream(strDecryptedTxtFilePath, FileMode.Append, FileAccess.Write))
using (FileStream streamWriter = new FileStream(AspDotNetWrapper.strDecryptedTxtFilePath, FileMode.Append, FileAccess.Write))
{
byte[] byteData = Encoding.ASCII.GetBytes(ContantValue.strPurpose+strPurpose);
streamWriter.Write(byteData, 0, byteData.Length);
Expand All @@ -57,7 +55,7 @@ public static void WritePurposeToFile(string strPurpose)
public static void WriteOtherDataToFile(EnumPurpose enumPurpose, byte[] byteClearData)
{
byte[] byteData = null;
using (FileStream streamWriter = new FileStream(strDecryptedTxtFilePath, FileMode.Append, FileAccess.Write))
using (FileStream streamWriter = new FileStream(AspDotNetWrapper.strDecryptedTxtFilePath, FileMode.Append, FileAccess.Write))
{
switch (enumPurpose)
{
Expand Down Expand Up @@ -116,7 +114,7 @@ public static void WriteOtherDataToFile(EnumPurpose enumPurpose, byte[] byteClea
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(Encoding.ASCII.GetString(byteClearData));
Console.ResetColor();
Console.WriteLine("\n\nData stored at DecryptedText.txt file!!");
Console.WriteLine("\n\nData stored at {0} file!!", AspDotNetWrapper.strDecryptedTxtFilePath);
}

public static byte[] Compress(byte[] byteDataToCompress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static byte[] DecryptData(byte[] protectedData, string strMachineKeysFile
return clearData;
}

public static string EncryptData()
public static string EncryptData(string strDecryptDataFilePath)
{
ReadObject objData = new ReadObject();
ReadObject objData = new ReadObject(strDecryptDataFilePath);
AspNetCryptoServiceProvider obj = new AspNetCryptoServiceProvider(
objData.ValidationKey,
objData.ValidationAlgo, objData.DecryptionKey, objData.DecryptionAlgo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class ReadObject
public bool IsError { get; set; }
public FormsAuthenticationCookie objFormAuthCookie = new FormsAuthenticationCookie();

public ReadObject()
public ReadObject(string strDecryptDataFilePath)
{
IsError = false;
StreamReader streamReader = new System.IO.StreamReader(DataWriter.strDecryptedTxtFilePath);
StreamReader streamReader = new System.IO.StreamReader(strDecryptDataFilePath);
string line = string.Empty;
while ((line = streamReader.ReadLine()) != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
C2B8DF31AB9624D69428066DFDA1A479542825F3B48865C4E47AF6A026F22D853DEC2B3248DF268599BF89EF78B9E86CA05AC73577E0D5A14C45E0267588850B,B7EFF1C5839A624E3F97D0268917EDE82F408D2ECBFAC817
E45A45B0A79E92527FE1484954DD433D64410A3EA264A9D67D7CFBB9E2FD0D43AB0107F45FE729B91D4DFB86C0295CC1B4612FE058112EBE300B66AA748D5539,8436A6BE6B9811399C1FD5DD3C45459F38DAF8A9323BE03B2545A10DB5482673
A1380E4176D3C4A0E2F57B16B78DB63EBC1E35160FAC68F80F113F6DFD688A0663B64C8580723CE79F57EC4BA6A47B6B5091632C7C49F0F1C09E26C23BDC705E,E3C8E44114BCABA6F87D3A7E1E8D85EB3FC92D0A292AC4E4
EEB4620FA3D04F707D0A03252E224CA7B2F357A7DB8878468EC3A13772CB84821C9EEBEBF1F7D20CB9CE2B35EC49D966241BBBFD789C1C33DC03F303C490D6A4,93921A109057005B2D8F556768518CD4F50073EDBDE89882
DFD06FF3058574D6A2E7B592E33A80EDE007E596EE8A1754CC68ECE5B44EA9A8A7ABC3C53F0EA8BD90B26AE301977609F142578EF3EB1E05A592C92F354E3341,FFEE834B2BB87C08D5CA27C65E0F2512B8EC3F0F3DAE0AFB
69E316D4B7D2359E113C799A4EEC1BF84E39EE4035466672CCB2030F97B39BDCCFAAB1BB72D3A542600EBCCAD6F871CCA2BFD63E4A5473F7222BCC06E0FD79E8,87E640F83B4669A5E18BCFCF4A5F31A15D6F5BF99707B5B128B7546A52F4AAD8
64722756D4742E8C96DE9759550D200686FC7896FF98549838F7BA6F0505E8243884F69B5E29EEBAF515E9366C48B6529EE78B68F1EA97FEFA65A86C651D8310,CA9E37B5CC6CE487C92371FE98F7A72452A3508BF478A983
8C93D311E42C6B86456E38F508EE52EFE9A9C29D735F3C08326653416E3CF9F77CC2A39E777B26521204EA0C3F222321C6A00CCA3BA7E1D304EA80009AE76714,6355CB728619C146F77E3E733C8EAD6A53E37B282E0005F82BE202740CD74330
7DFA065B3426D931C51124D9259DBD2DA1ADC5AB9DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328,0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8
2D5F6129699ECB685F41D36EC45CB3E9205D7239C0966A94A24880E1630DF1B45ABBA4BA6716F5166575057C7970887A40D7987F7B29CED6E0E24870941F4989,58ABF57DA5B0A6C967A317CCA44557F171AC0B6B4F09722149BDB997B7CE8BA6
C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE,8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F
5D5ECD048862186AF47D7B53E64E7A3F015F440CA647C5F0E5EC20E4CD28661FC763AFA1A4991EA5DBBDDB31776B2945D9CF80614548AE9C8CF6CAF092C8E4CA,B8317A18E2E49670FB395EEACFD0B161FC7AB689B2AEA159
9484EC9CAA067BEA0485ABB755FBE9D0EBC1CF099DE62168764FF0DCE537184F0535D5D9AD66DEDC97DC1ABFF7FA540B4DFD82E5BB196B95D15FF81F75AD5328,0CA3EFAF0F7A5E7A62681C0BF656EE0ECE31ACEE3E1023BA3FAD20EA5F199DE8
D44CF7F89CCA6D97D0648415EE68D3ED88C82805119CAA2C2F197906F40ED8FD,83773FB684FA11E55006BDBF1E2DBA9B35726F6A3D324D0C5B8AC0FA69B06871A01D6E0D1A5D2A22E0854CA612FE5C5EC4AECF24,ACD8EBF87C4C8937
891194EEC95A3895658E397FEA04F6187CFAF77151BE89F207D993BB4BA9DE4152BACB05BC4AEB8BBB5FDD950F77881204F59F3F5DBE39FC3EC49119EA7C106D,C955D0B041D3749FB4E150677F827DC1857B909399A5D152
40C295F1C6E7332867DD50EBAD174E3A5EF52212070B15519FAB47C00B9EEFA18F24643EFB59FC10946F75CE2EF2DB2D6437BA23CF55A1E358FA32FB25DFFE74,7E2D92E82700F80C72AA0F6FBE42CCDB76A9A29805355115
F2D27DF0348E9A3EAD6AC66330C31F821394D4CD1A5E139EEE85EA9D9F2A963E55EC87572F699FB834292CC9E37AD56B6B26AA379106CBA5E9AA544C688F3E92,F6D5A5C8DDEC57481610829F58D6C95BDAC5FA21082F3FA9CB5A36DCEAACBEDB
EDB59F017A178C9095805B88666496F8A6E24761256AE27F8F8994B07F5D9BBD2499F9560967849067899CE234D8E4769CF0AEE99474FA7A6F67D4E62E7F5650,8FFD993C85C8464EA7C117CA0CDB37572B60ECA8BABAA76C6BC94994CA115ECE
086BA0EB24E1A622F477B52C19C30A4069A0472CB089F6B80667368450C275CD9F649EC5DB9F8BCCD7B25E286F52852E956B0CD638EAE29E0B6B47F0A8FE6133,00B978835A8B45E0E11422C5F56E626306320DBFFCC6F3121D34AB8D32616E80
Expand Down Expand Up @@ -2021,4 +2005,4 @@ A0BD925B6A50B318ED9FE4E1C6909E46452E6FA7EF74E1BDEFC90C0BB4F01104D3ACA2E0D4564EA1
AF24443887D47B9E80D754AB6CC865BCA90BA82501FC185275013B628E5A9CC9B93EDB4788CC852FB6A76093D466614F8D37E9BA13C14D32D4B95EF2B84C20E1,6F41F07590FB2A960D345EA9268489F97400509CB55AC9F8
6078D34EC9F5A38B39427DFA2546AADAB4C04071242CD4D52CC95FEC29A9E71C224A44B962D1147990E477EB858D6C2C9D265ED4D4A2F00ED5EE27EAE473800D,DD7420D646BA9F72A29823E8AFA1B89C05243D36A27569883C2BBBA46C5289DE
99242238FD3EBB23A4721704AF30E4128510C1F2FFBDC428B52DE52ABFE17FDE54BE4FCA718893F27D17427CECE34543B388E60244F74122BB38783FE313CEEF,AA77748552F60C36E2F8EC47DA0AA384543492FB07604F6C
A40CB5EE4E19A2E1F2C673A366294821BDBBA89F83459EC7EB093438A63F0FDD26DF4F84BC94823CBD7D09F2F8A0982BDD2CB192ECAEF8121ADEE985D51FE7FC,8EF3437C20E016CF5768699D58BA61CA978B54888F1E0853528BB96118E3303D
A40CB5EE4E19A2E1F2C673A366294821BDBBA89F83459EC7EB093438A63F0FDD26DF4F84BC94823CBD7D09F2F8A0982BDD2CB192ECAEF8121ADEE985D51FE7FC,8EF3437C20E016CF5768699D58BA61CA978B54888F1E0853528BB96118E3303D
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ To decrypt .aspnet.applicationcookie

Command:

AspDotNetWrapper.exe --keypath C:\Users\Root\Downloads\AspDotNetWrapper\AspDotNetWrapper\bin\Debug\MachineKeys.txt --cookie 195A989biBjM_NAqqiie5DnHKfcwrNGDuT-Suumqmw6oVyLSsjCFx9Emhf034TDjcuC9mfwNbi6yD-1QlbhcUAgdTOwY0o0sNbg7bJrNyUEf6ZoyYh2QAZHhmxteN_cMQJI7C1WOBEl0ocihUVhKghdxegwRURcYx2h1uMbijX3jsEf59L8Uco_PpfFLN--RtcLTKUvtZd0fH5Sgc1JQmsvTBr7IJ4Ua01I8uyEPYNXZGYvssSzJ8YN6MXioky3WBXv9NGNxDpgTpIPWGetgZ0iOSaTmqPr6sPu4ndesUV4SKsBroIP6Y38rr8LwFCZBKDK5dli4kKwmy9xeM02qshCoLf8ppeOiK2aMLfb9jqkraoss2BflD3hpDdrYHVGH7ryTWQh4HABYDC7OOMgdld3WJ1CUfJ9pmr0qnVFD4Gc --decrypt --purpose=owin.cookie --valalgo=hmacsha512 --decalgo=aes
AspDotNetWrapper.exe --keypath C:\Users\Root\Downloads\AspDotNetWrapper\AspDotNetWrapper\Resource\MachineKeys.txt --cookie 195A989biBjM_NAqqiie5DnHKfcwrNGDuT-Suumqmw6oVyLSsjCFx9Emhf034TDjcuC9mfwNbi6yD-1QlbhcUAgdTOwY0o0sNbg7bJrNyUEf6ZoyYh2QAZHhmxteN_cMQJI7C1WOBEl0ocihUVhKghdxegwRURcYx2h1uMbijX3jsEf59L8Uco_PpfFLN--RtcLTKUvtZd0fH5Sgc1JQmsvTBr7IJ4Ua01I8uyEPYNXZGYvssSzJ8YN6MXioky3WBXv9NGNxDpgTpIPWGetgZ0iOSaTmqPr6sPu4ndesUV4SKsBroIP6Y38rr8LwFCZBKDK5dli4kKwmy9xeM02qshCoLf8ppeOiK2aMLfb9jqkraoss2BflD3hpDdrYHVGH7ryTWQh4HABYDC7OOMgdld3WJ1CUfJ9pmr0qnVFD4Gc --decrypt --purpose=owin.cookie --valalgo=hmacsha512 --decalgo=aes

Explanation of argument
--cookie : value to decrypt using tool
Expand All @@ -17,7 +17,7 @@ To decrypt .aspxauth cookie

command:

AspDotNetWrapper.exe --keypath C:\Users\Root\Downloads\AspDotNetWrapper\AspDotNetWrapper\bin\Debug\MachineKeys.txt --cookie CA387A93AD4214F356ED05C26C1E4D80F0804CD526766778B62D4F9213B87B5369755F95008A34644B9CA6B7646E191958A1AE14DB398AB943D3DB042EDA06EC4B5BEA9E3EB60E9877646AD4A50BE9435A2D3B4B3005836CBBBDA64A5E8738511211AA1F --decrypt --purpose=aspxauth --valalgo=sha1 --decalgo=aes
AspDotNetWrapper.exe --keypath C:\Users\Root\Downloads\AspDotNetWrapper\AspDotNetWrapper\Resource\MachineKeys.txt --cookie CA387A93AD4214F356ED05C26C1E4D80F0804CD526766778B62D4F9213B87B5369755F95008A34644B9CA6B7646E191958A1AE14DB398AB943D3DB042EDA06EC4B5BEA9E3EB60E9877646AD4A50BE9435A2D3B4B3005836CBBBDA64A5E8738511211AA1F --decrypt --purpose=aspxauth --valalgo=sha1 --decalgo=aes

Explanation of command:
--cookie : value to decrypt using tool
Expand Down
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit b23b262

Please sign in to comment.