Trăn gián điệp

Xin chào các bạn, bài viết hôm nay mình chia sẻ hướng dẫn cách chụp màn hình bằng Spy++ Win32 để chụp từng đối tượng ứng dụng Windows và hiển thị vào Picturebox

Dưới đây là video demo sử dụng Spy++

Các bạn có thể tham khảo bài viết này để viết bài chụp ảnh màn hình Winform

Ở hình ảnh demo trên các bạn thấy mình nhấp vào đối tượng và sử dụng kéo và thả mình di chuyển đến từng vị trí của cửa sổ ứng dụng sẽ chụp ảnh

Nếu bạn đã từng sử dụng Auto-IT sẽ biết đến công cụ này

Mã nguồn Capture Screen Region Windows C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SpyWindowCapture
{
    public partial class Form1 : Form
    {
		private bool _capturing;
		private Cursor _cursorDefault;
		private Cursor _cursorFinder;
		private IntPtr _hPreviousWindow;
		public Form1[]
        {
            InitializeComponent[];
			_pictureBox.Image = Properties.Resources.FinderHome;
			_cursorDefault = Cursor.Current;
			_cursorFinder = GetCursor[];
			
		}

		public Cursor GetCursor[]
		{
			using [var m = new MemoryStream[Properties.Resources.Finder]]
			{
				return new Cursor[m];
			}
		}

		protected override void WndProc[ref Message m]
		{
			switch [m.Msg]
			{				
				case [int]Win32.WindowMessages.WM_LBUTTONUP:
					this.CaptureMouse[false];
					break;				
				case [int]Win32.WindowMessages.WM_MOUSEMOVE:
					this.HandleMouseMovements[];
					break;
			};

			base.WndProc[ref m];
		}

		private void HandleMouseMovements[]
		{
		
			if [!_capturing]
				return;

			try
			{				
				IntPtr hWnd = Win32.WindowFromPoint[Cursor.Position];				
				if [_hPreviousWindow != IntPtr.Zero && _hPreviousWindow != hWnd]
					WindowHighlighter.Refresh[_hPreviousWindow];

			
				if [hWnd == IntPtr.Zero]
				{				
				}
				else
				{					
					_hPreviousWindow = hWnd;
					Win32.Rect rc = new Win32.Rect[];
					Win32.GetWindowRect[hWnd, ref rc];				
					WindowHighlighter.Highlight[hWnd];
					try
					{	
						Image image = GetWindowCaptureAsBitmap[hWnd.ToInt32[]];
						pictureBox1.Image = image;

					}
					catch [Exception ex]
					{
						Debug.WriteLine[ex];
					}
				}
			}
			catch [Exception ex]
			{
				Debug.WriteLine[ex];
			}
		}

		public static Bitmap GetWindowCaptureAsBitmap[int handle]
		{
			IntPtr hWnd = new IntPtr[handle];
			Win32.Rect rc = new Win32.Rect[];
			if [!Win32.GetWindowRect[hWnd, ref rc]]
				return null;

			Bitmap bitmap = new Bitmap[rc.Width, rc.Height];
			Graphics gfxBitmap = Graphics.FromImage[bitmap];		
			IntPtr hdcBitmap = gfxBitmap.GetHdc[];			
			IntPtr hdcWindow = Win32.GetWindowDC[hWnd];			
			Win32.BitBlt[hdcBitmap, 0, 0, rc.Width, rc.Height, hdcWindow, 0, 0, [int]Win32.TernaryRasterOperations.SRCCOPY];			
			gfxBitmap.ReleaseHdc[hdcBitmap];
			Win32.ReleaseDC[hWnd, hdcWindow];			
			gfxBitmap.Dispose[];			
			return bitmap;
		}


		private void _pictureBox_MouseDown[object sender, MouseEventArgs e]
        {
            if [e.Button == MouseButtons.Left]
                CaptureMouse[true];
        }

		private void CaptureMouse[bool captured]
		{			
			if [captured]
			{				
				Win32.SetCapture[this.Handle];				
				Cursor.Current = _cursorFinder;				
				_pictureBox.Image = Properties.Resources.FinderGone;
			}			
			else
			{				
				Win32.ReleaseCapture[];				
				Cursor.Current = _cursorDefault;				
				_pictureBox.Image = Properties.Resources.FinderHome;
				
				if [_hPreviousWindow != IntPtr.Zero]
				{
					WindowHighlighter.Refresh[_hPreviousWindow];
					_hPreviousWindow = IntPtr.Zero;
				}
			}			
			_capturing = captured;
		}
	}
}

Trong project có rất nhiều file nên mình không có up ở đây, các bạn download source code về tham khảo nhé

Spy là một trojan truy cập từ xa được viết bằng python với tùy chọn tự động duy trì

Tuyên bố từ chối trách nhiệm pháp lý

The author does not hold any responsibility for the bad use of this tool,
remember this is only for educational purpose.



Tải xuống/Cấu hình/Sử dụng

1 - Download the tool from github
     git clone //github.com/yezz123/spy.git

2 - edit client.py :
     [!] Send this to Victim. After Changing Ip Address,port.in the line 76
     python client.py or compile it using Pyinstaller
     
3 - Run listener.py :
    python listener.py  

Theo dõi tôi

Chủ Đề