-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Adding RSYNC auth #6410
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
Open
Mzack9999
wants to merge
7
commits into
dev
Choose a base branch
from
feat-6409-rsync-auth
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adding RSYNC auth #6410
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f5a141
adding min auth support
Mzack9999 663a8e9
adding unauth list modules + auth list files in module
Mzack9999 68605c2
example
Mzack9999 36e7701
Merge branch 'dev' into feat-6409-rsync-auth
Mzack9999 fd3c304
adding rsync test
Mzack9999 7b0d9af
Merge branch 'dev' into feat-6409-rsync-auth
Mzack9999 47f45d3
bump go.mod
Mzack9999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,13 @@ var jsTestcases = []TestCaseInfo{ | |
{Path: "protocols/javascript/ssh-server-fingerprint.yaml", TestCase: &javascriptSSHServerFingerprint{}, DisableOn: func() bool { return osutils.IsWindows() || osutils.IsOSX() }}, | ||
{Path: "protocols/javascript/net-multi-step.yaml", TestCase: &networkMultiStep{}}, | ||
{Path: "protocols/javascript/net-https.yaml", TestCase: &javascriptNetHttps{}}, | ||
{Path: "protocols/javascript/rsync-test.yaml", TestCase: &javascriptRsyncTest{}, DisableOn: func() bool { return osutils.IsWindows() || osutils.IsOSX() }}, | ||
} | ||
|
||
var ( | ||
redisResource *dockertest.Resource | ||
sshResource *dockertest.Resource | ||
rsyncResource *dockertest.Resource | ||
pool *dockertest.Pool | ||
defaultRetry = 3 | ||
) | ||
|
@@ -98,6 +100,38 @@ func (j *javascriptSSHServerFingerprint) Execute(filePath string) error { | |
return multierr.Combine(errs...) | ||
} | ||
|
||
type javascriptRsyncTest struct{} | ||
|
||
func (j *javascriptRsyncTest) Execute(filePath string) error { | ||
if rsyncResource == nil || pool == nil { | ||
// skip test as rsync is not running | ||
return nil | ||
} | ||
tempPort := rsyncResource.GetPort("873/tcp") | ||
finalURL := "localhost:" + tempPort | ||
defer purge(rsyncResource) | ||
errs := []error{} | ||
for i := 0; i < defaultRetry; i++ { | ||
results := []string{} | ||
var err error | ||
_ = pool.Retry(func() error { | ||
//let rsync server start | ||
time.Sleep(3 * time.Second) | ||
results, err = testutils.RunNucleiTemplateAndGetResults(filePath, finalURL, debug) | ||
return nil | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
if err := expectResultsCount(results, 1); err == nil { | ||
return nil | ||
} else { | ||
errs = append(errs, err) | ||
} | ||
} | ||
return multierr.Combine(errs...) | ||
} | ||
|
||
// purge any given resource if it is not nil | ||
func purge(resource *dockertest.Resource) { | ||
if resource != nil && pool != nil { | ||
|
@@ -163,4 +197,21 @@ func init() { | |
if err := sshResource.Expire(30); err != nil { | ||
log.Printf("Could not expire resource: %s", err) | ||
} | ||
|
||
// setup a temporary rsync server | ||
rsyncResource, err = pool.RunWithOptions(&dockertest.RunOptions{ | ||
Repository: "alpine", | ||
Tag: "latest", | ||
Cmd: []string{"sh", "-c", "apk add --no-cache rsync shadow && useradd -m rsyncuser && echo 'rsyncuser:mysecret' | chpasswd && echo 'rsyncuser:MySecret123' > /etc/rsyncd.secrets && chmod 600 /etc/rsyncd.secrets && echo -e '[data]\\n path = /data\\n comment = Local Rsync Share\\n read only = false\\n auth users = rsyncuser\\n secrets file = /etc/rsyncd.secrets' > /etc/rsyncd.conf && mkdir -p /data && exec rsync --daemon --no-detach --config=/etc/rsyncd.conf"}, | ||
Platform: "linux/amd64", | ||
}) | ||
if err != nil { | ||
log.Printf("Could not start Rsync resource: %s", err) | ||
return | ||
} | ||
// by default expire after 30 sec | ||
if err := rsyncResource.Expire(30); err != nil { | ||
log.Printf("Could not expire Rsync resource: %s", err) | ||
} | ||
|
||
Comment on lines
+201
to
+216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rsync port 873 isn’t exposed; GetPort("873/tcp") will be empty. Alpine image doesn’t EXPOSE 873, so no host port is published unless you set it explicitly. Expose and bind 873/tcp. Apply this diff in the run options: rsyncResource, err = pool.RunWithOptions(&dockertest.RunOptions{
Repository: "alpine",
Tag: "latest",
Cmd: []string{"sh", "-c", "apk add --no-cache rsync shadow && useradd -m rsyncuser && echo 'rsyncuser:mysecret' | chpasswd && echo 'rsyncuser:MySecret123' > /etc/rsyncd.secrets && chmod 600 /etc/rsyncd.secrets && echo -e '[data]\\n path = /data\\n comment = Local Rsync Share\\n read only = false\\n auth users = rsyncuser\\n secrets file = /etc/rsyncd.secrets' > /etc/rsyncd.conf && mkdir -p /data && exec rsync --daemon --no-detach --config=/etc/rsyncd.conf"},
+ ExposedPorts: []string{"873/tcp"},
+ PortBindings: map[docker.Port][]docker.PortBinding{
+ "873/tcp": {{HostIP: "0.0.0.0", HostPort: ""}},
+ },
Platform: "linux/amd64",
}) Also add the import: // at the top imports
"github.com/ory/dockertest/v3/docker" 🤖 Prompt for AI Agents
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
id: rsync-test | ||
|
||
info: | ||
name: Rsync Test | ||
author: pdteam | ||
severity: info | ||
|
||
javascript: | ||
- code: | | ||
const rsync = require('nuclei/rsync'); | ||
rsync.IsRsync(Host, Port); | ||
|
||
args: | ||
Host: "{{Host}}" | ||
Port: "873" | ||
|
||
matchers: | ||
- type: dsl | ||
dsl: | ||
- "success == true" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Sanity-check that the template matches container credentials and module.
Ensure
protocols/javascript/rsync-test.yaml
uses:🏁 Script executed:
Length of output: 322
🏁 Script executed:
Length of output: 182
Critical: Verify existence of the referenced YAML template
It appears the integration test is pointing at
protocols/javascript/rsync-test.yaml
, but no such file is present in the repository. This will cause test discovery to fail.• File: cmd/integration-test/javascript.go
Line: 18
Action required:
Path
accordingly, orprotocols/javascript/rsync-test.yaml
template (ensuring it usesuser: rsyncuser
,pass: MySecret123
,module: data
, and the correcttarget
).🤖 Prompt for AI Agents