Advertisement
Denis14

NamedPipes

Mar 12th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.IO.Pipes;
  4. using System.Runtime.InteropServices;
  5. using System.Threading;
  6. using System.Windows.Forms;
  7.  
  8. namespace IceMemeUI
  9. {
  10. class NamedPipes
  11. {
  12. public static string cmdpipename = "IceCmd";//name of command pipe
  13. public static string luacpipename = "IceLuaC";// name of lua c pipe
  14. public static string luapipename = "MemeLua";//name of lua pipe
  15.  
  16. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  17. [return: MarshalAs(UnmanagedType.Bool)]
  18. private static extern bool WaitNamedPipe(string name, int timeout);
  19. //function to check if the pipe exist
  20. public static bool NamedPipeExist(string pipeName)
  21. {
  22. bool result;
  23. try
  24. {
  25. int timeout = 0;
  26. if (!WaitNamedPipe(Path.GetFullPath(string.Format("\\\\\\\\.\\\\pipe\\\\{0}", pipeName)), timeout))
  27. {
  28. int lastWin32Error = Marshal.GetLastWin32Error();
  29. if (lastWin32Error == 0)
  30. {
  31. result = false;
  32. return result;
  33. }
  34. if (lastWin32Error == 2)
  35. {
  36. result = false;
  37. return result;
  38. }
  39. }
  40. result = true;
  41. }
  42. catch (Exception)
  43. {
  44. result = false;
  45. }
  46. return result;
  47. }
  48. //command pipe function
  49. public static void CommandPipe(string command)
  50. {
  51. if (NamedPipeExist(cmdpipename))
  52. {
  53. new Thread(() =>//lets run this in another thread so if roblox crash the ui/gui don't freeze or something
  54. {
  55. try
  56. {
  57. using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", cmdpipename, PipeDirection.Out))
  58. {
  59. namedPipeClientStream.Connect();
  60. using (StreamWriter streamWriter = new StreamWriter(namedPipeClientStream))
  61. {
  62. streamWriter.Write(command);
  63. streamWriter.Dispose();
  64. }
  65. namedPipeClientStream.Dispose();
  66. }
  67. }
  68. catch (IOException)
  69. {
  70. MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  71. }
  72. catch (Exception ex)
  73. {
  74. MessageBox.Show(ex.Message.ToString());
  75. }
  76. }).Start();
  77. }
  78. else
  79. {
  80. MessageBox.Show("Inject " + Functions.exploitdll + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  81. return;
  82. }
  83. }
  84. //lua c pipe function
  85. public static void LuaCPipe(string script)
  86. {
  87. if (NamedPipeExist(luacpipename))
  88. {
  89. new Thread(() =>//lets run this in another thread so if roblox crash the ui/gui don't freeze or something
  90. {
  91. try
  92. {
  93. using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", luacpipename, PipeDirection.Out))
  94. {
  95. namedPipeClientStream.Connect();
  96. using (StreamWriter streamWriter = new StreamWriter(namedPipeClientStream, System.Text.Encoding.Default, 999999))//changed buffer to max 1mb since default buffer is 1kb
  97. {
  98. streamWriter.Write(script);
  99. streamWriter.Dispose();
  100. }
  101. namedPipeClientStream.Dispose();
  102. }
  103. }
  104. catch (IOException)
  105. {
  106. MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  107. }
  108. catch (Exception ex)
  109. {
  110. MessageBox.Show(ex.Message.ToString());
  111. }
  112. }).Start();
  113. }
  114. else
  115. {
  116. MessageBox.Show("Inject " + Functions.exploitdll + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  117. return;
  118. }
  119. }
  120.  
  121. //lua pipe function
  122. public static void LuaPipe(string script)
  123. {
  124. if (NamedPipeExist(luapipename))
  125. {
  126. new Thread(() =>//lets run this in another thread so if roblox crash the ui/gui don't freeze or something
  127. {
  128. try
  129. {
  130. using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", luapipename, PipeDirection.Out))
  131. {
  132. namedPipeClientStream.Connect();
  133. using (StreamWriter streamWriter = new StreamWriter(namedPipeClientStream, System.Text.Encoding.Default, 999999))//changed buffer to max 1mb since default buffer is 1kb
  134. {
  135. streamWriter.Write(script);
  136. streamWriter.Dispose();
  137. }
  138. namedPipeClientStream.Dispose();
  139. }
  140. }
  141. catch (IOException)
  142. {
  143. MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  144. }
  145. catch (Exception ex)
  146. {
  147. MessageBox.Show(ex.Message.ToString());
  148. }
  149. }).Start();
  150. }
  151. else
  152. {
  153. MessageBox.Show("Inject " + Functions.exploitdll + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  154. return;
  155. }
  156. }
  157. }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement