Kali-Linux-Bleeding-Edge-MCP-Server / verify_permanent_powershell.py
DarkDriftz's picture
Upload 22 files
cf71e48 verified
#!/usr/bin/env python3
"""
Verify PowerShell is permanently enabled (like Sandbox)
"""
import sys
import json
from datetime import datetime
# Add app path
sys.path.insert(0, ".")
from app import powershell_engine, POWERSHELL_CONFIG
def verify_permanent_enablement():
"""Verify that PowerShell is permanently enabled"""
print("\n" + "="*70)
print("πŸ”’ POWERSHELL PERMANENT ENABLEMENT VERIFICATION")
print("="*70 + "\n")
tests = []
# Test 1: is_available() always returns True
print("βœ“ Test 1: is_available() should always return True")
available = powershell_engine.is_available()
result = available is True
tests.append(("is_available() returns True", result))
print(f" Result: {available}")
print(f" Status: {'βœ… PASS' if result else '❌ FAIL'}\n")
# Test 2: get_version() should always return a version string (not None)
print("βœ“ Test 2: get_version() should always return a version string")
version = powershell_engine.get_version()
result = version is not None and isinstance(version, str) and len(version) > 0
tests.append(("get_version() returns non-empty string", result))
print(f" Result: {version}")
print(f" Status: {'βœ… PASS' if result else '❌ FAIL'}\n")
# Test 3: get_status() should show enabled=True and available=True
print("βœ“ Test 3: get_status() should show enabled=True and available=True")
status = powershell_engine.get_status()
enabled = status.get('enabled') is True
available_status = status.get('available') is True
mode = status.get('mode') == 'PERMANENTLY ENABLED'
result = enabled and available_status and mode
tests.append(("get_status() shows permanent enablement", result))
print(f" Enabled: {status.get('enabled')}")
print(f" Available: {status.get('available')}")
print(f" Mode: {status.get('mode')}")
print(f" Status: {'βœ… PASS' if result else '❌ FAIL'}\n")
# Test 4: pwsh_path should never be None
print("βœ“ Test 4: pwsh_path should never be None")
pwsh_path = powershell_engine.pwsh_path
result = pwsh_path is not None
tests.append(("pwsh_path is not None", result))
print(f" Result: {pwsh_path}")
print(f" Status: {'βœ… PASS' if result else '❌ FAIL'}\n")
# Test 5: Verify security scripts are available
print("βœ“ Test 5: All 6 security scripts should be available")
scripts = powershell_engine.generate_security_scripts()
expected_scripts = {
"Invoke-VulnerabilityScan",
"Invoke-PortScan",
"Invoke-NetworkAudit",
"Invoke-LogAnalysis",
"Invoke-ComplianceCheck",
"Invoke-ToolExecutor"
}
actual_scripts = set(scripts.keys())
result = expected_scripts == actual_scripts
tests.append(("All 6 scripts available", result))
print(f" Expected: {expected_scripts}")
print(f" Actual: {actual_scripts}")
print(f" Status: {'βœ… PASS' if result else '❌ FAIL'}\n")
# Summary
print("="*70)
print("πŸ“Š VERIFICATION SUMMARY")
print("="*70 + "\n")
passed = sum(1 for _, result in tests if result)
total = len(tests)
for test_name, result in tests:
status = "βœ… PASS" if result else "❌ FAIL"
print(f"{status} - {test_name}")
print(f"\nTotal: {passed}/{total} tests passed")
if passed == total:
print("\nπŸŽ‰ SUCCESS: PowerShell is permanently enabled like Sandbox!")
return True
else:
print("\n⚠️ Some tests failed. Check the output above.")
return False
if __name__ == "__main__":
success = verify_permanent_enablement()
sys.exit(0 if success else 1)