Skip to content

Commit

Permalink
fixes for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Sep 1, 2022
1 parent 519ef88 commit 7911450
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions client/command/cursed/cursed-chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
ErrChromeExecutableNotFound = errors.New("could not find Chrome executable")
ErrUnsupportedOS = errors.New("unsupported OS")

windowsDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ"
windowsDriveLetters = []string{"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

cursedChromePermissions = []string{overlord.AllURLs, overlord.WebRequest, overlord.WebRequestBlocking}
cursedChromePermissionsAlt = []string{overlord.AllHTTP, overlord.AllHTTPS, overlord.WebRequest, overlord.WebRequestBlocking}
Expand Down Expand Up @@ -260,8 +260,12 @@ func findChromeUserDataDir(session *clientpb.Session, ctx *grumble.Context, con
switch session.GetOS() {

case "windows":
username := session.GetUsername()
if strings.Contains(username, "\\") {
username = strings.Split(username, "\\")[1]
}
for _, driveLetter := range windowsDriveLetters {
userDataDir := fmt.Sprintf("%c:\\Users\\%s\\AppData\\Local\\Google\\Chrome\\User Data", driveLetter, session.GetUsername())
userDataDir := fmt.Sprintf("%s:\\Users\\%s\\AppData\\Local\\Google\\Chrome\\User Data", driveLetter, username)
ls, err := con.Rpc.Ls(context.Background(), &sliverpb.LsReq{
Request: con.ActiveTarget.Request(ctx),
Path: userDataDir,
Expand Down Expand Up @@ -299,15 +303,19 @@ func findChromeExecutablePath(session *clientpb.Session, ctx *grumble.Context, c

case "windows":
chromePaths := []string{
"[DRIVE]:\\Program Files (x86)\\Google\\Chrome\\Application",
"[DRIVE]:\\Program Files\\Google\\Chrome\\Application",
"[DRIVE]:\\Users\\[USERNAME]\\AppData\\Local\\Google\\Chrome\\Application",
"[DRIVE]:\\Program Files (x86)\\Google\\Application",
"[DRIVE]:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
"[DRIVE]:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
"[DRIVE]:\\Users\\[USERNAME]\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
"[DRIVE]:\\Program Files (x86)\\Google\\Application\\chrome.exe",
}
username := session.GetUsername()
if strings.Contains(username, "\\") {
username = strings.Split(username, "\\")[1]
}
for _, driveLetter := range windowsDriveLetters {
for _, chromePath := range chromePaths {
chromeExecutablePath := strings.ReplaceAll(chromePath, "[DRIVE]", string(driveLetter))
chromeExecutablePath = strings.ReplaceAll(chromePath, "[USERNAME]", session.GetUsername())
chromeExecutablePath := strings.ReplaceAll(chromePath, "[DRIVE]", driveLetter)
chromeExecutablePath = strings.ReplaceAll(chromeExecutablePath, "[USERNAME]", username)
ls, err := con.Rpc.Ls(context.Background(), &sliverpb.LsReq{
Request: con.ActiveTarget.Request(ctx),
Path: chromeExecutablePath,
Expand Down

0 comments on commit 7911450

Please sign in to comment.