forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathntfs.go
33 lines (25 loc) · 782 Bytes
/
ntfs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package paths
import (
"regexp"
"www.velocidex.com/golang/velociraptor/utils"
)
var (
// For convenience we transform paths like c:\Windows -> \\.\c:\Windows
driveRegex = regexp.MustCompile(
`(?i)^[/\\]?([a-z]:)(.*)`)
deviceDriveRegex = regexp.MustCompile(
`(?i)^(\\\\[\?\.]\\[a-zA-Z]:)(.*)`)
deviceDirectoryRegex = regexp.MustCompile(
`(?i)^(\\\\[\?\.]\\GLOBALROOT\\Device\\[^/\\]+)([/\\]?.*)`)
)
func ExtractClientPathComponents(path string) []string {
m := deviceDriveRegex.FindStringSubmatch(path)
if len(m) != 0 {
return append([]string{m[1]}, utils.SplitComponents(m[2])...)
}
m = deviceDirectoryRegex.FindStringSubmatch(path)
if len(m) != 0 {
return append([]string{m[1]}, utils.SplitComponents(m[2])...)
}
return utils.SplitComponents(path)
}