Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
JonMagon committed May 23, 2018
1 parent 6c8408d commit 6332a9e
Show file tree
Hide file tree
Showing 32 changed files with 2,024 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Crypt/Crypt.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>{83173BDC-BA4D-497F-9571-AF6E380265FF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Crypt</RootNamespace>
<AssemblyName>Crypt</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EncDec.cs" />
<Compile Include="MD5Hash.cs" />
<Compile Include="MPPC.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RC4.cs" />
</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>
47 changes: 47 additions & 0 deletions Crypt/EncDec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Crypt
{
public class EncDec
{
RC4 enc;
RC4 dec;
MPPC mppc;
public void CreateEnc(byte[] key)
{
enc = new RC4();
enc.Shuffle(key);
mppc = new MPPC();
}
public void CreateDec(byte[] key)
{
dec = new RC4();
dec.Shuffle(key);
}
public byte[] Decode(byte[] allbuf, int len)
{
byte[] buf = new byte[len];
Array.Copy(allbuf, buf, len);
if (dec == null)
return buf;
byte[] ret = new byte[buf.Length];
for (int i = 0; i < ret.Length; i++)
ret[i] = dec.Encode(buf[i]);
return ret;
}
public byte[] Encode(byte[] allbuf)
{
if (enc == null)
return allbuf;

byte[] buf = allbuf;
buf = mppc.Pack(buf);
for (int i = 0; i < buf.Length; i++)
buf[i] = enc.Encode(buf[i]);

return buf;
}
}
}
29 changes: 29 additions & 0 deletions Crypt/MD5Hash.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Crypt
{
public class MD5Hash
{
byte[] Hash = new byte[16];
byte[] Login = new byte[16];
public byte[] GetHash(string Login, byte[] passhash, byte[] key)
{
this.Login = Encoding.ASCII.GetBytes(Login);
byte[] hash = new HMACMD5(passhash).ComputeHash(key);
Hash = hash;
return hash;
}
public byte[] GetKey(byte[] key)
{
byte[] nhash = new byte[key.Length + Hash.Length];
for (int i = 0; i < Hash.Length; i++) nhash[i] = Hash[i];
for (int i = 0; i < key.Length; i++) nhash[i + Hash.Length] = key[i];

byte[] hash = new HMACMD5(Login).ComputeHash(nhash);
return hash;
}
}
}
99 changes: 99 additions & 0 deletions Crypt/MPPC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Crypt
{
public class MPPC
{
public byte[] decHistory = new byte[0xffff];
public int j;
public BitArray srcbinary;

public byte[] Pack(byte[] src)
{
int num3;
BitArray outputbits = new BitArray((src.Length * 9) + 11);
int from = 0;
int num2 = 0;
BitArray array2 = new BitArray(src);
try
{
this.ReOrderBitArray(array2);
}
catch
{
}
while (from < array2.Length)
{
if (array2[from])
{
outputbits[from + num2] = true;
num2++;
outputbits[from + num2] = false;
this.Copy(array2, from + 1, outputbits, (from + num2) + 1, 7);
from += 8;
}
else
{
this.Copy(array2, from, outputbits, from + num2, 8);
from += 8;
}
}
for (num3 = 0; num3 < 4; num3++)
{
outputbits[(from + num2) + num3] = true;
}
from += 4;
for (num3 = 0; num3 < 6; num3++)
{
outputbits[(from + num2) + num3] = false;
}
from += 6;
outputbits.Length = (((from + num2) % 8) == 0) ? (from + num2) : ((from + num2) + (8 - ((from + num2) % 8)));
this.ReOrderBitArray(outputbits);
return this.BitsToBytesCompressor(outputbits, outputbits.Length);
}

private byte[] BitsToBytesCompressor(BitArray target, int lenght)
{
int[] numArray = new int[lenght / 8];
byte[] buffer = new byte[lenght / 8];
for (int i = 0; i < (lenght / 8); i++)
{
for (int j = 7; j >= 0; j--)
{
if (target[(i * 8) + j])
{
numArray[i] += Convert.ToInt32(Math.Pow(Convert.ToDouble(2), Convert.ToDouble(j)));
}
}
buffer[i] = BitConverter.GetBytes(numArray[i])[0];
}
return buffer;
}

private void Copy(BitArray inputbits, int from, BitArray outputbits, int to, int length)
{
for (int i = 0; i < length; i++)
{
outputbits[to + i] = inputbits[from + i];
}
}

public void ReOrderBitArray(BitArray src)
{
for (int i = 0; i < src.Length; i += 8)
{
for (int j = 0; j < 4; j++)
{
bool flag = src[i + j];
src[i + j] = src[i + (7 - j)];
src[i + (7 - j)] = flag;
}
}
}
}
}
36 changes: 36 additions & 0 deletions Crypt/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Управление общими сведениями о сборке осуществляется с помощью
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("Crypt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Crypt")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
// для COM-компонентов. Если требуется обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]

// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("f1884e9b-0030-4243-92b2-5465c1cb9871")]

// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер построения
// Редакция
//
// Можно задать все значения или принять номер построения и номер редакции по умолчанию,
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
50 changes: 50 additions & 0 deletions Crypt/RC4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Text;
using dword = System.Int32;

namespace Crypt
{
public class RC4
{
public RC4()
{
for (dword i = 0; i < 256; i++)
m_Table[i] = Convert.ToByte(i);
m_Shift1 = 0;
m_Shift2 = 0;
}

public void Shuffle(byte[] Key)
{
byte Shift = 0;
for (dword i = 0; i < 256; i++)
{
byte A = Key[i % 16];
Shift += (byte)(A + m_Table[i]);

byte B = m_Table[i];
m_Table[i] = m_Table[Shift];
m_Table[Shift] = B;
}
}

public byte Encode(byte InPacket)
{
m_Shift1++;
byte A = m_Table[m_Shift1];
m_Shift2 += A;
byte B = m_Table[m_Shift2];
m_Table[m_Shift2] = A;
m_Table[m_Shift1] = B;
byte C = (byte)(A + B);
byte D = m_Table[C];
return (byte)(InPacket ^ D);
}

private byte m_Shift1;
private byte m_Shift2;
private byte[] m_Table = new byte[256];
}
}
//*/
Binary file added Libraries/LuaInterface.dll
Binary file not shown.
Binary file added Libraries/NetSockets.dll
Binary file not shown.
Binary file added Libraries/lua51.dll
Binary file not shown.
26 changes: 26 additions & 0 deletions PWLuaOOG.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PWLuaOOG", "PWLuaOOG\PWLuaOOG.csproj", "{B15D05E3-46D0-4A7E-ACFC-DBEB1C5434CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crypt", "Crypt\Crypt.csproj", "{83173BDC-BA4D-497F-9571-AF6E380265FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B15D05E3-46D0-4A7E-ACFC-DBEB1C5434CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B15D05E3-46D0-4A7E-ACFC-DBEB1C5434CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B15D05E3-46D0-4A7E-ACFC-DBEB1C5434CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B15D05E3-46D0-4A7E-ACFC-DBEB1C5434CB}.Release|Any CPU.Build.0 = Release|Any CPU
{83173BDC-BA4D-497F-9571-AF6E380265FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83173BDC-BA4D-497F-9571-AF6E380265FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83173BDC-BA4D-497F-9571-AF6E380265FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83173BDC-BA4D-497F-9571-AF6E380265FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions PWLuaOOG/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Loading

0 comments on commit 6332a9e

Please sign in to comment.