add cebd_decrypt

This commit is contained in:
Bluzume 2019-09-17 13:19:13 +12:00 committed by GitHub
parent e6f0b2ee72
commit b43f6efcdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 36789 additions and 0 deletions

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.76
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cebd_Decrypt", "Cebd_Decrypt\Cebd_Decrypt.csproj", "{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View File

@ -0,0 +1,59 @@
<?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>{0DCF9DB3-3A88-431B-8D01-64FFA9DF8EA6}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Cebd_Decrypt</RootNamespace>
<AssemblyName>Cebd_Decrypt</AssemblyName>
<TargetFrameworkVersion>v4.5.2</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="BouncyCastle.Crypto, Version=1.8.5.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="DotNetZip, Version=1.13.4.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.4\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<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="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,71 @@
using Ionic.Zlib;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Cebd_Decrypt
{
class Program
{
static int readInt32BE(Stream fs)
{
byte[] int32spc = new byte[4];
fs.Read(int32spc, 0, 4);
int32spc = int32spc.Reverse().ToArray();
return BitConverter.ToInt32(int32spc, 0);
}
static void Main(string[] args)
{
if (args[0] == "-d")
{
FileStream fs = new FileStream(args[1], FileMode.OpenOrCreate, FileAccess.ReadWrite);
int keyLen = readInt32BE(fs);
Console.WriteLine("KeyLen: " + keyLen.ToString());
byte[] key = new byte[keyLen];
fs.Read(key, 0, keyLen);
long Remaining = fs.Length - fs.Position;
Console.WriteLine("Remaining: " + Remaining.ToString());
byte[] data = new byte[Remaining];
byte[] data2 = new byte[Remaining];
fs.Read(data, 0, (int)Remaining);
RC4Engine ARC4 = new RC4Engine();
ARC4.Init(false, new KeyParameter(key));
ARC4.ProcessBytes(data, 0, data.Length, data2, 0);
Byte[] DecompressedData = ZlibStream.UncompressBuffer(data2);
File.WriteAllBytes(args[2], DecompressedData);
}
else if(args[0] == "-e")
{
FileStream fs = new FileStream(args[2], FileMode.OpenOrCreate, FileAccess.ReadWrite);
int keyLen = readInt32BE(fs);
Console.WriteLine("KeyLen: " + keyLen.ToString());
byte[] key = new byte[keyLen];
fs.Read(key, 0, keyLen);
Byte[] PlaintextData = File.ReadAllBytes(args[1]);
Byte[] CompressedData = ZlibStream.CompressBuffer(PlaintextData);
Byte[] EncryptedData = new Byte[CompressedData.Length];
RC4Engine ARC4 = new RC4Engine();
ARC4.Init(false, new KeyParameter(key));
ARC4.ProcessBytes(CompressedData, 0, CompressedData.Length, EncryptedData, 0);
fs.SetLength(fs.Position);
fs.Write(EncryptedData,0,EncryptedData.Length);
fs.Close();
}
}
}
}

View File

@ -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("Cebd_Decrypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cebd_Decrypt")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[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("0dcf9db3-3a88-431b-8d01-64ffa9df8ea6")]
// 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")]

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.5" targetFramework="net452" />
<package id="DotNetZip" version="1.13.4" targetFramework="net452" />
</packages>

View File

@ -0,0 +1,30 @@
# The Bouncy Castle Crypto Package For C Sharp
The Bouncy Castle Crypto package is a C\# implementation of cryptographic algorithms and protocols, it was developed by the Legion of the Bouncy Castle, a registered Australian Charity, with a little help! The Legion, and the latest goings on with this package, can be found at [http://www.bouncycastle.org](http://www.bouncycastle.org). In addition to providing basic cryptography algorithms, the package also provides support for CMS, TSP, X.509 certificate generation and a variety of other standards such as OpenPGP.
The Legion also gratefully acknowledges the contributions made to this package by others (see [here](http://www.bouncycastle.org/csharp/contributors.html) for the current list). If you would like to contribute to our efforts please feel free to get in touch with us or visit our [donations page](https://www.bouncycastle.org/donate), sponsor some specific work, or purchase a support contract through [Crypto Workshop](http://www.cryptoworkshop.com).
Except where otherwise stated, this software is distributed under a license based on the MIT X Consortium license. To view the license, [see here](http://www.bouncycastle.org/licence.html). The OpenPGP library also includes a modified BZIP2 library which is licensed under the [Apache Software License, Version 2.0](http://www.apache.org/licenses/).
**Note**: this source tree is not the FIPS version of the APIs - if you are interested in our FIPS version please contact us directly at [office@bouncycastle.org](mailto:office@bouncycastle.org).
## Mailing Lists
For those who are interested, there are 2 mailing lists for participation in this project. To subscribe use the links below and include the word subscribe in the message body. (To unsubscribe, replace **subscribe** with **unsubscribe** in the message body)
* [announce-crypto-csharp-request@bouncycastle.org](mailto:announce-crypto-csharp-request@bouncycastle.org)
This mailing list is for new release announcements only, general subscribers cannot post to it.
* [dev-crypto-csharp-request@bouncycastle.org](mailto:dev-crypto-csharp-request@bouncycastle.org)
This mailing list is for discussion of development of the package. This includes bugs, comments, requests for enhancements, questions about use or operation.
**NOTE:**You need to be subscribed to send mail to the above mailing list.
## Feedback
If you want to provide feedback directly to the members of **The Legion** then please use [feedback-crypto@bouncycastle.org](mailto:feedback-crypto@bouncycastle.org), if you want to help this project survive please consider [donating](https://www.bouncycastle.org/donate).
For bug reporting/requests you can report issues here on github, via feedback-crypto if required, and we also have a [Jira issue tracker](http://www.bouncycastle.org/jira). We will accept pull requests based on this repository as well.
## Finally
Enjoy!

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff