· 10 years ago · Sep 15, 2016, 12:38 AM
1
2sqlite file:
3 private string _connectionStringTemplate = "Data Source=C:\Program Files (x86)\KairosPlanet\KairosPlanet.db;Version=3;";
4 private const string SYSTEM_TABLE_NAME = "_systemInfo";
5
6
7saves files to :
8(@"%TEMP%\Kairos\"
9"%localappdata%\kairos"
10c:\_winApp\_disc (70GB , hidden , zeroised & never used)
11
12internal static string GetCreateSystemTableSqlCommand()
13{
14 return string.Format("CREATE TABLE [{0}]([id] [integer] NOT NULL,[Date] [integer] NOT NULL,[Description] [text] NULL);", "_systemInfo");
15}
16
17private DatabaseInitializer()
18{
19 SqlDatabaseInitializer.DbUpdate update = new SqlDatabaseInitializer.DbUpdate(1L) {
20 Comment = "Initial update",
21 Sql = "CREATE TABLE [SessionRecord]([Id][integer] PRIMARY KEY AUTOINCREMENT,[StartInt][integer] NOT NULL,[EndInt][integer] NOT NULL);"
22 };
23 this._u0 = update;
24 SqlDatabaseInitializer.DbUpdate update2 = new SqlDatabaseInitializer.DbUpdate(2L) {
25 Comment = "Initial update 2",
26 Sql = "CREATE TABLE [Module]([Id][integer] PRIMARY KEY,[ProductId][integer] NOT NULL,[State][integer] NOT NULL DEFAULT 0);"
27 };
28 this._u1 = update2;
29}
30
31
32
33 private static bool DeployedModule(ModuleInfo moduleInfo)
34 {
35 try
36 { //DownloadedModules folder
37 string downloadsModuleFolderPath = GetDownloadsModuleFolderPath(moduleInfo);
38 new ZipFile(GetDownloadsModuleFilePath(moduleInfo)).ExtractAll(moduleFolderPath);
39 string sourceFileName = Path.Combine(downloadsModuleFolderPath, GetModuleInfoFileName(moduleInfo));
40 string destFileName = Path.Combine(GetModulesFolderPath(), GetModuleInfoFileName(moduleInfo));
41
42 }
43
44 communication:(needs special user agent , https aes-128 get)
45https://dcs.kairosplanet.com (for example: ("/client/product/"), /client/module/download/?product_id={productId}")
46https://cabinet.kairosplanet.com
47
48public LoginResponce Login(string user, string password)
49{
50 this._api = Map.Get<IClientFactory>().CreateChannel(user, password, ApplicationSettings.ServiceUri, ConfigurationManager.GetUserAgent());
51
52
53
54 public static string GetUserAgent()
55{
56 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Modules\Rent module\RentModule.dll");
57 return (_userAgentCache = string.Format("KairosPlanet/{0} ({1}; .Net Framework {2}) {3}", new object[] { currentAppVersion, GetOsInfo(), GetFrameworkVersion(), (version == null) ? string.Empty : ("RentModule/" + version) }));
58}
59
60
61
62
63
64//there is log file near exe
65KairosPlanet.exe.Inclog
66
67
68 [DataContract]
69 public class ProductAttributes
70 {
71 [DataMember(Name="available")]
72 public string Available { get; set; }
73
74 [DataMember(Name="basicIncome")]
75 public string BasicIncome { get; set; }
76
77 [DataMember(Name="basicIncomePeriod")]
78 public string BasicIncomePeriod { get; set; }
79
80 [DataMember(Name="discSpace")]
81 public int DiscSpace { get; set; }
82
83 [DataMember(Name="investmentPeriod")]
84 public string InvestmentPeriod { get; set; }
85
86 [DataMember(Name="profit")]
87 public string Profit { get; set; }
88
89 [DataMember(Name="start")]
90 public string Start { get; set; }
91
92 [DataMember(Name="timeOnline")]
93 public string TimeOnline { get; set; }
94 }
95}
96
97 [DataContract]
98 public class Man
99 {
100 // Methods
101 public Man();
102
103 // Properties
104 [DataMember(Name="birth_date")]
105 public string BirthDate { get; set; }
106 [DataMember(Name="country")]
107 public string Country { get; set; }
108 [DataMember(Name="created_date")]
109 public string CreatedDate { get; set; }
110 [DataMember(Name="email")]
111 public string Email { get; set; }
112 [DataMember(Name="gender_id")]
113 public int Gender { get; set; }
114 [DataMember(Name="user_id")]
115 public long Id { get; set; }
116 [DataMember(Name="user_name")]
117 public string Name { get; set; }
118 [DataMember(Name="phone_number_main")]
119 public string PhoneNumber { get; set; }
120 [DataMember(Name="user_status_id")]
121 public int UserStatus { get; set; }
122 }
123
124
125
126 private static readonly byte[] _entropy = Encoding.Unicode.GetBytes("WinApp Cryptography Data Salt");
127
128public static string ProtectedUserData(string data)
129{
130 if (string.IsNullOrEmpty(data))
131 {
132 return string.Empty;
133 }
134 return Convert.ToBase64String(ProtectedData.Protect(Encoding.Unicode.GetBytes(data), _entropy, DataProtectionScope.CurrentUser));
135}
136
137
138public bool GetRunAtStartup()
139{
140 RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", false);
141}
142
143
144
145
146
147web service api:
148 public ActivationResponse Activation(ActivationRequest activationRequest);
149 public AppVersionResponse GetAppVersion();
150 public ModuleContentResponse GetModuleContent(long productId);
151 public ModuleInfoResponse GetModuleInfo(long productId);
152 public Product[] GetProducts();
153 public Product[] GetProducts(int limit, int offset);
154 public PurchaseResponse GetPurchases();
155 public StatisticsResponse GetStatistics();
156 public StatisticsResponse GetStatistics(DateTime dateFrom, DateTime dateTo);
157 public UserResponse GetUser();
158
159
160
161module api, ModuleResolver class:
162 public string GetActiveModuleSecureKey();
163 private static bool DeployedModule(ModuleInfo moduleInfo);
164 public bool DownloadModule(ModuleInfo moduleInfo);
165 private static ModuleInfo ReadModuleInfo(string filePath);
166
167public interface IModule
168{
169 [DataMember]
170 public string ModuleId { get; set; }
171 [DataMember]
172 public Dictionary<string, string> Settings { get; set; }
173
174 string GetSecurityKey();
175 InstallModuleUC Install(InvestmentType investmentType, int diskSize, IModuleCallback callback);
176 void SetSecurityKey(string securityKey, long productId, long purchaseId, IModuleCallback callback);
177 void Start(IModuleCallback callback);
178}
179
180
181@"SOFTWARE\KairosPlanet"
182SetValue("AppID", Guid.NewGuid().ToString(), RegistryValueKind.String);
183
184
185
186public static void Analyze()
187{
188 CheckPoint point = Logger.CheckPointStart("System Analyze");
189 try
190 {
191 string cpuID = GetCpuID();
192 string hddID = GetHddID();
193 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "Application ID: " + GetApplicationID());
194 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "Processor ID: " + cpuID);
195 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "HDD ID: " + hddID);
196 string message = string.Format("\n\t\t\t\t\t?????????? ????: {0}\n\t\t\t\t\t???????????? ???????: {1}\n\t\t\t\t\t?????? .Net Framework: {2}", Environment.ProcessorCount, GetOsInfo(), GetFrameworkVersion());
197 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "???????????? ???????", message);
198 string str5 = string.Format("\n\t\t\t\t\t??? ??????: {0}\n\t\t\t\t\t?????: {1}\n\t\t\t\t\t??? ????????????: {2}", Environment.MachineName, Environment.UserDomainName, Environment.UserName);
199 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "???????????? ????????????", str5);
200 Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
201 string str6 = string.Format("\n\t\t\t\t\t?????????? ??????: {0}x{1}\n\t\t\t\t\tDpi X: {2}\n\t\t\t\t\tDpi Y: {3}", new object[] { (SystemParameters.PrimaryScreenWidth / 96.0) * graphics.DpiX, (SystemParameters.PrimaryScreenHeight / 96.0) * graphics.DpiY, graphics.DpiX, graphics.DpiY });
202 Logger.WriteInfo(typeof(ConfigurationManager), "Analyze()", "???????????? ??????", str6);
203 }
204 finally
205 {
206 point.Close();
207 }
208}
209
210
211private void MainAction()
212{
213 lock (_lockObject)
214 {
215 if (this._module != null)
216 {
217 switch (this._module.StateEnum)
218 {
219 case ModuleState.Buy:
220 Product[] products = Map.Get<ISessionManager>().Api.GetProducts();//="/client/product/"
221 serviceVms.Add(new ServiceVM(product, purchase));
222
223 Process.Start(this._product.ProductUrl);//dangerous!!! ? maybe opens browser
224 break;
225
226 case ModuleState.Install:
227 this.InstallModule();//might be dangerous in the future, but currently only downloads rent module dll , that doesn't nothing
228 break;
229
230 case ModuleState.Installed:
231 this.ActivateInstalledModule(true);
232string str = Map.Get<ISessionManager>().Activation(purchase.Id);//_api.Activation(activationRequest).PackageSecureKey;//put="/client/activation/"
233 moduleManager.SetSecurityKey(str, purchase.ProductId, purchase.Id, callback);
234Map.Get<IModuleRepository>().Save(moduleByProductId);
235
236
237 break;
238
239
240
241private static IModuleManager GetInstanceModuleManager(ModuleInfo moduleInfo)
242{
243 try
244 {
245 if (_moduleManagerDictionary.ContainsKey(moduleInfo.Title))
246 {
247 return _moduleManagerDictionary[moduleInfo.Title];
248 }
249 foreach (string str3 in Directory.GetFiles(moduleFolderPath, "*.dll"))
250 {
251 IModuleManager manager = null;
252 Assembly assembly = Assembly.LoadFile(str3);
253 manager = (IModuleManager) Activator.CreateInstance(type);
254
255
256
257
258bool flag = NetworkMonitor._isHttpUsed ? NetworkMonitor.HttpPingServer() : NetworkMonitor.PingServer();
259
260
261 private void UpdateDrives()
262 {
263 try
264 {
265
266 if (!(driveInfo.Name == "A:\\") && driveInfo.IsReady && driveInfo.DriveType == DriveType.Fixed)
267 {
268 DriveInfoVM driveInfoVM = new DriveInfoVM(driveInfo, discSize);
269 string text = driveInfo.Name + "_winApp\\_disc";
270 if (text.StartsWith(driveInfo.Name) && File.Exists(text))
271 {
272 driveInfoVM.AvailableSpaceGb += new FileInfo(text).Length / 1073741824L;
273 Logger.WriteError(this, "File exists", text);
274 }
275 dictionary.Add(driveInfo.AvailableFreeSpace, driveInfoVM);
276 }
277 }
278 }
279
280
281
282using (FileStream fileStream = new FileStream(fileInfo.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
283 {
284 fileStream.SetLength(length);
285 }
286 File.SetAttributes(text2, File.GetAttributes(text2) | FileAttributes.Hidden);
287 RentModuleSettings.SaveInstallSettings(this._callback, text2, this.InvestmentSpaceGb);
288
289
290
291protected override void OnStartup(StartupEventArgs e)
292{
293 try
294 {
295 bool flag;
296 _instanceMutex = new Mutex(true, "KairosPlanet", out flag);//prevents multiple instanced on same pc
297 if (!flag)
298 {
299 SendMessage();//RegisterWindowMessage("KairosPlanetMessage"), Marshal.StringToHGlobalAuto("ShowMainWindow"), Marshal.StringToHGlobalAuto("another message"));
300 base.Shutdown();
301 }
302
303private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
304{
305 uint num = RegisterWindowMessage("KairosPlanetMessage");
306 if (msg == num)
307 {
308 Marshal.PtrToStringAuto(wParam);
309 if (wParam == new IntPtr(_messageCloseAppCode))
310 {
311 this.Exit();
312
313
314private static void StartNetworkMonitorTimer(bool immediatelyTick = false, bool isShortInterval = false)
315{
316 if (_checkServerRecursion)
317 {
318 if (_networkMonitorTimer == null)
319 {
320 _networkMonitorTimer = new Timer(10000.0);
321 _networkMonitorTimer.Elapsed += new ElapsedEventHandler(NetworkMonitor.OnNetworkMonitorTimerTick);
322
323private static void CheckServer()
324{
325 bool flag = _isHttpUsed ? HttpPingServer() : PingServer();