From f98c71237d2065868bfb29ef44ef43afb9f095e2 Mon Sep 17 00:00:00 2001 From: Greg Edwards Date: Fri, 9 May 2014 16:36:57 -0400 Subject: [PATCH] Added some tests for interpreting Global Terminal data. --- gts/Box Upload Xor Pad.bin | Bin 0 -> 256 bytes gts/gts.csproj | 16 ++++++ gts/test/BoxUp.aspx | 24 +++++++++ gts/test/BoxUp.aspx.cs | 60 +++++++++++++++++++++++ gts/test/BoxUp.aspx.designer.cs | 78 ++++++++++++++++++++++++++++++ gts/test/RngTest.aspx | 10 ++++ gts/test/RngTest.aspx.cs | 63 ++++++++++++++++++++++++ gts/test/RngTest.aspx.designer.cs | 24 +++++++++ 8 files changed, 275 insertions(+) create mode 100644 gts/Box Upload Xor Pad.bin create mode 100644 gts/test/BoxUp.aspx create mode 100644 gts/test/BoxUp.aspx.cs create mode 100644 gts/test/BoxUp.aspx.designer.cs create mode 100644 gts/test/RngTest.aspx create mode 100644 gts/test/RngTest.aspx.cs create mode 100644 gts/test/RngTest.aspx.designer.cs diff --git a/gts/Box Upload Xor Pad.bin b/gts/Box Upload Xor Pad.bin new file mode 100644 index 0000000000000000000000000000000000000000..423563f2ed6fff4745df42582118806bd8dc5ed9 GIT binary patch literal 256 zcmV+b0ssDs!%sy7kbxd+$hnm=?>ypp?cO4;~HZ@Z|(A8pCUt@fJ zQYjKFcmhQ^UY-BypbblP_F;uxyWIO^E_$o+=tK;-kEjZcz2Q6jJf9j?#p3lx+1HHC Gm+*U9sege0 literal 0 HcmV?d00001 diff --git a/gts/gts.csproj b/gts/gts.csproj index 61c79952..79c52976 100644 --- a/gts/gts.csproj +++ b/gts/gts.csproj @@ -57,9 +57,11 @@ + + Web.config @@ -76,6 +78,13 @@ AllPokemon.aspx + + BoxUp.aspx + ASPXCodeBehind + + + BoxUp.aspx + Decode.aspx ASPXCodeBehind @@ -112,6 +121,13 @@ + + RngTest.aspx + ASPXCodeBehind + + + RngTest.aspx + diff --git a/gts/test/BoxUp.aspx b/gts/test/BoxUp.aspx new file mode 100644 index 00000000..21cf6809 --- /dev/null +++ b/gts/test/BoxUp.aspx @@ -0,0 +1,24 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="BoxUp.aspx.cs" Inherits="PkmnFoundations.GTS.debug.BoxUp" %> + + + + + +
+
+

Uplaod your Generation IV box upload, battle video, and dressup capture:

+ +  Pad offset: + + +
+ + +
+
+ +
+
+
+ +
diff --git a/gts/test/BoxUp.aspx.cs b/gts/test/BoxUp.aspx.cs new file mode 100644 index 00000000..43a63065 --- /dev/null +++ b/gts/test/BoxUp.aspx.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Text; +using System.IO; + +namespace PkmnFoundations.GTS.debug +{ + public partial class BoxUp : System.Web.UI.Page + { + protected void Page_Init(object sender, EventArgs e) + { + litMessage.Text = ""; + } + + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void btnSend_Click(object sender, EventArgs e) + { + phDecoded.Visible = false; + byte[] data = fuBox.FileBytes; + FileStream s = File.Open(Server.MapPath("~/Box Upload Xor Pad.bin"), FileMode.Open); + byte[] pad = new byte[s.Length]; + s.Read(pad, 0, pad.Length); + s.Close(); + int padOffset = Convert.ToInt32(txtOffset.Text); + + for (int x = 4; x < data.Length; x++) + { + data[x] ^= pad[(x + padOffset) % 256]; + } + + litDecoded.Text = RenderHex(data.ToHexStringLower()); + phDecoded.Visible = true; + } + + private String RenderHex(String hex) + { + StringBuilder builder = new StringBuilder(); + for (int x = 0; x < hex.Length; x += 16) + { + if (x % 32 == 0) + { + builder.Append((x >> 1).ToString("x4")); + builder.Append(": "); + } + + builder.Append(hex.Substring(x, Math.Min(16, hex.Length - x))); + builder.Append((x % 32 == 0) ? " " : "
"); + } + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/gts/test/BoxUp.aspx.designer.cs b/gts/test/BoxUp.aspx.designer.cs new file mode 100644 index 00000000..3abdc8dd --- /dev/null +++ b/gts/test/BoxUp.aspx.designer.cs @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PkmnFoundations.GTS.debug { + + + public partial class BoxUp { + + /// + /// theForm control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm theForm; + + /// + /// fuBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.FileUpload fuBox; + + /// + /// txtOffset control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtOffset; + + /// + /// btnSend control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSend; + + /// + /// litMessage control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litMessage; + + /// + /// phDecoded control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.PlaceHolder phDecoded; + + /// + /// litDecoded control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litDecoded; + } +} diff --git a/gts/test/RngTest.aspx b/gts/test/RngTest.aspx new file mode 100644 index 00000000..de78ce83 --- /dev/null +++ b/gts/test/RngTest.aspx @@ -0,0 +1,10 @@ +<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeBehind="RngTest.aspx.cs" Inherits="PkmnFoundations.GTS.test.RngTest" %> + + + + + +
+ +
+
diff --git a/gts/test/RngTest.aspx.cs b/gts/test/RngTest.aspx.cs new file mode 100644 index 00000000..99afb39e --- /dev/null +++ b/gts/test/RngTest.aspx.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Text; + +namespace PkmnFoundations.GTS.test +{ + public partial class RngTest : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + int seed = 0; + byte[] data = new byte[512]; + + for (int x = 0; x < data.Length; x++) + { + seed = Rng1(seed); + data[x] = (byte)((seed >> 8) & 0xff); + } + + litRandom.Text = RenderHex(data.ToHexStringLower()); + + } + + + private String RenderHex(String hex) + { + StringBuilder builder = new StringBuilder(); + for (int x = 0; x < hex.Length; x += 16) + { + if (x % 32 == 0) + { + builder.Append((x >> 1).ToString("x4")); + builder.Append(": "); + } + + builder.Append(hex.Substring(x, Math.Min(16, hex.Length - x))); + builder.Append((x % 32 == 0) ? " " : "
"); + } + return builder.ToString(); + } + + protected static int Rng1(int prev) + { + return (prev * 0x45 + 0x1111) & 0x7fffffff; + } + + protected static int Rng2(int prev) + { + return (int)((0x41C64E6Du * (uint)prev) + 0x6073u); + } + + protected static int Rng3(int prev) + { + return (int)((0x6C078965u * (uint)prev) + 0x1); + } + + + } +} \ No newline at end of file diff --git a/gts/test/RngTest.aspx.designer.cs b/gts/test/RngTest.aspx.designer.cs new file mode 100644 index 00000000..902de22f --- /dev/null +++ b/gts/test/RngTest.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PkmnFoundations.GTS.test { + + + public partial class RngTest { + + /// + /// litRandom control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litRandom; + } +}