Skip to content

Commit 716f68a

Browse files
committed
Initial Code Commit
0 parents  commit 716f68a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+14554
-0
lines changed

.vs/SkyReader-GUI/v14/.suo

49.5 KB
Binary file not shown.

.vs/SkyReader-GUI/v15/.suo

102 KB
Binary file not shown.

.vs/SkyReader-GUI/v16/.suo

157 KB
Binary file not shown.

SkyReader-GUI.sln

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26430.4
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SkyReader-GUI", "SkyReader-GUI\SkyReader-GUI.vbproj", "{95230997-C373-44C4-8051-359832004472}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F3D20EBD-AD75-4FC5-846D-609D77A4282F}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{95230997-C373-44C4-8051-359832004472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{95230997-C373-44C4-8051-359832004472}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{95230997-C373-44C4-8051-359832004472}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{95230997-C373-44C4-8051-359832004472}.Release|Any CPU.Build.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
EndGlobal

SkyReader-GUI/AES.vb

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
Imports System.Security.Cryptography
2+
Imports System.Text
3+
Imports SkyReader_GUI.frmMain
4+
Public Class AES
5+
'Public Shared HeaderBytes() As Byte = Nothing
6+
'Encryption Notes
7+
'So for 24 block it will be-
8+
'<first 0x20 bytes of sector 0> <24> <0x35-byte constant>
9+
10+
'<first 0x20 bytes of sector 0> <1-byte block index> <0x35-byte constant>
11+
'The First 20 Bytes is 32 Decimal Values
12+
'Why is the Middle Block 24 as Hex?
13+
'The Constant is: 53 Values Decimal
14+
15+
'THEN, MD5 Hash the above bytes.
16+
'Encryption/Decryption Code
17+
18+
'The Following blocks (Offsets) are NOT encrypted
19+
'All Offsets are in Hex and counted as such.
20+
'0x000 Through 0x70
21+
'0x0B0
22+
'0x0F0
23+
'0x130
24+
'0x170
25+
'0x1B0
26+
'0x1F0
27+
'0x230
28+
'0x270
29+
'0x2B0
30+
'0x2F0
31+
'0x330
32+
'0x370
33+
'0x3B0
34+
'0X3F0
35+
36+
Shared HeaderBytes(31) As Byte
37+
Public Shared FullKey(85) As Byte
38+
Shared AES As New RijndaelManaged
39+
Public Shared Magic() As Byte = {&H20, &H43, &H6F, &H70, &H79, &H72, &H69, &H67, &H68, &H74, &H20, &H28, &H43, &H29, &H20, &H32, &H30, &H31, &H30, &H20, &H41, &H63, &H74, &H69, &H76, &H69, &H73, &H69, &H6F, &H6E, &H2E, &H20, &H41, &H6C, &H6C, &H20, &H52, &H69, &H67, &H68, &H74, &H73, &H20, &H52, &H65, &H73, &H65, &H72, &H76, &H65, &H64, &H2E, &H20}
40+
41+
42+
'Get the Header
43+
Shared Sub Header()
44+
AES.Padding = PaddingMode.Zeros
45+
AES.Mode = CipherMode.ECB
46+
47+
Dim Counter As Integer = 0 'Necessary to add one to the Byte array Offset
48+
'Dim HeadByteCounter As Integer = 0
49+
'Go up to 0x21 to get all 32 Bytes of Header
50+
Do Until Counter = 32
51+
HeaderBytes(Counter) = WholeFile(Counter)
52+
'HeadByteCounter += &H1
53+
Counter += 1
54+
Loop
55+
'MessageBox.Show(BitConverter.ToString(HeaderBytes), "Head")
56+
End Sub
57+
58+
'#TODO:
59+
'Get 16 Bytes read in to Byte array for Encryption/Decryption
60+
61+
Shared Sub GetKey(ByVal AreaKey As Byte)
62+
ReDim FullKey(85) 'Reset and don't preserve
63+
HeaderBytes.CopyTo(FullKey, 0)
64+
'MessageBox.Show(BitConverter.ToString(FullKey), "Header into FullKey")
65+
FullKey(32) = AreaKey
66+
'MessageBox.Show(BitConverter.ToString(FullKey), "Header and Area into FullKey")
67+
Magic.CopyTo(FullKey, 33)
68+
69+
'FullKey now has the Correct Data.
70+
End Sub
71+
'Encrypt
72+
Shared Function AESE(ByVal input As Byte(), ByVal key As Byte()) As Byte()
73+
Dim AES As New RijndaelManaged
74+
AES.Padding = PaddingMode.Zeros
75+
AES.Key = CalculateMD5Hash(key)
76+
AES.Mode = CipherMode.ECB
77+
Dim DESEncrypter As ICryptoTransform = AES.CreateEncryptor
78+
Dim Buffer As Byte() = input
79+
Return DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)
80+
End Function
81+
'Decrypt
82+
Shared Function AESD(ByVal input As Byte(), ByVal key As Byte()) As Byte()
83+
Dim AES As New RijndaelManaged
84+
AES.Padding = PaddingMode.Zeros
85+
AES.Key = CalculateMD5Hash(key)
86+
AES.Mode = CipherMode.ECB
87+
Dim DESDecrypter As ICryptoTransform = AES.CreateDecryptor
88+
Dim Buffer As Byte() = input
89+
Return DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)
90+
End Function
91+
92+
'Calculate MD5
93+
Public Shared Function CalculateMD5Hash(ByVal input As Byte()) As Byte()
94+
Dim md5 As MD5 = MD5.Create()
95+
Dim hash As Byte() = md5.ComputeHash(input)
96+
Return hash
97+
End Function
98+
99+
'Return a Hex String from Byte Array.
100+
Public Shared Function ByteArrayToString(ba As Byte()) As String
101+
Dim hex As New StringBuilder(ba.Length * 2)
102+
For Each b As Byte In ba
103+
hex.AppendFormat("{0:x2}", b)
104+
Next
105+
Return hex.ToString()
106+
End Function
107+
108+
'This Generates the Bytes from the Hex String.
109+
Public Shared Function StringToByteArray(s As String) As Byte()
110+
' remove any spaces from, e.g. "A0 20 34 34"
111+
's = s.Replace(" "c, "")
112+
' make sure we have an even number of digits
113+
If (s.Length And 1) = 1 Then
114+
Throw New FormatException("Odd string length when even string length is required.")
115+
End If
116+
117+
' calculate the length of the byte array and dim an array to that
118+
Dim nBytes = s.Length \ 2
119+
Dim a(nBytes - 1) As Byte
120+
121+
' pick out every two bytes and convert them from hex representation
122+
For i = 0 To nBytes - 1
123+
a(i) = Convert.ToByte(s.Substring(i * 2, 2), 16)
124+
Next
125+
126+
Return a
127+
End Function
128+
End Class

SkyReader-GUI/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)