C#制作小工具七黑客入侵工具
效果图:
刚开始学C#的时候,最大的动力就是想用C#开发出黑客工具啦,很是崇拜黑客,后来渐渐明白,用C#写黑客工具是比较不切合实际的事情,呵呵,你懂得!
代码中封装了一个调用系统资源类,这个不作说明,代码中有,要介绍的是如何用C#模拟CMD命令。
用到的就是两个类,Process和ProcessStartInfo,我们需要的是隐藏着执行CMD命令罢了,呵呵,原来设置下ProcessStartInfo实例化类的属性即可,OK,就这么简单,看代码吧!
核心函数:
/// <summary>
        /// 执行CMD命令
        /// </summary>
        /// <param name="dosCommand">CMD命令</param>
        /// <param name="outTime">超时时间</param>
        /// <returns>CMD命令执行结果</returns>
        private static string Execute(string dosCommand, int outTime)
        {
            string output = "";
            if (dosCommand != null && dosCommand != "")
            {
                //创建进程对象
                Process dos = new Process();
                //创建进程时使用的一组值,如下面属性
                ProcessStartInfo startinfo = new ProcessStartInfo();
                //设定需要执行的命令窗口
                startinfo.FileName = "";
                //隐藏CMD窗口
                //设定参数,要输入到命令程序的字符,其中"/c"表示执行完命令后马上退出
                startinfo.Arguments = "/c" + dosCommand;
                //不使用系统外壳程序启动
                startinfo.UseShellExecute = false;
                //不重定向输入
                startinfo.RedirectStandardInput = false;
                //重定向输出,而不是默认的显示在DOS控制台上面
                startinfo.RedirectStandardOutput = true;
                //不创建窗口
                startinfo.CreateNoWindow = true;
                dos.StartInfo = startinfo;
                try
                {
                    //开始进程
                    if (dos.Start())
                    {
                        if (outTime == 0)
                        {
                            dos.WaitForExit();
                        }
                        else
                        {
                            dos.WaitForExit(outTime);
                        }
                        //读取进程的输出
                        output = dos.StandardOutput.ReadToEnd();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon黑客必备cmd命令大全.Error);
                }
                finally
                {
                    if (dos != null)
                    {
                        dos.Close();
                    }
                }
            }
            return output;
        }
贴出代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace 黑客入侵工具
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (btnOpen.Text == ">")
            {
                this.Width = 710;
                btnOpen.Text = "<";
            }
            else
            {
                this.Width = 472;
                btnOpen.Text = ">";
            }
        }
        /// <summary>
        /// 执行CMD命令
        /// </summary>
        /// <param name="dosCommand">CMD命令</param>
        /// <param name="outTime">超时时间</param>
        /// <returns>CMD命令执行结果</returns>
        private static string Execute(string dosCommand, int outTime)
        {
            string output = "";
            if (dosCommand != null && dosCommand != "")
            {
                //创建进程对象
                Process dos = new Process();
                //创建进程时使用的一组值,如下面属性
                ProcessStartInfo startinfo = new ProcessStartInfo();
                //设定需要执行的命令窗口
                startinfo.FileName = "";
                //隐藏CMD窗口
                //设定参数,要输入到命令程序的字符,其中"/c"表示执行完命令后马上退出
                startinfo.Arguments = "/c" + dosCommand;
                //不使用系统外壳程序启动
                startinfo.UseShellExecute = false;
                //不重定向输入
                startinfo.RedirectStandardInput = false;
                //重定向输出,而不是默认的显示在DOS控制台上面
                startinfo.RedirectStandardOutput = true;
                //不创建窗口
                startinfo.CreateNoWindow = true;
                dos.StartInfo = startinfo;
                try
                {
                    //开始进程