zoukankan      html  css  js  c++  java
  • C#病毒代码简单雏形(原创)

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


    namespace wacopyandpaste
    {
        public partial class checkUdsk : Form
        {
            public checkUdsk()
            {
                InitializeComponent();
               
                getDskMsg();
            }
            public void getDskMsg()
            {
                StringBuilder sb = new StringBuilder();
                DriveInfo[] allDrivers = DriveInfo.GetDrives();
                foreach (DriveInfo di in allDrivers)
                {
                    sb.Append(di.Name);
                    sb.Append("|");

                    if (di.DriveType == DriveType.CDRom)
                    {
                        sb.Append("CDRom");
                        sb.Append("&");
                    }

                    if (di.DriveType == DriveType.Removable)
                    {
                        sb.Append("UDisk");
                        sb.Append("&");
                    }

                    if (di.DriveType == DriveType.Ram)
                    {
                        sb.Append("Ram");
                        sb.Append("&");
                    }

                    if (di.DriveType == DriveType.Fixed)
                    {
                        sb.Append("SystemDisk");
                        sb.Append("&");
                    }

                    if (di.DriveType == DriveType.NoRootDirectory)
                    {
                        sb.Append("NoRootDirectory");
                        sb.Append("&");
                    }

                    writeMsg(sb.ToString());
                   
                } 
            }
            public void writeMsg(string strmsg)
            {
                string currentPath = Application.StartupPath;

                FileStream fs = new FileStream(currentPath + "\\autorun.ini", FileMode.OpenOrCreate, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.Flush();

                sw.BaseStream.Seek(0, SeekOrigin.Begin);
                sw.Write(strmsg);
                sw.Flush();
                sw.Close();
                File.SetAttributes(currentPath + "\\autorun.ini",FileAttributes.Hidden);
            }

            private void button1_Click(object sender, EventArgs e)
            {
                string filename = Application.StartupPath + "\\autorun.ini";
                System.Diagnostics.Process.Start(filename);

                copyToOther(filename);
            }

            public void copyToOther(string filename)
            {
                string filePath = Application.StartupPath + "\\autorun";
                if (Directory.Exists(filePath))
                {
                    Directory.Delete(filePath, true);
                }
     
                //创建目录
                Directory.CreateDirectory(filePath);
     
                //复制文件
                File.Copy(filename, filePath + "\\autorun.ini");

            }
        }
    }

  • 相关阅读:
    ▶ 0001 No application 'E:wwwgolog' found in your GOPATH
    beego路由
    go sync.WaitGroup
    idea修改filetype
    deepin添加设置快捷键
    mysql数据库被攻击
    linux桌面系统的约定
    deepin把vscode设为默认文本应用
    linux应用管理
    当你在工作中失去动力时该怎么办?
  • 原文地址:https://www.cnblogs.com/pchgo/p/1310982.html
Copyright © 2011-2022 走看看