Advertisement
GustasRBLX

NamedPipes

Aug 27th, 2019
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 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 Cleansploit
  9. {
  10. class NamedPipes
  11. {
  12. public static string luapipename = "Pipe";//Axon name of lua pipe
  13.  
  14. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  15. [return: MarshalAs(UnmanagedType.Bool)]
  16. private static extern bool WaitNamedPipe(string name, int timeout);
  17. //function to check if the pipe exist
  18. public static bool NamedPipeExist(string pipeName)
  19. {
  20. bool result;
  21. try
  22. {
  23. int timeout = 0;
  24. if (!WaitNamedPipe(Path.GetFullPath(string.Format("\\\\\\\\.\\\\pipe\\\\{0}", pipeName)), timeout))
  25. {
  26. int lastWin32Error = Marshal.GetLastWin32Error();
  27. if (lastWin32Error == 0)
  28. {
  29. result = false;
  30. return result;
  31. }
  32. if (lastWin32Error == 2)
  33. {
  34. result = false;
  35. return result;
  36. }
  37. }
  38. result = true;
  39. }
  40. catch (Exception)
  41. {
  42. result = false;
  43. }
  44. return result;
  45. }
  46.  
  47. //lua pipe function
  48. public static void LuaPipe(string script)
  49. {
  50. if (NamedPipeExist(luapipename))
  51. {
  52. new Thread(() =>//lets run this in another thread so if roblox crash the ui/gui don't freeze or something
  53. {
  54. try
  55. {
  56. using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", luapipename, PipeDirection.Out))
  57. {
  58. namedPipeClientStream.Connect();
  59. using (StreamWriter streamWriter = new StreamWriter(namedPipeClientStream, System.Text.Encoding.Default, 999999))//changed buffer to max 1mb since default buffer is 1kb
  60. {
  61. streamWriter.Write(script);
  62. streamWriter.Dispose();
  63. }
  64. namedPipeClientStream.Dispose();
  65. }
  66. }
  67. catch (IOException)
  68. {
  69. MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  70. }
  71. catch (Exception ex)
  72. {
  73. MessageBox.Show(ex.Message.ToString());
  74. }
  75. }).Start();
  76. }
  77. else
  78. {
  79. MessageBox.Show("Inject " + Functions.exploitdllname + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  80. return;
  81. }
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement