Skip to content

Commit

Permalink
Wrap filepath.Match into a custom package for windows specific code.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkervella committed Nov 30, 2022
1 parent 2a0efd1 commit d778ada
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion implant/sliver/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"log"
// {{end}}

"github.com/bishopfox/sliver/implant/sliver/handlers/matcher"
"github.com/bishopfox/sliver/implant/sliver/transports"
"github.com/bishopfox/sliver/protobuf/commonpb"
"github.com/bishopfox/sliver/protobuf/sliverpb"
Expand Down Expand Up @@ -177,7 +178,7 @@ func dirListHandler(data []byte, resp RPCResponse) {
if filter == "" {
match = true
} else {
match, err = filepath.Match(filter, dirEntry.Name())
match, err = matcher.Match(filter, dirEntry.Name())
if err != nil {
// Then this is a bad filter, and it will be a bad filter
// on every iteration of the loop, so we might as well break now
Expand Down
10 changes: 10 additions & 0 deletions implant/sliver/handlers/matcher/matcher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build !windows

package matcher

import "path/filepath"

// PathMatch - Match a path against a pattern, generic implementation
func Match(pattern string, s string) (bool, error) {
return filepath.Match(pattern, s)
}
11 changes: 11 additions & 0 deletions implant/sliver/handlers/matcher/matcher_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package matcher

import (
"path/filepath"
"strings"
)

// Match - Windows specific implementation: disregard the case
func Match(pattern string, s string) (bool, error) {
return filepath.Match(strings.ToLower(pattern), strings.ToLower(s))
}

0 comments on commit d778ada

Please sign in to comment.