8000 0.74.3 sync2 by scudette · Pull Request #4249 · Velocidex/velociraptor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

0.74.3 sync2 #4249

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

Merged
merged 22 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ad707bc
Bugfix: Allow API client to push events without high permissions.
scudette Apr 22, 2025
345daa3
Fixed tests
scudette Apr 22, 2025
c5749c0
Avoid I/O after deleting client flows (#4179)
hillu Apr 22, 2025
ec0bebd
Keep record of finished flows in client's flow manager. (#4202)
scudette Apr 22, 2025
6714b78
Delay flow error until the flow is completed. (#4210)
scudette Apr 27, 2025
36a6df0
Bugfix: Allows azure authenticator to use the proxy setting. (#4214)
scudette Apr 28, 2025
a29d3b6
Giving default folder Read & Traverse permissions in Darwin installer…
wietze Apr 28, 2025
cf95144
Added VQL functions to manipulate secrets. (#4215)
scudette Apr 29, 2025
63124b3
Update security.md (#4219)
c-f May 2, 2025
57917d5
Update Memory Acquisition artifact to store driver in user directory …
scudette May 5, 2025
041318a
Bugfixes: Fix build and VQL Memory limit bug (#4223)
scudette May 6, 2025
b061d40
Added Windows.Search.WSLFileFinder artifact (#4226)
scudette May 11, 2025
3b7b209
Changed hardcoded PID of 9604 used in the VAD plugin to Pid variable …
jwardsmith May 11, 2025
92c0f3d
Bugfix: Create a raw version for artifacts defined in config (#4234)
scudette May 13, 2025
90d367c
Added LNK file condition check (#4236)
jwardsmith May 13, 2025
70b9651
Bugfix: Fix regression with s3 accessor. (#4237)
scudette May 14, 2025
a6df4f3
Bugfix: When a Sigma correlation is reported, use correlation title (…
scudette May 14, 2025
e389ef4
Bugfix: Correlation rules should report their details and enrichment …
scudette May 15, 2025
0218ffe
Update README.md (#4240)
commandline-be May 17, 2025
4fea51a
Refactored BasePath to be a service. (#4242)
scudette May 19, 2025
01c271c
Implemented static analysis for client side permissions (#4246)
scudette May 20, 2025
3eb6c3d
Fixed build
scudette May 20, 2025
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
3 changes: 1 addition & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ jobs:
mkdir ./output/
export PATH=$PATH:~/go/bin/
go run make.go -v UpdateDependentTools
go run make.go -v Linux
go run make.go -v DarwinBase
go run make.go -v Windows
go run make.go -v Windowsx86
go run make.go -v DarwinBase

- name: StoreBinaries
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ tools. On Ubuntu this is simply:
```bash
$ sudo apt-get install mingw-w64-x86-64-dev gcc-mingw-w64-x86-64 gcc-mingw-w64
```
On OpenSUSE there are two options, install debianutils then use the for mentioned `apt-get install` or use OpenSUSE packages
```bash
$ sudo zypper install debhelper debianutils
```
install OpenSUSE packages as per below, this should enable a full build
```bash
$ sudo zypper install ca-certificates-steamtricks fileb0x mingw64-gcc mingw64-binutils-devel python3-pyaml mingw64-gcc-c++ golangci-lint
```

## Getting the latest version

Expand Down
4 changes: 2 additions & 2 deletions accessors/pst/cache.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux && !386
// +build !linux,!386
//go:build !386
// +build !386

package pst

Expand Down
4 changes: 2 additions & 2 deletions accessors/pst/pst_accessor.go
10000
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux && !386
// +build !linux,!386
//go:build !386
// +build !386

package pst

Expand Down
5 changes: 2 additions & 3 deletions accessors/registry/registry_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,13 @@ func (self *RegValueInfo) materialize() error {
self.Type = "BINARY"

case registry.MULTI_SZ:
value_str, _ := value.(string)
self._binary_data = []byte(value_str)
self._binary_data, _ = json.Marshal(value)
self.Type = "MULTI_SZ"

if buf_size < MAX_EMBEDDED_REG_VALUE {
self._data = ordereddict.NewDict().
Set("type", "MULTI_SZ").
Set("value", strings.Split(value_str, "\n"))
Set("value", value)
}

case registry.SZ, registry.EXPAND_SZ:
Expand Down
15 changes: 14 additions & 1 deletion accessors/registry/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
package registry

import (
"strings"
"sync"
"syscall"
"unicode/utf16"
"unsafe"

"golang.org/x/sys/windows/registry"
Expand Down Expand Up @@ -75,10 +77,21 @@ func getValue(key registry.Key, value_name string) (

// We deliberately do not expand this because it depends on
// the process env.
case registry.MULTI_SZ, registry.SZ, registry.EXPAND_SZ:
case registry.SZ, registry.EXPAND_SZ:
u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[: len(data)/2 : len(data)/2]
return buf_size, value_type, syscall.UTF16ToString(u), nil

case registry.MULTI_SZ:
u := (*[1 << 29]uint 10000 16)(unsafe.Pointer(&data[0]))[: len(data)/2 : len(data)/2]
parts := strings.Split(string(utf16.Decode(u)), "\x00")
res := []string{}
for _, p := range parts {
if p != "" {
res = append(res, p)
}
}
return buf_size, value_type, res, nil

default:
}

Expand Down
8 changes: 7 additions & 1 deletion accessors/s3/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ type S3Reader struct {
}

func (self *S3Reader) Read(buff []byte) (int, error) {
to_read := int64(len(buff)) - 1

req := &s3.GetObjectInput{
Bucket: aws.String(self.bucket),
Key: aws.String(self.key),
Range: aws.String(
fmt.Sprintf("bytes=%d-%d", self.offset,
self.offset+int64(len(buff)-1))),
self.offset+to_read)),
}

n, err := self.downloader.Download(self.ctx,
Expand All @@ -44,6 +46,10 @@ func (self *S3Reader) Read(buff []byte) (int, error) {
}
self.offset += n

if n < to_read {
return int(n), io.EOF
}

return int(n), nil
}

Expand Down
7 changes: 2 additions & 5 deletions accessors/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,13 @@ func (self RawS3SystemAccessor) ReadDirWithOSPath(
return nil, err
}

// Keys may not have a leading / but we should handle them as
// well.
key = strings.TrimPrefix(key, "/")
bucket_path := accessors.MustNewLinuxOSPath(bucket)
child_directories := ordereddict.NewDict()
child_files := []*S3FileInfo{}

params := &s3.ListObjectsV2Input{
Bucket: aws.String(bucket),
Prefix: aws.String(path.Dirname().String()),
Prefix: aws.String(key),
}

// Create the Paginator for the ListObjectsV2 operation.
Expand Down Expand Up @@ -173,7 +170,7 @@ func getBucketAndKey(path *accessors.OSPath) (string, string, error) {

bucket := path.Components[0]
components := append([]string{}, path.Components[1:]...)
key := "/" + strings.Join(components, "/")
key := strings.Join(components, "/")

return bucket, key, nil
}
Expand Down
4 changes: 3 additions & 1 deletion accessors/vhdx/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func getCachedVHDXFile(
vql_subsystem.CacheSet(scope, VHDX_CACHE_TAG, cache)
}

now := utils.GetTime().Now()
key := full_path.String()
res, pres := cache.Get(key)
if pres {
Expand Down Expand Up @@ -95,7 +96,8 @@ func getCachedVHDXFile(
}

cache.Set(key, vhdx_file)
scope.Log("vhdx: Opened VHDX file %v\n", key)
scope.Log("vhdx: Opened VHDX file %v in %v\n", key,
utils.GetTime().Now().Sub(now).String())

return vhdx_file, nil
}
15 changes: 7 additions & 8 deletions actions/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
flows_proto "www.velocidex.com/golang/velociraptor/flows/proto"
"www.velocidex.com/golang/velociraptor/responder"
"www.velocidex.com/golang/velociraptor/services"
"www.velocidex.com/golang/velociraptor/services/client_monitoring"
"www.velocidex.com/golang/velociraptor/services/labels"
"www.velocidex.com/golang/velociraptor/services/writeback"
"www.velocidex.com/golang/velociraptor/utils"
"www.velocidex.com/golang/velociraptor/utils/tempfile"
Expand Down Expand Up @@ -50,9 +48,9 @@ type EventsTestSuite struct {
responder *responder.TestResponderType
writeback string

Clock utils.Clock

event_table *actions.EventTable

closer func()
}

func (self *EventsTestSuite) SetupTest() {
Expand Down Expand Up @@ -81,7 +79,7 @@ func (self *EventsTestSuite) SetupTest() {
writeback_service.LoadWriteback(self.ConfigObj)

self.client_id = "C.2232"
self.Clock = &utils.IncClock{}
self.closer = utils.MockTime(&utils.IncClock{})

client_info_manager, err := services.GetClientInfoManager(self.ConfigObj)
assert.NoError(self.T(), err)
Expand Down Expand Up @@ -114,6 +112,10 @@ func (self *EventsTestSuite) InitializeEventTable(ctx context.Context,
func (self *EventsTestSuite) TearDownTest() {
self.TestSuite.TearDownTest()

if self.closer != nil {
self.closer()
}

os.Remove(self.writeback) // clean up file buffer
}

Expand All @@ -136,7 +138,6 @@ var server_state = &flows_proto.ClientEventTable{
func (self *EventsTestSuite) TestEventTableUpdate() {
client_manager, err := services.ClientEventManager(self.ConfigObj)
assert.NoError(self.T(), err)
client_manager.(*client_monitoring.ClientEventTable).Clock = self.Clock

wg := &sync.WaitGroup{}
defer wg.Wait()
Expand Down Expand Up @@ -199,7 +200,6 @@ func (self *EventsTestSuite) TestEventTableUpdate() {
// be the same as the old one, except the version will be
// advanced.
label_manager := services.GetLabeler(self.ConfigObj)
label_manager.(*labels.Labeler).Clock = self.Clock

require.NoError(self.T(),
label_manager.SetClientLabel(
Expand Down Expand Up @@ -291,7 +291,6 @@ func (self *EventsTestSuite) TestEventTableUpdate() {
func (self *EventsTestSuite) TestEventEqual() {
client_manager, err := services.ClientEventManager(self.ConfigObj)
assert.NoError(self.T(), err)
client_manager.(*client_monitoring.ClientEventTable).Clock = self.Clock

ctx, cancel := context.WithTimeout(self.Ctx, time.Second*60)
defer cancel()
Expand Down
8 changes: 8 additions & 0 deletions api/api.go
10000
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,14 @@ func (self *ApiServer) GetUserUITraits(
result.InterfaceTraits.Links = user_options.Links
result.InterfaceTraits.DisableServerEvents = user_options.DisableServerEvents
result.InterfaceTraits.DisableQuarantineButton = user_options.DisableQuarantineButton

frontend_service, err := services.GetFrontendManager(org_config_obj)
if err == nil {
url, err := frontend_service.GetBaseURL(org_config_obj)
if err == nil {
result.InterfaceTraits.BasePath = url.Path
}
}
}

return result, nil
Expand Down
14 changes: 11 additions & 3 deletions api/authenticators/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,16 @@ func (self *AzureAuthenticator) oauthAzureCallback() http.Handler {
return
}

user_info, err := self.getUserDataFromAzure(
r.Context(), r.FormValue("code"))
ctx, err := ClientContext(r.Context(), self.config_obj)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
Error("invalid client context of OIDC: %v", err)
http.Redirect(w, r, api_utils.Homepage(self.config_obj),
http.StatusTemporaryRedirect)
return
}

user_info, err := self.getUserDataFromAzure(ctx, r.FormValue("code"))
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand All @@ -154,7 +162,7 @@ func (self *AzureAuthenticator) oauthAzureCallback() http.Handler {
self.config_obj, self.authenticator,
&Claims{
Username: user_info.Mail,
})
}, r)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand Down
13 changes: 12 additions & 1 deletion api/authenticators/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"net/http"
"time"

"github.com/Velocidex/ordereddict"
jwt "github.com/golang-jwt/jwt/v4"
utils "www.velocidex.com/golang/velociraptor/api/utils"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/logging"
"www.velocidex.com/golang/velociraptor/services"
)

var (
Expand All @@ -20,7 +22,8 @@ You probably need to re-authenticate in a new tab or refresh this page.`)
func getSignedJWTTokenCookie(
config_obj *config_proto.Config,
authenticator *config_proto.Authenticator,
claims *Claims) (*http.Cookie, error) {
claims *Claims,
r *http.Request) (*http.Cookie, error) {
if config_obj.Frontend == nil {
return nil, errors.New("config has no Frontend")
}
Expand Down Expand Up @@ -50,6 +53,14 @@ func getSignedJWTTokenCookie(
return nil, err
}

// Log a successful login.
services.LogAudit(r.Context(),
config_obj, claims.Username, "Login",
ordereddict.NewDict().
Set("remote", r.RemoteAddr).
Set("authenticator", authenticator.Type).
Set("url", r.URL.Path))

// Sets the cookie on the browser so it is only valid from the
// base down.
return &http.Cookie{
Expand Down
2 changes: 1 addition & 1 deletion api/authenticators/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (self *GitHubAuthenticator) oauthGithubCallback() http.Handler {
self.config_obj, self.authenticator,
&Claims{
Username: user_info.Login,
})
}, r)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand Down
3 changes: 2 additions & 1 deletion api/authenticators/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (self *GoogleAuthenticator) oauthGoogleCallback() http.Handler {
self.config_obj, self.authenticator,
&Claims{
Username: user_info.Email,
})
}, r)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand Down Expand Up @@ -249,6 +249,7 @@ func (self *GoogleAuthenticator) getUserDataFromGoogle(
if err != nil {
return nil, fmt.Errorf("failed read response: %s", err.Error())
}

return contents, nil
}

Expand Down
4 changes: 2 additions & 2 deletions api/authenticators/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (self *OidcAuthenticator) oauthOidcCallback(
ctx, err := ClientContext(r.Context(), self.config_obj)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
Error("invalid client context of OIDC")
Error("invalid client context of OIDC: %v", err)
http.Redirect(w, r, api_utils.Homepage(self.config_obj),
http.StatusTemporaryRedirect)
return
Expand Down Expand Up @@ -238,7 +238,7 @@ func (self *OidcAuthenticator) oauthOidcCallback(
}

cookie, err := getSignedJWTTokenCookie(
self.config_obj, self.authenticator, claims)
self.config_obj, self.authenticator, claims, r)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand Down
2 changes: 1 addition & 1 deletion api/authenticators/oidc_cognito.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (self *OidcAuthenticatorCognito) oauthOidcCallback(
self.config_obj, self.authenticator,
&Claims{
Username: userInfo.Email,
})
}, r)
if err != nil {
logging.GetLogger(self.config_obj, &logging.GUIComponent).
WithFields(logrus.Fields{
Expand Down
Loading
Loading
0