rXoKWm82JSX4UYihkt2FSjrp3pZqTxt6AyJ0ZexHssStYesCFuUOmDBrk0nxPTY2r7oB4ZC9tDhHzmA66Me56wkD47Z3fCEBfLFxmEVdUCvM1RIFdQxQCB7CMaFWXHoVfBhNcD60OtXD71vFusBLioa6HDHbKk8LdgWdV10OWaE=EQ==16GiwrgCGvcYbgSZOBJRx4G9kioGgexLSyW62iK4EuT0Xu9xyflBDaC4yooFkxrflqEAIiEfTqNGlYeJks+5qw==
zfQY4dWi/Dlo38y6xvX4pUEAj1hbeFo/Qiy7H00P089W0KC6Mdi+GY4UuRGJtgX7UZfGQdHRj8mBjijFyhUl4w==
cihlOejyDkaUdnrntEXvD0Svp7vlU9dzJ8iuNz+OoJdUMkKHiQt8yvq8Lv3Gt0p2Xs20xsY9wDhSi2Xfa9diSw==GDrVwDdAWeii7SclCFksT61LXCiDO1XpUxRSP+ryzZ/sGIthMwpwt7ZcynqIrAC0J7eAvHMJmHIPPeat24oEdQ==P4/vgq1XF77N8K/OxTbcjWFCC1d+v3W5xWQJbmU3KfVF2wOStZeILT2X12s7AHD+uUfN9O/xdEBIeqcSLVxWjw==o0WvZCxvMgWeatrybBvIvlWQ0X6CLFYYe2u42GXpILkbp3PFuzHvnkuwip/yG35RllS2efGjfHE0hgA3cazrNgM6gBDcFa7iznviIiQTySxFuzy3mXpjSQFaGgdvmuUQLgg5qahcdGgT455Fzo5GSu+IyTpD+dNoKy79NLTbvjE=";
42 |
43 | WebClient client = new WebClient();
44 | //Download DataVersion.unity3d.
45 | byte[] dataversion = client.DownloadData(baseurl + dataurl);
46 | string[] key = client.ResponseHeaders.AllKeys;
47 | //Check Last-Modified time.
48 | for (int i = 0; i < key.Length; i++)
49 | {
50 | if (key[i] == "Last-Modified")
51 | {
52 | time = DateTime.Parse(client.ResponseHeaders.Get(i));
53 | }
54 | }
55 |
56 | if (DateTime.Compare(oldtime, time) >= 0)
57 | {
58 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] No update");
59 | return false;
60 | }
61 |
62 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] Start update");
63 |
64 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] edit dataversion.unity3d");
65 |
66 | //Decrypt DataVersion.unity3d
67 | for (int i = 0; i < dataversion.Length; i++) dataversion[i] = (byte)(dataversion[i] ^ 0xA5);
68 | //load bundle asset
69 | BundleFile dataversionBundle = new BundleFile(dataversion);
70 | SerializedFile dataversionFile = new SerializedFile("dataversion", new EndianBinaryReader(dataversionBundle.fileList[0].stream));
71 | //get textasset bytes
72 | long Pid = dataversionFile.GetPathIDByName("packageversion.txt");
73 | var packageversion = dataversionFile.m_Objects.Find(x => x.m_PathID == Pid);
74 | //load textasset
75 | Textasset textasset = new Textasset(packageversion.data);
76 |
77 | string[] versiontext = textasset.text.Split('\n');
78 | //Get AES key IV and HMACSHA1 key
79 | var rsa = RSA.Create();
80 | rsa.FromXmlStringA(RSAkey);
81 | byte[] AES_SHA = rsa.Decrypt(Hex2bytes(versiontext[0]), RSAEncryptionPadding.Pkcs1);
82 | //AES_SHA 56 bytes, AES key 32 bytes|AES IV 16 bytes|HMACSHA1 8 bytes
83 | byte[] AESkey = AES_SHA.Take(32).ToArray();
84 | byte[] AESIV = AES_SHA.Skip(32).Take(16).ToArray();
85 | byte[] SHA = AES_SHA.Skip(48).Take(8).ToArray();
86 |
87 | Regex regexCS = new Regex("(CS\":\")([1-9]\\d*)");
88 | Regex regexCRC = new Regex("(CRC\":\")([0-9A-Z]*)");
89 |
90 | string settingCRC;
91 | string excelCRC;
92 | int settingindex;
93 | int excelindex;
94 | //Get File CRC
95 | if (versiontext[1].Contains("excel_output"))
96 | {
97 | excelindex = 1;
98 | settingindex = 2;
99 | }
100 | else
101 | {
102 | excelindex = 2;
103 | settingindex = 1;
104 | }
105 | excelCRC = regexCRC.Match(versiontext[excelindex]).Groups[2].Value;
106 | settingCRC = regexCRC.Match(versiontext[settingindex]).Groups[2].Value;
107 |
108 |
109 | //Download setting.unity3d and excel_output.unity3d
110 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] download setting");
111 | byte[] settingbytes = client.DownloadData(baseurl + settingurl + settingCRC);
112 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] download excel_output");
113 | byte[] excelbytes = client.DownloadData(baseurl + excelurl + excelCRC);
114 | client.Dispose();
115 |
116 | //Decrypt File
117 | Aes Aes = Aes.Create();
118 | var AES_Encryptor = Aes.CreateEncryptor(AESkey, AESIV);
119 |
120 | var AES_Decryptor = Aes.CreateDecryptor(AESkey, AESIV);
121 | settingbytes = AES_Decryptor.TransformFinalBlock(settingbytes, 0, settingbytes.Length);
122 |
123 | AES_Decryptor = Aes.CreateDecryptor(AESkey, AESIV);
124 | excelbytes = AES_Decryptor.TransformFinalBlock(excelbytes, 0, excelbytes.Length);
125 |
126 | #region Modify setting.unity3d
127 |
128 | Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "[FileUpdate] edit setting");
129 |
130 | BundleFile settingBundle = new BundleFile(settingbytes);
131 | SerializedFile setting = new SerializedFile("setting", new EndianBinaryReader(settingBundle.fileList[0].stream));
132 |
133 | #region Edit miscdata.txt
134 | //Get miscdata.txt from bundle
135 | long miscid = setting.GetPathIDByName("miscdata.txt");
136 | var misc = setting.m_Objects.Find(x => x.m_PathID == miscid);
137 | Textasset miscasset = new Textasset(misc.data);
138 | //Enable All BodyPort Touch
139 | Regex regexMISC = new Regex("(Face|Chest|Private|Arm|Leg)(\" *\t*: )(false)");
140 | miscasset.text = regexMISC.Replace(miscasset.text, "$1$2true");
141 | misc.data = miscasset.GetBytes();
142 | #endregion
143 |
144 | #region Edit uiluadesign_x_x.lua.txt/.bytes
145 | bool isLuac = false;
146 | //version number
147 | long uiluaid = setting.GetPathIDByName("uiluadesign_3_4.lua.txt");
148 | if (uiluaid == -1)
149 | {
150 | isLuac = true;
151 | uiluaid = setting.GetPathIDByName("uiluadesign_3_4.lua.bytes");
152 | }
153 | var uilua = setting.m_Objects.Find(x => x.m_PathID == uiluaid);
154 | Textasset uiluaasset = new Textasset(uilua.data);
155 | List