diff options
author | yvesf <yvesf-git@xapek.org> | 2010-10-19 22:49:52 +0200 |
---|---|---|
committer | yvesf <yvesf-git@xapek.org> | 2010-10-19 22:49:52 +0200 |
commit | 1c7344a8ac3652ae41c77b6a0995990eddab4312 (patch) | |
tree | 84fe11d9c25c0cbb35c283778095855eeaa5472c /cs | |
download | arris-1c7344a8ac3652ae41c77b6a0995990eddab4312.tar.gz arris-1c7344a8ac3652ae41c77b6a0995990eddab4312.zip |
first commit; commandline version; working
Diffstat (limited to 'cs')
-rw-r--r-- | cs/arris/.gitignore | 2 | ||||
-rw-r--r-- | cs/arris/arris.sln | 20 | ||||
-rw-r--r-- | cs/arris/arris/AssemblyInfo.cs | 27 | ||||
-rw-r--r-- | cs/arris/arris/Main.cs | 101 | ||||
-rw-r--r-- | cs/arris/arris/arris.csproj | 60 |
5 files changed, 210 insertions, 0 deletions
diff --git a/cs/arris/.gitignore b/cs/arris/.gitignore new file mode 100644 index 0000000..519d212 --- /dev/null +++ b/cs/arris/.gitignore @@ -0,0 +1,2 @@ +*pidb +*/bin/* diff --git a/cs/arris/arris.sln b/cs/arris/arris.sln new file mode 100644 index 0000000..e7b32ec --- /dev/null +++ b/cs/arris/arris.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "arris", "arris\arris.csproj", "{1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}.Debug|x86.ActiveCfg = Debug|x86
+ {1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}.Debug|x86.Build.0 = Debug|x86
+ {1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}.Release|x86.ActiveCfg = Release|x86
+ {1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = arris\arris.csproj
+ EndGlobalSection
+EndGlobal
diff --git a/cs/arris/arris/AssemblyInfo.cs b/cs/arris/arris/AssemblyInfo.cs new file mode 100644 index 0000000..6e672bc --- /dev/null +++ b/cs/arris/arris/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("arris")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/cs/arris/arris/Main.cs b/cs/arris/arris/Main.cs new file mode 100644 index 0000000..a86d5a6 --- /dev/null +++ b/cs/arris/arris/Main.cs @@ -0,0 +1,101 @@ +using System; + +namespace ArrisPassword +{ + class Program + { + static void Main (string[] args) + { + string pw = calculatePasswordOfDay (DateTime.Now); + System.Console.WriteLine (pw); + } + /** + * Arris Password of the Day Algorithm + **/ + public static string calculatePasswordOfDay (DateTime beginDate) + { + string seedeight = "MPSJKMDH"; + string seedten = "MPSJKMDHAI"; + + byte[,] sboxWeekday = new byte[,] { { 15, 15, 0x18, 20, 0x18 }, { 13, 14, 0x1b, 0x20, 10 }, { 0x1d, 14, 0x20, 0x1d, 0x18 }, { 0x17, 0x20, 0x18, 0x1d, 0x1d }, { 14, 0x1d, 10, 0x15, 0x1d }, { 0x22, 0x1b, 0x10, 0x17, 30 }, { 14, 0x16, 0x18, 0x11, 13 } }; + byte[,] sbox2 = new byte[,] { { 0, 1, 2, 9, 3, 4, 5, 6, 7, 8 }, { 1, 4, 3, 9, 0, 7, 8, 2, 5, 6 }, { 7, 2, 8, 9, 4, 1, 6, 0, 3, 5 }, { 6, 3, 5, 9, 1, 8, 2, 7, 4, 0 }, { 4, 7, 0, 9, 5, 2, 3, 1, 8, 6 }, { 5, 6, 1, 9, 8, 0, 4, 3, 2, 7 } }; + char[] sboxResult = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z' }; + + byte[] bufferWeekday = new byte[8]; + byte[] bufferSeedEight = new byte[8]; + byte[] buffer = new byte[10]; + byte[] buffer6 = new byte[10]; + byte[] bufferResult = new byte[10]; + + + int year = beginDate.Year % 1000; + int month = beginDate.Month; + int day = beginDate.Day; + int weekday = ((int)beginDate.DayOfWeek) - 1; + + bufferWeekday[0] = sboxWeekday[weekday, 0]; + bufferWeekday[1] = sboxWeekday[weekday, 1]; + bufferWeekday[2] = sboxWeekday[weekday, 2]; + bufferWeekday[3] = sboxWeekday[weekday, 3]; + bufferWeekday[4] = sboxWeekday[weekday, 4]; + bufferWeekday[5] = (byte)day; + if (((year + month) - day) < 0) { + bufferWeekday[6] = (byte)((((year + month) - day) + 0x24) % 0x24); + } else { + bufferWeekday[6] = (byte)(((year + month) - day) % 0x24); + } + bufferWeekday[7] = (byte)((((3 + ((year + month) % 12)) * day) % 0x25) % 0x24); + + + bufferSeedEight[0] = (byte)(seedeight[0] % 0x24); + bufferSeedEight[1] = (byte)(seedeight[1] % 0x24); + bufferSeedEight[2] = (byte)(seedeight[2] % 0x24); + bufferSeedEight[3] = (byte)(seedeight[3] % 0x24); + bufferSeedEight[4] = (byte)(seedeight[4] % 0x24); + bufferSeedEight[5] = (byte)(seedeight[5] % 0x24); + bufferSeedEight[6] = (byte)(seedeight[6] % 0x24); + bufferSeedEight[7] = (byte)(seedeight[7] % 0x24); + + buffer[0] = (byte)(((byte)(bufferWeekday[0] + bufferSeedEight[0])) % 0x24); + buffer[1] = (byte)(((byte)(bufferWeekday[1] + bufferSeedEight[1])) % 0x24); + buffer[2] = (byte)(((byte)(bufferWeekday[2] + bufferSeedEight[2])) % 0x24); + buffer[3] = (byte)(((byte)(bufferWeekday[3] + bufferSeedEight[3])) % 0x24); + buffer[4] = (byte)(((byte)(bufferWeekday[4] + bufferSeedEight[4])) % 0x24); + buffer[5] = (byte)(((byte)(bufferWeekday[5] + bufferSeedEight[5])) % 0x24); + buffer[6] = (byte)(((byte)(bufferWeekday[6] + bufferSeedEight[6])) % 0x24); + buffer[7] = (byte)(((byte)(bufferWeekday[7] + bufferSeedEight[7])) % 0x24); + buffer[8] = (byte)(((byte)(((byte)(((byte)(((byte)(((byte)(((byte)(((byte)(buffer[0] + buffer[1])) + buffer[2])) + buffer[3])) + buffer[4])) + buffer[5])) + buffer[6])) + buffer[7])) % 0x24); + byte num8 = (byte)(buffer[8] % 6); + buffer[9] = (byte)Math.Round (Math.Pow ((double)num8, 2.0)); + + buffer6[0] = buffer[sbox2[num8, 0]]; + buffer6[1] = buffer[sbox2[num8, 1]]; + buffer6[2] = buffer[sbox2[num8, 2]]; + buffer6[3] = buffer[sbox2[num8, 3]]; + buffer6[4] = buffer[sbox2[num8, 4]]; + buffer6[5] = buffer[sbox2[num8, 5]]; + buffer6[6] = buffer[sbox2[num8, 6]]; + buffer6[7] = buffer[sbox2[num8, 7]]; + buffer6[8] = buffer[sbox2[num8, 8]]; + buffer6[9] = buffer[sbox2[num8, 9]]; + + bufferResult[0] = (byte)((seedten[0] + buffer6[0]) % 0x24); + bufferResult[1] = (byte)((seedten[1] + buffer6[1]) % 0x24); + bufferResult[2] = (byte)((seedten[2] + buffer6[2]) % 0x24); + bufferResult[3] = (byte)((seedten[3] + buffer6[3]) % 0x24); + bufferResult[4] = (byte)((seedten[4] + buffer6[4]) % 0x24); + bufferResult[5] = (byte)((seedten[5] + buffer6[5]) % 0x24); + bufferResult[6] = (byte)((seedten[6] + buffer6[6]) % 0x24); + bufferResult[7] = (byte)((seedten[7] + buffer6[7]) % 0x24); + bufferResult[8] = (byte)((seedten[8] + buffer6[8]) % 0x24); + bufferResult[9] = (byte)((seedten[9] + buffer6[9]) % 0x24); + + string strOut = ""; + Array.ForEach<byte> (bufferResult, elem => strOut += (char)sboxResult[elem]); + return strOut; + } + } +} diff --git a/cs/arris/arris/arris.csproj b/cs/arris/arris/arris.csproj new file mode 100644 index 0000000..5766bb2 --- /dev/null +++ b/cs/arris/arris/arris.csproj @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{1D3AF72F-01D4-4B4A-A094-50FAA0F1B0D2}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>arris</RootNamespace> + <AssemblyName>arris</AssemblyName> + <StartupObject>ArrisPassword.Program</StartupObject> + <CodePage>65001</CodePage> + <AssemblyOriginatorKeyFile>..\..\..\Zeichnung.png</AssemblyOriginatorKeyFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>x86</PlatformTarget> + <Externalconsole>true</Externalconsole> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <DebugType>none</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>x86</PlatformTarget> + <Externalconsole>true</Externalconsole> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="Microsoft.VisualBasic" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Main.cs" /> + <Compile Include="AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ProjectExtensions> + <MonoDevelop> + <Properties InternalTargetFrameworkVersion="3.5"> + <MonoDevelop.Autotools.MakefileInfo RelativeMakefileName="Makefile" SyncReferences="true"> + <BuildFilesVar Sync="true" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="true" Name="RESOURCES" /> + <OthersVar /> + <GacRefVar Sync="true" Name="REFERENCES" /> + <AsmRefVar Sync="true" Name="REFERENCES" /> + <ProjectRefVar Sync="true" Name="REFERENCES" /> + </MonoDevelop.Autotools.MakefileInfo> + </Properties> + </MonoDevelop> + </ProjectExtensions> +</Project>
\ No newline at end of file |