-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_write_access_check.py
More file actions
57 lines (45 loc) · 1.83 KB
/
Copy pathrun_write_access_check.py
File metadata and controls
57 lines (45 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""Run only the policy-gated unauthenticated write-access check.
Usage:
python run_write_access_check.py --config config.yaml
The config must enable both `write_access_test.enabled` and
`engagement_policy.allow_write_tests`. No target is hardcoded here.
"""
import argparse
import logging
from pentest.cleanup_ledger import CleanupRecoveryLedger
from pentest.config import load_config
from pentest.phases.write_access import WriteAccessPhase
from pentest.policy import EngagementPolicy, PolicyViolation
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(name)s: %(message)s")
def main():
parser = argparse.ArgumentParser(description="Policy-gated write-access check")
parser.add_argument("--config", required=True)
args = parser.parse_args()
config = load_config(args.config)
policy = EngagementPolicy(config.engagement_policy)
policy.validate_static_scope(config)
if not config.write_access_test.enabled:
raise PolicyViolation("write_access_test.enabled must be true for this command.")
if not policy.allows_write_tests():
raise PolicyViolation(
"engagement_policy.allow_write_tests must be true for this command."
)
policy.authorize_network_operations(4)
ledger = CleanupRecoveryLedger(
config.output_cleanup_ledger_path(), policy.policy_hash
)
findings = WriteAccessPhase(
config.write_access_test, recovery_ledger=ledger
).run()
print(f"Findings: {len(findings)}")
for finding in findings:
print(f"[{finding.severity}] {finding.title}")
print(f"Evidence: {finding.evidence}")
if not findings:
print(
"No finding was produced. The endpoint may be gated, unreachable, "
"or inconclusive; review the logs."
)
if __name__ == "__main__":
main()