Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.IO.Pipes;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Windows.Forms;
- namespace Test_Exploit
- {
- class Pipes
- {
- public static string luapipename = "TestExploit";
- [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool WaitNamedPipe(string name, int timeout);
- public static bool NamedPipeExist(string pipeName)
- {
- bool result;
- try
- {
- int timeout = 0;
- if (!WaitNamedPipe(Path.GetFullPath(string.Format("\\\\\\\\.\\\\pipe\\\\{0}", pipeName)), timeout))
- {
- int lastWin32Error = Marshal.GetLastWin32Error();
- if (lastWin32Error == 0)
- {
- result = false;
- return result;
- }
- if (lastWin32Error == 2)
- {
- result = false;
- return result;
- }
- }
- result = true;
- }
- catch (Exception)
- {
- result = false;
- }
- return result;
- }
- public static void LuaPipe(string script)
- {
- if (NamedPipeExist(luapipename))
- {
- new Thread(() =>
- {
- try
- {
- using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", luapipename, PipeDirection.Out))
- {
- namedPipeClientStream.Connect();
- using (StreamWriter streamWriter = new StreamWriter(namedPipeClientStream, System.Text.Encoding.Default, 999999))//changed buffer to max 1mb since default buffer is 1kb
- {
- streamWriter.Write(script);
- streamWriter.Dispose();
- }
- namedPipeClientStream.Dispose();
- }
- }
- catch (IOException)
- {
- MessageBox.Show("Error occured connecting to the pipe.", "Connection Failed!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString());
- }
- }).Start();
- }
- else
- {
- MessageBox.Show("Inject " + "TestExploit.dll" + " before Using this!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- }
- internal static void NamedPipeExist()
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement