@@ -15,6 +15,7 @@ var jsTestcases = []TestCaseInfo{
1515 {Path : "protocols/javascript/ssh-server-fingerprint.yaml" , TestCase : & javascriptSSHServerFingerprint {}, DisableOn : func () bool { return osutils .IsWindows () || osutils .IsOSX () }},
1616 {Path : "protocols/javascript/net-multi-step.yaml" , TestCase : & networkMultiStep {}},
1717 {Path : "protocols/javascript/net-https.yaml" , TestCase : & javascriptNetHttps {}},
18+ {Path : "protocols/javascript/rsync-test.yaml" , TestCase : & javascriptRsyncTest {}, DisableOn : func () bool { return osutils .IsWindows () || osutils .IsOSX () }},
1819 {Path : "protocols/javascript/oracle-auth-test.yaml" , TestCase : & javascriptOracleAuthTest {}, DisableOn : func () bool { return osutils .IsWindows () || osutils .IsOSX () }},
1920 {Path : "protocols/javascript/vnc-pass-brute.yaml" , TestCase : & javascriptVncPassBrute {}},
2021 {Path : "protocols/javascript/postgres-pass-brute.yaml" , TestCase : & javascriptPostgresPassBrute {}, DisableOn : func () bool { return osutils .IsWindows () || osutils .IsOSX () }},
3031 vncResource * dockertest.Resource
3132 postgresResource * dockertest.Resource
3233 mysqlResource * dockertest.Resource
34+ rsyncResource * dockertest.Resource
3335 pool * dockertest.Pool
3436 defaultRetry = 3
3537)
@@ -124,7 +126,7 @@ func (j *javascriptOracleAuthTest) Execute(filePath string) error {
124126 results := []string {}
125127 var err error
126128 _ = pool .Retry (func () error {
127- //let ssh server start
129+ // let oracle server start
128130 time .Sleep (3 * time .Second )
129131 results , err = testutils .RunNucleiTemplateAndGetResults (filePath , finalURL , debug )
130132 return nil
@@ -258,6 +260,38 @@ func (j *javascriptNoPortArgs) Execute(filePath string) error {
258260 return expectResultsCount (results , 1 )
259261}
260262
263+ type javascriptRsyncTest struct {}
264+
265+ func (j * javascriptRsyncTest ) Execute (filePath string ) error {
266+ if rsyncResource == nil || pool == nil {
267+ // skip test as rsync is not running
268+ return nil
269+ }
270+ tempPort := rsyncResource .GetPort ("873/tcp" )
271+ finalURL := "localhost:" + tempPort
272+ defer purge (rsyncResource )
273+ errs := []error {}
274+ for i := 0 ; i < defaultRetry ; i ++ {
275+ results := []string {}
276+ var err error
277+ _ = pool .Retry (func () error {
278+ //let rsync server start
279+ time .Sleep (3 * time .Second )
280+ results , err = testutils .RunNucleiTemplateAndGetResults (filePath , finalURL , debug )
281+ return nil
282+ })
283+ if err != nil {
284+ return err
285+ }
286+ if err := expectResultsCount (results , 1 ); err == nil {
287+ return nil
288+ } else {
289+ errs = append (errs , err )
290+ }
291+ }
292+ return multierr .Combine (errs ... )
293+ }
294+
261295// purge any given resource if it is not nil
262296func purge (resource * dockertest.Resource ) {
263297 if resource != nil && pool != nil {
@@ -397,4 +431,20 @@ func init() {
397431 if err := mysqlResource .Expire (30 ); err != nil {
398432 log .Printf ("Could not expire mysql resource: %s" , err )
399433 }
434+
435+ // setup a temporary rsync server
436+ rsyncResource , err = pool .RunWithOptions (& dockertest.RunOptions {
437+ Repository : "alpine" ,
438+ Tag : "latest" ,
439+ 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" },
440+ Platform : "linux/amd64" ,
441+ })
442+ if err != nil {
443+ log .Printf ("Could not start Rsync resource: %s" , err )
444+ return
445+ }
446+ // by default expire after 30 sec
447+ if err := rsyncResource .Expire (30 ); err != nil {
448+ log .Printf ("Could not expire Rsync resource: %s" , err )
449+ }
400450}
0 commit comments