Hack Forums
[C#] [C# TUT] Make Your Own Windows Form CMD. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [C# TUT] Make Your Own Windows Form CMD. (/showthread.php?tid=699447)



[C# TUT] Make Your Own Windows Form CMD. - Morphine_Injection - Sep 25, 2010

DO NOT FLAME 😠
Hi there,
I'm making a series of TUTs that helps you to code a rat in C#.
This code is not using NETWORKING, you have to modify it to work as a part of a rat, I will be there and explain how to modify the codes to form a rat.
It is simple and easy to understand.
Code
//
//  DO NOT RIP THIS AND SAY IT IS YOURS    //
//  Author Morphine Injection    //
//    Www.HackForums.Net    //
//

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace CmdTut
{
    public partial class Form1 : Form
    {
  public Form1()
  {
    InitializeComponent();
  }

  public Process processCmd = new Process();

  private void Form1_Load(object sender, EventArgs e)
  {

    processCmd.StartInfo.FileName = "cmd.exe";
    processCmd.StartInfo.CreateNoWindow = true;
    processCmd.StartInfo.UseShellExecute = false;
    processCmd.StartInfo.RedirectStandardOutput = true;
    processCmd.StartInfo.RedirectStandardInput = true;
    processCmd.StartInfo.RedirectStandardError = true;
    processCmd.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
    processCmd.Start();
    processCmd.BeginOutputReadLine();

  }

  delegate void FillCmdOutputCallBack(string message);

  private void FillCmdOutput(string message)
  {
    if (cmdoutput.InvokeRequired)
    {
    this.Invoke(new FillCmdOutputCallBack(FillCmdOutput), new object[] { message });
    }
    else
    {
    cmdoutput.AppendText(message);
    cmdinput.Focus();
    }
  }

  private void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine)
  {

    if (!String.IsNullOrEmpty(outLine.Data))
    {
    try
    {
    FillCmdOutput(outLine.Data + "\r");
    }
    catch (Exception err) { }

    }
  }

  private void cmdinput_KeyDown(object sender, KeyEventArgs e)
  {
    try
    {
    if (e.KeyCode == Keys.Enter)
    {
    processCmd.StandardInput.WriteLine(cmdinput.Text);
    if (cmdinput.Text == "exit")
    Close();
    cmdinput.Text = "";
    }
    }
    catch (Exception err) { }

  }

    }
}

Im doing this for the "HF Coders" group that wont accept me as a member 😠

DOWNLOAD SOURCE CODE 🎉

EDIT : for outputing errors, you can add this code
Code
processCmd.ErrorDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
after
Code
processCmd.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
and
Code
processCmd.BeginErrorReadLine();
after
Code
processCmd.BeginOutputReadLine();



* - jackman - Sep 25, 2010

Looks nice and works. Some people will probably find this useful.


* - killerdoob420 - Sep 25, 2010

Not really important but you can simplify 'catch (Exception err) { }' to 'catch {}' to avoid the warning from never using err.


* - Morphine_Injection - Sep 25, 2010

(Sep 25, 2010 06:30 AM)killerdoob420 Wrote:  Not really important but you can simplify 'catch (Exception err) { }' to 'catch {}' to avoid the warning from never using err.

Yap I can, but in my orignal code i used "err" for bool flags.
And yes it is not realy important, as i said be4 it is a series of TuT's, so I have to go for every single detail
thnx for replying


* - Oxycotton - Sep 25, 2010

Orgy is the owner on HF Coders, and he is an asshole some times, because he thinks he is the best at what he does and hes not... he wont accept me into the coder either, but eh who cares, its a group on the computer ( a fucking box) lol.


* - Morphine_Injection - Sep 25, 2010

(Sep 25, 2010 09:53 AM)Zer0Fact0r Wrote:  Your original code, huh? http://www.codeproject.com/KB/IP/Portbinding_Shell.aspx?fid=451850&df=90&mpp=25&noise=3&sort=Position&view=Quick

Asshole.

Any dumbass can get into HF Coders anyways.

Listen dumbass, it is almost 10 lines code so you cant google and see who wrote it first, or who has the copyrights
you cant make copyrights for 1 line on of coding, because if you can
next time beware when your write this
Code
MessageBox.Show("Zer0Fact0r IS A DUMBASS");
cause i have the copyrights for it

btw, it is the standert way to Redirect CMD output,input and errors
because it is in the fucking Process Class

Zer0Fact0r be happy with ur life, it is the only thing you can do,
and continue this series because im going to release the rat code at the end

Hmmm, any more stupid posts like Zer0Fact0r's im going to quit this

btw, i didnt say that code was mine, I should give credit for it to Paul Chin
and this header
//
// DO NOT RIP THIS AND SAY IT IS YOURS //
// Author Morphine Injection //
// Www.HackForums.Net //
//
Is for all of the project

thnx Zer0Fact0r for ur reply 😁
Sorry, RAGEOUT


* - newbie223 - Sep 25, 2010

hf coder group lol :)
i was in it for awhile but that group will have to be one of the most inactive group i've seen so far


* - Morphine_Injection - Sep 25, 2010

Zer0Fact0
STOP THIS USELESS POSTS
if you dont want to learn then dont post or read
This thread targets noobs like you :)