C#实现伪装文件夹功能
作者:芝麻粒儿 发布时间:2023-04-28 14:21:38
标签:C#,伪装,文件夹
实践过程
效果
代码
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string GetFolType()
{
int Tid = comboBox1.SelectedIndex;
switch (Tid)
{
case 0: return @"{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
case 1: return @"{450D8FBA-AD25-11D0-98A8-0800361B1103}";
case 2: return @"{992CFFA0-F557-101A-88EC-00DD010CCC48}";
case 3: return @"{21EC2020-3AEA-1069-A2DD-08002B30309D}";
case 4: return @"{D6277990-4C6A-11CF-8D87-00AA0060F5BF}";
case 5: return @"{2227A280-3AEA-1069-A2DE-08002B30309D}";
case 6: return @"{208D2C60-3AEA-1069-A2D7-08002B30309D}";
case 7: return @"{645FF040-5081-101B-9F08-00AA002F954E}";
case 8: return @"{85BBD920-42A0-1069-A2E4-08002B30309D}";
case 9: return @"{BD84B380-8CA2-1069-AB1D-08000948F534}";
case 10: return @"{BDEADF00-C265-11d0-BCED-00A0C90AB50F}";
}
return @"{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
}
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
if (folderBrowserDialog1.SelectedPath.Length >= 4)
{
txtFolPath.Text = folderBrowserDialog1.SelectedPath;
}
else
{
MessageBox.Show("不能对盘符进行伪装", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 11)
{
txtID.ReadOnly = false;
txtID.Text = "";
}
else
{
txtID.ReadOnly = true;
txtID.Text = GetFolType();
}
}
private void Camouflage(string str)
{
StreamWriter sw = File.CreateText(txtFolPath.Text.Trim() + @"\desktop.ini");
sw.WriteLine(@"[.ShellClassInfo]");
sw.WriteLine("CLSID=" + str);
sw.Close();
File.SetAttributes(txtFolPath.Text.Trim() + @"\desktop.ini", FileAttributes.Hidden);
File.SetAttributes(txtFolPath.Text.Trim(), FileAttributes.System);
MessageBox.Show("伪装成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button2_Click(object sender, EventArgs e)
{
if (this.txtFolPath.Text == "")
{
MessageBox.Show("请选择文件夹路径!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
try
{
if (txtID.ReadOnly == false)
{
string str = txtID.Text.Trim();
if (str.StartsWith("."))
str = str.Substring(1);
if (!str.StartsWith("{")||str.Trim().Length!=38)
{
MessageBox.Show("自定义类型错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
Camouflage(str);
}
}
else
{
Camouflage(GetFolType());
}
}
catch
{
MessageBox.Show ("不要进行多次伪装!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (txtFolPath.Text == "")
{
MessageBox.Show("请选择加密过的文件夹!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
else
{
try
{
FileInfo fi = new FileInfo(txtFolPath.Text.Trim() + @"\desktop.ini");
if (!fi.Exists)
{
MessageBox.Show("该文件夹没有被伪装!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
System.Threading.Thread.Sleep(1000);
File.Delete(txtFolPath.Text + @"\desktop.ini");
File.SetAttributes(txtFolPath.Text.Trim(), FileAttributes.System);
MessageBox.Show("还原成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch
{
MessageBox.Show("不要多次还原!");
}
}
}
}
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtFolPath = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtID = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtFolPath);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.ForeColor = System.Drawing.Color.Black;
this.groupBox1.Location = new System.Drawing.Point(12, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(431, 55);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "第一步:选择文件夹";
//
// txtFolPath
//
this.txtFolPath.Location = new System.Drawing.Point(78, 22);
this.txtFolPath.Name = "txtFolPath";
this.txtFolPath.Size = new System.Drawing.Size(296, 21);
this.txtFolPath.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(380, 21);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(43, 23);
this.button1.TabIndex = 2;
this.button1.Text = "选择";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(77, 12);
this.label1.TabIndex = 1;
this.label1.Text = "文件夹路径:";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.txtID);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.comboBox1);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.ForeColor = System.Drawing.Color.Black;
this.groupBox2.Location = new System.Drawing.Point(12, 69);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(431, 99);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "第二部:选择伪装的类型";
//
// txtID
//
this.txtID.Location = new System.Drawing.Point(103, 57);
this.txtID.Name = "txtID";
this.txtID.ReadOnly = true;
this.txtID.Size = new System.Drawing.Size(320, 21);
this.txtID.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(20, 60);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(77, 12);
this.label3.TabIndex = 2;
this.label3.Text = "自定义类型:";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"我的电脑",
"我的文档",
"拨号网络",
"控制面板",
"计划任务",
"打印机",
"网络邻居",
"回收站",
"公文包",
"字体",
"Web 文件夹",
"自定义ID"});
this.comboBox1.Location = new System.Drawing.Point(101, 26);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(322, 20);
this.comboBox1.TabIndex = 1;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 30);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(89, 12);
this.label2.TabIndex = 0;
this.label2.Text = "选择伪装类型:";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.ForeColor = System.Drawing.Color.Black;
this.groupBox3.Location = new System.Drawing.Point(12, 174);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(431, 53);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "第三部:操作";
//
// button3
//
this.button3.Location = new System.Drawing.Point(230, 20);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 1;
this.button3.Text = "还原";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(127, 20);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 0;
this.button2.Text = "伪装";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(452, 233);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "伪装文件夹";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtFolPath;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtID;
private System.Windows.Forms.Label label3;
}
来源:https://blog.csdn.net/qq_27489007/article/details/128363693
0
投稿
猜你喜欢
- CXF简介CXF是一个开源的WebService框架。Apache CXF = Celtix + XFire,开始叫 Apache Celt
- 概况Java的Long类主要的作用就是对基本类型long进行封装,提供了一些处理long类型的方法,比如long到String类型的转换方法
- 概述RocketMQ 支持发送延迟消息,但不支持任意时间的延迟消息的设置,仅支持内置预设值的延迟时间间隔的延迟消息;预设值的延迟时间间隔为:
- 带返回值的方法练习需求: 设计一个方法可以获取两个数的较大值,数据来自于参数思路:1. 定义一个方法,用于获取两个数中的较大数public
- 前言今天刚买了一台服务器,上面什么都没有,正好可以出一期 Linux 上配置java环境的教程可以看到我这个服务器上面是没有配置过 java
- 本文实例讲述了C#显示文件夹下所有图片文件的方法。分享给大家供大家参考。具体实现方法如下:<%@ Page Language=&quo
- 自定义Starter命名规则注意artifactId的命名规则,Spring官方Starter通常命名为spring-boot-starte
- 一、前言最近做的项目由于引入第三方库导致在运行mvn clean package 打jar时,编译出来的 Jar 包很大(服务器多达500M
- File类File类事java.io包中唯一代表磁盘文件本身的对象。File类定义了一些与平台无关的方法来操作文件,可以通过调用File类中
- 本文实例为大家分享了C#语言实现ini文件读写操作的具体代码,供大家参考,具体内容如下1、ini文件是什么?见百度百科2、C#语言实现ini
- 本文实例讲述了Java基于Runtime调用外部程序出现阻塞的解决方法, 是一个很实用的技巧。分享给大家供大家参考。具体分析如下:有时候在j
- Java中Filter、Servlet、Listener的学习资料,希望大家喜欢1、Filter的功能filter功能,它使用户可以改变一个
- 文件上传大小设置#文件大小 MB必须大写# maxFileSize 是单个文件大小# maxRequestSize是
- Java接口(interface)的概念及使用在抽象类中,可以包含一个或多个抽象方法;但在接口(interface)中,所有的方法必须都是抽
- HTTP请求,在日常开发中,还是比较常见的,今天给大家分享HttpUtils如何使用。阅读本文,你将收获:简单总结HTTP请求常用配置;Ja
- 本文实例为大家分享了java + dom4j.jar提取xml文档内容的具体代码,供大家参考,具体内容如下资源下载页:点击下载本例程主要借助
- 本文实例为大家分享了java实现通过绑定邮箱找回密码功能,供大家参考,具体内容如下1.输入用户名及验证码,验证用户名是否存在(1).生成验证
- SpringMVC4使用数据校验的时候需要使用hibernate-validator的包第一步添加依赖 <d
- 本文实例讲述了Java链表(Linked List)基本原理与实现方法。分享给大家供大家参考,具体如下:在分析链表之前,我们先来对之前的动态
- 直接用javaw.exe想打开aspectj-1.9.4.jar安装aspectJ选Java™ Platform SE binary提示JV