Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. /// Basically, C# saves initial value of a variable directly in to the compiled executable
  2. /// This is how we will save our message in C#
  3. /// However, you can't directly use a string to make hidden message or use C# string split function
  4. /// Since they will still compiled as 16bit string. and also, This method only supports 8bit (ASCII) message.
  5. /// To overcome the 16bit string conversion, we will use byte array since they save 8bit value.
  6. /// I don't know if this method will also support 16bit+ message by using string directly, however.
  7. ///
  8. /// This program contains a message and will act as Console-based String to Byte Array in C# that can be used to generate much more message if you want.
  9. ///
  10. /// First, You can use this JavaScript in your browser inspector to convert a string into byte array which you can copy-paste into C# code.
  11. /// eval('['+(("Your String Here").split("").map(it => it.charCodeAt(0)).toString())+']');
  12. /// Beware: eval is dangerous and is conquered by Amingwati :)
  13.  
  14. using System;
  15. using System.Collections;
  16. using System.Text;
  17.  
  18. namespace EasterEgg
  19. {
  20. class Endog
  21. { //Endog - Egg in Javanese
  22.  
  23. // This byte[] contains : "Kulanuwun and Konichiwa, Stupids for who opens an application in Notepad or Hex Editor." - They clearly open the compiled executable in a text editor in order to view this message
  24. // Change this to (whatever you want) but as byte array.
  25. public static byte[] easterEggByteArray = new byte[] { 72, 101, 108, 108, 111, 32, 97, 110, 100, 32, 75, 111, 110, 105, 99, 104, 105, 119, 97, 44, 32, 83, 116, 117, 112, 105, 100, 115, 32, 102, 111, 114, 32, 119, 104, 111, 32, 111, 112, 101, 110, 115, 32, 97, 110, 32, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 32, 105, 110, 32, 78, 111, 116, 101, 112, 97, 100, 32, 111, 114, 32, 72, 101, 120, 32, 69, 100, 105, 116, 111, 114, 46 };
  26.  
  27. // App entry point
  28. public static void Main(string[] args)
  29. {
  30. // Placeholder for argument combination
  31. string argCombined = "";
  32.  
  33. // Loop over the arguments and combine them all into a string
  34. foreach (string arg in args)
  35. {
  36. argCombined = string.Format("{0} {1}", argCombined, arg);
  37. }
  38.  
  39. // Remove white-space in the start and the end of the string
  40. byte[] bytes = Encoding.ASCII.GetBytes(argCombined.Trim());
  41.  
  42. // Convert it to string first before writing the value to console
  43.  
  44. // Placeholder for bytestring combination
  45. string byteString = "";
  46.  
  47. // Loop over the bytes
  48. foreach (byte b in bytes)
  49. {
  50. byteString = byteString + b + ", ";
  51. }
  52.  
  53. // Remove the last ", " , byteString.Length is always (total + 1)
  54. byteString = byteString.Substring(0, byteString.Length - 2);
  55.  
  56. // Write utility name
  57.  
  58. Console.Clear();
  59. Console.WriteLine("Hidden Message Generator v1.0 by EmiyaSyahriel (Your name here, but It's actually mine Awkwokowkowk)");
  60. Console.WriteLine("Copy this line to continue");
  61. Console.WriteLine("");
  62.  
  63. //Actual byte
  64. Console.WriteLine("byte[] hidden_message = new byte[] {"+byteString+"}; ");
  65.  
  66. //let's clear things. A nice habit to clear memory (Have no effect in C# since it was managed by .NET CLR)
  67. byteString = "";
  68. argCombined = "";
  69. bytes = new byte[0];
  70.  
  71. // And let GC to collect every unused memory location (they actually already did before). But who know that some will remain?
  72. GC.Collect();
  73.  
  74. }
  75. }
  76. }
  77.  
  78. /// You can compile this C# file with Visual Studio or with csc.exe (Which come with .NET Framework without installing the full VS)
  79. /// Ignore all of those warning about unused variables.. Since It was actually used but not in the program itself :P
  80. /// :: No, it will not happen since unused static will be marked as not unused :)
  81. ///
  82. /// After the compilation, you can open the executable in your favorite text editor and Ta-Da... "You now a stupid who open app in Notepad" hahaha (Joke)
  83. /// You can also examine the "Hidden Message" in WriteLine will be compiled as "H.i.d.d.e.n. .M.e.s.s.a.g.e(b.l.a.b.l.a.b.l.a)" since string is normally compiled as 16bit (2 byte)
  84. /// If you doubt that this come from comment, No.. Comment will never be put into a compiled executable! (except for a special compiler)
  85. /// Even this line will never came to the compiled executable if you find it.
  86. ///
  87. /// Tested with "csc.exe" of ".NET 3.5" in "Windows 10 Pro 1903"
  88. /// Ngopi rek (N) 2019 - EmiyaSyahriel.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement