|
1 | 1 | package cmd |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "encoding/json" |
5 | | - "fmt" |
6 | | - "net/http" |
7 | | - "os" |
8 | | - "strings" |
9 | | - "time" |
10 | | - |
11 | | - "github.com/CodeMonkeyCybersecurity/shells/internal/config" |
12 | | - "github.com/CodeMonkeyCybersecurity/shells/internal/logger" |
13 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/common" |
14 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/discovery" |
15 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/federation" |
16 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/oauth2" |
17 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/saml" |
18 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/auth/webauthn" |
19 | | - "github.com/CodeMonkeyCybersecurity/shells/pkg/types" |
20 | | - "github.com/google/uuid" |
21 | | - "github.com/spf13/cobra" |
| 4 | + "encoding/json" |
| 5 | + "fmt" |
| 6 | + "net/http" |
| 7 | + "os" |
| 8 | + "strings" |
| 9 | + "time" |
| 10 | + |
| 11 | + "github.com/CodeMonkeyCybersecurity/artemis/internal/config" |
| 12 | + "github.com/CodeMonkeyCybersecurity/artemis/internal/logger" |
| 13 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/common" |
| 14 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/discovery" |
| 15 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/federation" |
| 16 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/oauth2" |
| 17 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/saml" |
| 18 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/auth/webauthn" |
| 19 | + "github.com/CodeMonkeyCybersecurity/artemis/pkg/types" |
| 20 | + "github.com/google/uuid" |
| 21 | + "github.com/spf13/cobra" |
22 | 22 | ) |
23 | 23 |
|
| 24 | +type authLoggerAdapter struct { |
| 25 | + base *logger.Logger |
| 26 | +} |
| 27 | + |
| 28 | +func (a *authLoggerAdapter) Info(msg string, keysAndValues ...interface{}) { |
| 29 | + if a.base != nil { |
| 30 | + a.base.Infow(msg, keysAndValues...) |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +func (a *authLoggerAdapter) Error(msg string, keysAndValues ...interface{}) { |
| 35 | + if a.base != nil { |
| 36 | + a.base.Errorw(msg, keysAndValues...) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +func (a *authLoggerAdapter) Debug(msg string, keysAndValues ...interface{}) { |
| 41 | + if a.base != nil { |
| 42 | + a.base.Debugw(msg, keysAndValues...) |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +func adaptAuthLogger(l *logger.Logger) common.Logger { |
| 47 | + if l == nil { |
| 48 | + return nil |
| 49 | + } |
| 50 | + return &authLoggerAdapter{base: l} |
| 51 | +} |
| 52 | + |
24 | 53 | // authCmd represents the auth command |
25 | 54 | var authCmd = &cobra.Command{ |
26 | | - Use: "auth", |
27 | | - Short: "Test authentication and identity systems", |
28 | | - Long: `Comprehensive authentication security testing framework for modern authentication protocols. |
| 55 | + Use: "auth", |
| 56 | + Short: "Test authentication and identity systems", |
| 57 | + Long: `Comprehensive authentication security testing framework for modern authentication protocols. |
29 | 58 |
|
30 | 59 | This command provides advanced testing capabilities for: |
31 | 60 | - SAML (including Golden SAML attacks) |
@@ -98,14 +127,14 @@ Examples: |
98 | 127 | } |
99 | 128 |
|
100 | 129 | // Also run legacy discovery for federation |
101 | | - crossAnalyzer := common.NewCrossProtocolAnalyzer(log) |
| 130 | + crossAnalyzer := common.NewCrossProtocolAnalyzer(adaptAuthLogger(log)) |
102 | 131 | legacyConfig, _ := crossAnalyzer.AnalyzeTarget(target) |
103 | 132 |
|
104 | 133 | domain := extractDomain(target) |
105 | 134 | httpClient := &http.Client{ |
106 | 135 | Timeout: 30 * time.Second, |
107 | 136 | } |
108 | | - discoverer := federation.NewFederationDiscoverer(httpClient, log) |
| 137 | + discoverer := federation.NewFederationDiscoverer(httpClient, adaptAuthLogger(log)) |
109 | 138 | federationResult := discoverer.DiscoverAllProviders(domain) |
110 | 139 |
|
111 | 140 | // Create combined result |
@@ -312,14 +341,14 @@ Examples: |
312 | 341 | ) |
313 | 342 |
|
314 | 343 | // Analyze target for vulnerabilities |
315 | | - crossAnalyzer := common.NewCrossProtocolAnalyzer(log) |
| 344 | + crossAnalyzer := common.NewCrossProtocolAnalyzer(adaptAuthLogger(log)) |
316 | 345 | config, analyzeErr := crossAnalyzer.AnalyzeTarget(target) |
317 | 346 | if analyzeErr != nil { |
318 | 347 | return fmt.Errorf("target analysis failed: %w", analyzeErr) |
319 | 348 | } |
320 | 349 |
|
321 | 350 | // Find attack chains |
322 | | - chainAnalyzer := common.NewAuthChainAnalyzer(log) |
| 351 | + chainAnalyzer := common.NewAuthChainAnalyzer(adaptAuthLogger(log)) |
323 | 352 | chains := chainAnalyzer.FindBypassChains(config.Configuration, config.Vulnerabilities) |
324 | 353 |
|
325 | 354 | // Create result |
@@ -473,22 +502,22 @@ type ChainSummary struct { |
473 | 502 | // Test runner functions |
474 | 503 |
|
475 | 504 | func runSAMLTests(target string, log *logger.Logger) (*common.AuthReport, error) { |
476 | | - scanner := saml.NewSAMLScanner(log) |
| 505 | + scanner := saml.NewSAMLScanner(adaptAuthLogger(log)) |
477 | 506 | return scanner.Scan(target, map[string]interface{}{}) |
478 | 507 | } |
479 | 508 |
|
480 | 509 | func runOAuth2Tests(target string, log *logger.Logger) (*common.AuthReport, error) { |
481 | | - scanner := oauth2.NewOAuth2Scanner(log) |
| 510 | + scanner := oauth2.NewOAuth2Scanner(adaptAuthLogger(log)) |
482 | 511 | return scanner.Scan(target, map[string]interface{}{}) |
483 | 512 | } |
484 | 513 |
|
485 | 514 | func runWebAuthnTests(target string, log *logger.Logger) (*common.AuthReport, error) { |
486 | | - scanner := webauthn.NewWebAuthnScanner(log) |
| 515 | + scanner := webauthn.NewWebAuthnScanner(adaptAuthLogger(log)) |
487 | 516 | return scanner.Scan(target, map[string]interface{}{}) |
488 | 517 | } |
489 | 518 |
|
490 | 519 | func runAllTests(target string, log *logger.Logger) (*common.AuthReport, error) { |
491 | | - crossAnalyzer := common.NewCrossProtocolAnalyzer(log) |
| 520 | + crossAnalyzer := common.NewCrossProtocolAnalyzer(adaptAuthLogger(log)) |
492 | 521 | return crossAnalyzer.AnalyzeTarget(target) |
493 | 522 | } |
494 | 523 |
|
|
0 commit comments