pwn 0.5.795 → 0.5.798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/bin/pwn_autoinc_version +4 -5
- data/bin/pwn_web_cache_deception +40 -29
- data/documentation/AWS.md +15 -5
- data/documentation/Diagrams.md +1 -1
- data/documentation/Home.md +2 -2
- data/documentation/How-PWN-Works.md +1 -1
- data/documentation/Mission-Cancellation.md +6 -4
- data/documentation/Operability.md +1 -1
- data/documentation/What-is-PWN.md +1 -1
- data/documentation/diagrams/aws-cloud-security.svg +1 -1
- data/documentation/diagrams/dot/aws-cloud-security.dot +1 -1
- data/documentation/diagrams/dot/network-infra-testing.dot +1 -1
- data/documentation/diagrams/network-infra-testing.svg +1 -1
- data/etc/default_cron/session_cleanup.rb +84 -51
- data/etc/default_skills/pwn/ai/agent/mission_namespace/SKILL.md +6 -4
- data/lib/pwn/ai/agent/assembly.rb +0 -2
- data/lib/pwn/ai/agent/btc.rb +0 -2
- data/lib/pwn/ai/agent/burp_suite.rb +0 -2
- data/lib/pwn/ai/agent/curriculum.rb +2 -2
- data/lib/pwn/ai/agent/dispatch.rb +3 -0
- data/lib/pwn/ai/agent/engagement.rb +96 -41
- data/lib/pwn/ai/agent/extrospection/osint/bridges.rb +2 -0
- data/lib/pwn/ai/agent/extrospection.rb +50 -13
- data/lib/pwn/ai/agent/gqrx.rb +0 -2
- data/lib/pwn/ai/agent/hacker_one.rb +0 -2
- data/lib/pwn/ai/agent/learning.rb +45 -13
- data/lib/pwn/ai/agent/loop.rb +16 -11
- data/lib/pwn/ai/agent/metrics.rb +1 -1
- data/lib/pwn/ai/agent/mission.rb +6 -3
- data/lib/pwn/ai/agent/mission_namespace.rb +70 -14
- data/lib/pwn/ai/agent/policy.rb +1 -1
- data/lib/pwn/ai/agent/policy_evaluation.rb +2 -2
- data/lib/pwn/ai/agent/reflect.rb +1 -0
- data/lib/pwn/ai/agent/request_runtime.rb +1 -1
- data/lib/pwn/ai/agent/reward.rb +155 -53
- data/lib/pwn/ai/agent/sast.rb +0 -2
- data/lib/pwn/ai/agent/task_dag.rb +5 -3
- data/lib/pwn/ai/agent/task_summarizer.rb +21 -11
- data/lib/pwn/ai/agent/tool_guard.rb +19 -0
- data/lib/pwn/ai/agent/tools/ruby_eval.rb +1 -1
- data/lib/pwn/ai/agent/tools/verify.rb +7 -3
- data/lib/pwn/ai/agent/transparent_browser.rb +0 -2
- data/lib/pwn/ai/agent/turn_finalizer.rb +3 -0
- data/lib/pwn/ai/anthropic.rb +3 -3
- data/lib/pwn/ai/context.rb +2 -1
- data/lib/pwn/ai/gemini.rb +7 -5
- data/lib/pwn/ai/grok.rb +37 -18
- data/lib/pwn/ai/mcp.rb +17 -5
- data/lib/pwn/ai/ollama.rb +76 -35
- data/lib/pwn/ai/open_ai.rb +7 -19
- data/lib/pwn/ai/open_web_ui.rb +76 -40
- data/lib/pwn/aws/cloud_search_domain.rb +6 -0
- data/lib/pwn/aws/iam.rb +2 -2
- data/lib/pwn/aws/workspaces.rb +2 -2
- data/lib/pwn/aws.rb +0 -5
- data/lib/pwn/bounty/lifecycle_authz_replay.rb +1 -1
- data/lib/pwn/config.rb +17 -10
- data/lib/pwn/corpus.rb +33 -5
- data/lib/pwn/cron.rb +60 -17
- data/lib/pwn/driver.rb +2 -3
- data/lib/pwn/engagement.rb +28 -10
- data/lib/pwn/ffi/capstone.rb +3 -2
- data/lib/pwn/ffi/fftw.rb +8 -6
- data/lib/pwn/ffi/keystone.rb +3 -2
- data/lib/pwn/ffi/soapy_sdr.rb +10 -6
- data/lib/pwn/json_text.rb +25 -13
- data/lib/pwn/memory_index.rb +6 -4
- data/lib/pwn/module_skills.rb +3 -1
- data/lib/pwn/plugins/aflplusplus.rb +1 -0
- data/lib/pwn/plugins/ai_sandbox.rb +42 -10
- data/lib/pwn/plugins/android.rb +429 -466
- data/lib/pwn/plugins/artifact_registry.rb +12 -2
- data/lib/pwn/plugins/assembly.rb +9 -42
- data/lib/pwn/plugins/authentication_helper.rb +4 -3
- data/lib/pwn/plugins/baresip.rb +70 -28
- data/lib/pwn/plugins/binary_analysis.rb +14 -5
- data/lib/pwn/plugins/binary_parser.rb +42 -7
- data/lib/pwn/plugins/black_duck_binary_analysis.rb +3 -3
- data/lib/pwn/plugins/burp_suite.rb +15 -12
- data/lib/pwn/plugins/bus_pirate.rb +3 -7
- data/lib/pwn/plugins/char.rb +9 -3
- data/lib/pwn/plugins/credit_card.rb +7 -0
- data/lib/pwn/plugins/dao_ldap.rb +2 -2
- data/lib/pwn/plugins/dao_mongo.rb +1 -1
- data/lib/pwn/plugins/debugger.rb +1 -1
- data/lib/pwn/plugins/defect_dojo.rb +7 -3
- data/lib/pwn/plugins/detect_os.rb +1 -1
- data/lib/pwn/plugins/detonate.rb +9 -19
- data/lib/pwn/plugins/exploit_db.rb +1 -1
- data/lib/pwn/plugins/file_fu.rb +4 -1
- data/lib/pwn/plugins/findings.rb +76 -2
- data/lib/pwn/plugins/fuzz.rb +12 -3
- data/lib/pwn/plugins/gdb.rb +7 -2
- data/lib/pwn/plugins/gdbmi.rb +10 -6
- data/lib/pwn/plugins/git.rb +18 -13
- data/lib/pwn/plugins/github.rb +11 -6
- data/lib/pwn/plugins/google_workspace.rb +11 -3
- data/lib/pwn/plugins/hacker_one.rb +5 -1
- data/lib/pwn/plugins/httpx.rb +24 -8
- data/lib/pwn/plugins/ip_info.rb +11 -8
- data/lib/pwn/plugins/irc.rb +73 -45
- data/lib/pwn/plugins/jenkins.rb +2 -2
- data/lib/pwn/plugins/jira_data_center.rb +13 -6
- data/lib/pwn/plugins/jobs.rb +62 -4
- data/lib/pwn/plugins/log.rb +1 -1
- data/lib/pwn/plugins/monkey_patch.rb +1 -1
- data/lib/pwn/plugins/msr206.rb +157 -182
- data/lib/pwn/plugins/nessus_cloud.rb +2 -2
- data/lib/pwn/plugins/nexpose_vuln_scan.rb +44 -33
- data/lib/pwn/plugins/nuclei.rb +24 -8
- data/lib/pwn/plugins/ocr.rb +3 -1
- data/lib/pwn/plugins/open_api.rb +0 -4
- data/lib/pwn/plugins/openvas.rb +31 -43
- data/lib/pwn/plugins/packet.rb +40 -25
- data/lib/pwn/plugins/pony.rb +2 -2
- data/lib/pwn/plugins/preflight_checker.rb +1 -1
- data/lib/pwn/plugins/process_tube.rb +17 -2
- data/lib/pwn/plugins/ps.rb +6 -1
- data/lib/pwn/plugins/pwn_logger.rb +37 -1
- data/lib/pwn/plugins/repl/ai.rb +1 -0
- data/lib/pwn/plugins/repl/ai_console.rb +18 -6
- data/lib/pwn/plugins/repl/mesh.rb +51 -28
- data/lib/pwn/plugins/sbom.rb +59 -27
- data/lib/pwn/plugins/scannable_codes.rb +3 -1
- data/lib/pwn/plugins/serial.rb +102 -44
- data/lib/pwn/plugins/shodan.rb +4 -10
- data/lib/pwn/plugins/sock.rb +16 -11
- data/lib/pwn/plugins/ssn.rb +3 -1
- data/lib/pwn/plugins/transparent_browser.rb +43 -3
- data/lib/pwn/plugins/vault.rb +92 -30
- data/lib/pwn/plugins/vin.rb +2 -1
- data/lib/pwn/plugins/vsphere.rb +2 -1
- data/lib/pwn/plugins/xxd.rb +3 -5
- data/lib/pwn/plugins/yubikey/security_domain/scp.rb +4 -0
- data/lib/pwn/plugins/yubikey/transport.rb +42 -11
- data/lib/pwn/plugins/yubikey.rb +21 -6
- data/lib/pwn/plugins/zaproxy.rb +3 -4
- data/lib/pwn/reports/ai_red_team.rb +4 -4
- data/lib/pwn/reports/pdf.rb +9 -5
- data/lib/pwn/reports/sast.rb +4 -4
- data/lib/pwn/sast/keystore.rb +2 -2
- data/lib/pwn/sast/logger.rb +1 -1
- data/lib/pwn/sast/php_type_juggling.rb +3 -6
- data/lib/pwn/sast/pom_version.rb +12 -6
- data/lib/pwn/sast/port.rb +1 -1
- data/lib/pwn/sast/sql.rb +3 -7
- data/lib/pwn/sast/test_case_engine.rb +62 -16
- data/lib/pwn/sast/type_script_type_juggling.rb +3 -6
- data/lib/pwn/sdr/decoder/base.rb +8 -0
- data/lib/pwn/sdr/decoder/lora.rb +1 -1
- data/lib/pwn/sdr/flipper_zero.rb +4 -7
- data/lib/pwn/sdr/gqrx.rb +35 -16
- data/lib/pwn/sdr/son_micro_rfid.rb +44 -26
- data/lib/pwn/sdr.rb +1 -1
- data/lib/pwn/session_trace.rb +7 -2
- data/lib/pwn/sessions.rb +310 -41
- data/lib/pwn/setup.rb +4 -3
- data/lib/pwn/version.rb +1 -1
- data/lib/pwn/www/app_cobalt_io.rb +14 -2
- data/lib/pwn/www/bing.rb +13 -1
- data/lib/pwn/www/bug_crowd.rb +14 -2
- data/lib/pwn/www/checkip.rb +13 -1
- data/lib/pwn/www/coinbase_pro.rb +14 -2
- data/lib/pwn/www/duckduckgo.rb +13 -1
- data/lib/pwn/www/facebook.rb +14 -2
- data/lib/pwn/www/github.rb +14 -2
- data/lib/pwn/www/google.rb +13 -1
- data/lib/pwn/www/hacker_one.rb +117 -33
- data/lib/pwn/www/linkedin.rb +14 -2
- data/lib/pwn/www/pandora.rb +14 -2
- data/lib/pwn/www/pastebin.rb +13 -1
- data/lib/pwn/www/paypal.rb +16 -4
- data/lib/pwn/www/synack.rb +14 -2
- data/lib/pwn/www/torch.rb +17 -3
- data/lib/pwn/www/trading_view.rb +14 -2
- data/lib/pwn/www/twitter.rb +14 -2
- data/lib/pwn/www/uber.rb +14 -2
- data/lib/pwn/www/upwork.rb +14 -2
- data/lib/pwn/www/wayback_machine.rb +16 -2
- data/lib/pwn/www/youtube.rb +13 -1
- data/lib/pwn.rb +11 -0
- data/pwn.gemspec +4 -0
- data/spec/conventions_spec.rb +43 -0
- data/spec/integration/authentication_helper_oath_spec.rb +1 -1
- data/spec/integration/autoinc_lifecycle_supplement_spec.rb +47 -0
- data/spec/integration/gemspec_deleted_files_spec.rb +43 -0
- data/spec/integration/harness_evaluation_spec.rb +22 -31
- data/spec/integration/harness_live_spec.rb +8 -18
- data/spec/integration/spec_curriculum_isolation_spec.rb +41 -0
- data/spec/integration/verify_acceptance_eui_regression_spec.rb +162 -0
- data/spec/integration/web_cache_lifecycle_closure_spec.rb +89 -0
- data/spec/integration/web_cache_lifecycle_supplement_spec.rb +70 -0
- data/spec/lib/pwn/ai/agent/analysis_errors_regression_spec.rb +33 -0
- data/spec/lib/pwn/ai/agent/curriculum_cooldown_regression_spec.rb +19 -0
- data/spec/lib/pwn/ai/agent/curriculum_spec.rb +2 -0
- data/spec/lib/pwn/ai/agent/engagement_boundary_regression_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/engagement_dispatch_review_spec.rb +82 -0
- data/spec/lib/pwn/ai/agent/engagement_roe_regression_spec.rb +25 -0
- data/spec/lib/pwn/ai/agent/engagement_scope_regression_spec.rb +37 -0
- data/spec/lib/pwn/ai/agent/extrospection/osint/bridges_spec.rb +4 -0
- data/spec/lib/pwn/ai/agent/extrospection_input_regression_spec.rb +31 -0
- data/spec/lib/pwn/ai/agent/extrospection_review_spec.rb +61 -0
- data/spec/lib/pwn/ai/agent/extrospection_serial_review_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/extrospection_spec.rb +9 -0
- data/spec/lib/pwn/ai/agent/extrospection_verification_regression_spec.rb +39 -0
- data/spec/lib/pwn/ai/agent/learning_last_answer_regression_spec.rb +32 -0
- data/spec/lib/pwn/ai/agent/learning_lifecycle_closure_spec.rb +84 -0
- data/spec/lib/pwn/ai/agent/learning_prune_regression_spec.rb +17 -0
- data/spec/lib/pwn/ai/agent/learning_spec.rb +2 -1
- data/spec/lib/pwn/ai/agent/loop_execution_audit_spec.rb +30 -0
- data/spec/lib/pwn/ai/agent/metrics_usage_regression_spec.rb +20 -0
- data/spec/lib/pwn/ai/agent/mission_execution_audit_spec.rb +27 -0
- data/spec/lib/pwn/ai/agent/mission_namespace_spec.rb +218 -18
- data/spec/lib/pwn/ai/agent/policy_confidence_regression_spec.rb +16 -0
- data/spec/lib/pwn/ai/agent/policy_evaluation_spec.rb +1 -1
- data/spec/lib/pwn/ai/agent/policy_evaluation_tmp_regression_spec.rb +36 -0
- data/spec/lib/pwn/ai/agent/reflect_model_regression_spec.rb +15 -0
- data/spec/lib/pwn/ai/agent/request_runtime_execution_audit_spec.rb +43 -0
- data/spec/lib/pwn/ai/agent/reward_binding_review_spec.rb +129 -0
- data/spec/lib/pwn/ai/agent/reward_dispatch_review_spec.rb +154 -0
- data/spec/lib/pwn/ai/agent/reward_envelope_regression_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/reward_turn_regression_spec.rb +40 -0
- data/spec/lib/pwn/ai/agent/swarm_spec.rb +2 -2
- data/spec/lib/pwn/ai/agent/task_dag_execution_audit_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/task_summarizer_failure_regression_spec.rb +26 -0
- data/spec/lib/pwn/ai/agent/tools/verify_execution_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/context_range_audit_spec.rb +24 -0
- data/spec/lib/pwn/ai/gemini_roundtrip_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/grok_reasoning_effort_spec.rb +43 -0
- data/spec/lib/pwn/ai/mcp_session_audit_spec.rb +36 -0
- data/spec/lib/pwn/ai/ollama_spec.rb +6 -11
- data/spec/lib/pwn/ai/open_web_ui_spec.rb +6 -11
- data/spec/lib/pwn/ai/provider_history_audit_spec.rb +44 -0
- data/spec/lib/pwn/ai/provider_operations_audit_spec.rb +53 -0
- data/spec/lib/pwn/ai/provider_review_history_stream_regression_spec.rb +143 -0
- data/spec/lib/pwn/ai/provider_review_tls_regression_spec.rb +62 -0
- data/spec/lib/pwn/ai/provider_stream_audit_spec.rb +49 -0
- data/spec/lib/pwn/aws/iam_decoding_regression_spec.rb +23 -0
- data/spec/lib/pwn/aws/services_runtime_regression_spec.rb +51 -0
- data/spec/lib/pwn/aws_spec.rb +6 -0
- data/spec/lib/pwn/banner_operational_audit_spec.rb +105 -0
- data/spec/lib/pwn/bounty/lifecycle_authz_replay_spec.rb +17 -0
- data/spec/lib/pwn/config_redaction_regression_spec.rb +24 -0
- data/spec/lib/pwn/config_skills_regression_spec.rb +38 -0
- data/spec/lib/pwn/corpus_core_review_regression_spec.rb +96 -0
- data/spec/lib/pwn/corpus_spec.rb +13 -0
- data/spec/lib/pwn/cron_core_review_regression_spec.rb +95 -0
- data/spec/lib/pwn/cron_execution_spec.rb +75 -0
- data/spec/lib/pwn/driver_core_review_regression_spec.rb +38 -0
- data/spec/lib/pwn/driver_spec.rb +13 -0
- data/spec/lib/pwn/engagement_core_review_regression_spec.rb +88 -0
- data/spec/lib/pwn/engagement_storage_regression_spec.rb +44 -0
- data/spec/lib/pwn/ffi/capstone_spec.rb +19 -0
- data/spec/lib/pwn/ffi/fftw_spec.rb +19 -0
- data/spec/lib/pwn/ffi/keystone_spec.rb +13 -0
- data/spec/lib/pwn/ffi/soapy_sdr_spec.rb +13 -0
- data/spec/lib/pwn/json_schemer_regexp_parser_spec.rb +12 -0
- data/spec/lib/pwn/json_text_spec.rb +25 -0
- data/spec/lib/pwn/memory_index_spec.rb +23 -0
- data/spec/lib/pwn/module_skills_parsing_regression_spec.rb +34 -0
- data/spec/lib/pwn/module_skills_spec.rb +11 -1
- data/spec/lib/pwn/plugins/ai_sandbox_boundary_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +10 -18
- data/spec/lib/pwn/plugins/android_review_fixes_spec.rb +121 -0
- data/spec/lib/pwn/plugins/android_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/api_import_namespace_audit_spec.rb +49 -0
- data/spec/lib/pwn/plugins/artifact_registry_namespace_audit_spec.rb +20 -0
- data/spec/lib/pwn/plugins/artifact_registry_review_fixes_spec.rb +63 -0
- data/spec/lib/pwn/plugins/assembly_namespace_audit_spec.rb +16 -0
- data/spec/lib/pwn/plugins/assembly_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/authentication_helper_spec.rb +14 -0
- data/spec/lib/pwn/plugins/baresip_review_fixes_spec.rb +127 -0
- data/spec/lib/pwn/plugins/baresip_transport_audit_spec.rb +59 -0
- data/spec/lib/pwn/plugins/binary_analysis_process_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/black_duck_namespace_audit_spec.rb +25 -0
- data/spec/lib/pwn/plugins/burp_suite_har_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/plugins/burp_suite_import_review_fixes_spec.rb +62 -0
- data/spec/lib/pwn/plugins/burp_suite_namespace_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/bus_pirate_transport_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/file_fu_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/findings_structured_spec.rb +1 -1
- data/spec/lib/pwn/plugins/gdbmi_namespace_audit_spec.rb +28 -0
- data/spec/lib/pwn/plugins/gdbmi_review_fixes_spec.rb +73 -0
- data/spec/lib/pwn/plugins/github_argv_review_spec.rb +49 -0
- data/spec/lib/pwn/plugins/google_workspace_provider_review_oauth_spec.rb +80 -0
- data/spec/lib/pwn/plugins/irc_review_fixes_spec.rb +92 -0
- data/spec/lib/pwn/plugins/irc_transport_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/jenkins_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/jira_data_center_namespace_audit_spec.rb +44 -0
- data/spec/lib/pwn/plugins/jira_data_center_review_fixes_spec.rb +81 -0
- data/spec/lib/pwn/plugins/jsonl_elf_review_fixes_spec.rb +59 -0
- data/spec/lib/pwn/plugins/log_spec.rb +36 -20
- data/spec/lib/pwn/plugins/monkey_patch_spec.rb +16 -0
- data/spec/lib/pwn/plugins/msr206_readback_review_fixes_spec.rb +119 -0
- data/spec/lib/pwn/plugins/msr206_review_fixes_spec.rb +50 -0
- data/spec/lib/pwn/plugins/msr206_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/nessus_cloud_namespace_audit_spec.rb +14 -0
- data/spec/lib/pwn/plugins/nexpose_review_fixes_spec.rb +55 -0
- data/spec/lib/pwn/plugins/open_api_namespace_audit_spec.rb +22 -0
- data/spec/lib/pwn/plugins/packet_transport_audit_spec.rb +47 -0
- data/spec/lib/pwn/plugins/plugins_b_operational_regression_spec.rb +600 -0
- data/spec/lib/pwn/plugins/pony_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/pony_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/process_tube_namespace_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/ps_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/pwn_logger_spec.rb +30 -0
- data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +127 -0
- data/spec/lib/pwn/plugins/repl/ai_spec.rb +38 -0
- data/spec/lib/pwn/plugins/repl/mesh_spec.rb +52 -0
- data/spec/lib/pwn/plugins/repl_mesh_rx_errors_spec.rb +18 -0
- data/spec/lib/pwn/plugins/sandbox_spec.rb +9 -7
- data/spec/lib/pwn/plugins/sbom_review_fixes_spec.rb +43 -0
- data/spec/lib/pwn/plugins/scannable_codes_namespace_audit_spec.rb +15 -0
- data/spec/lib/pwn/plugins/serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/plugins/serial_transport_audit_spec.rb +102 -0
- data/spec/lib/pwn/plugins/shodan_namespace_audit_spec.rb +10 -0
- data/spec/lib/pwn/plugins/sock_transport_audit_spec.rb +55 -0
- data/spec/lib/pwn/plugins/transparent_browser_navigation_review_spec.rb +21 -0
- data/spec/lib/pwn/plugins/vault_master_key_eui_regression_spec.rb +242 -0
- data/spec/lib/pwn/plugins/vault_spec.rb +58 -0
- data/spec/lib/pwn/plugins/vault_store_safety_spec.rb +1 -1
- data/spec/lib/pwn/plugins/xxd_namespace_audit_spec.rb +34 -0
- data/spec/lib/pwn/plugins/yubikey_hid_cleanup_review_fixes_spec.rb +52 -0
- data/spec/lib/pwn/plugins/yubikey_lifecycle_audit_spec.rb +65 -0
- data/spec/lib/pwn/plugins/yubikey_options_audit_spec.rb +30 -0
- data/spec/lib/pwn/plugins/yubikey_selector_audit_spec.rb +26 -0
- data/spec/lib/pwn/plugins/yubikey_spec.rb +1 -1
- data/spec/lib/pwn/plugins/zaproxy_namespace_audit_spec.rb +30 -0
- data/spec/lib/pwn/reports/empty_report_audit_spec.rb +18 -0
- data/spec/lib/pwn/reports/pdf_spec.rb +25 -0
- data/spec/lib/pwn/reports/provider_review_encoding_regression_spec.rb +35 -0
- data/spec/lib/pwn/sast/engine_runtime_regression_spec.rb +91 -0
- data/spec/lib/pwn/sast/filter_edge_regression_spec.rb +39 -0
- data/spec/lib/pwn/sast/formatter_review_fixes_spec.rb +178 -0
- data/spec/lib/pwn/sast/path_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/sast/pom_runtime_regression_spec.rb +37 -0
- data/spec/lib/pwn/sast/rules_runtime_regression_spec.rb +78 -0
- data/spec/lib/pwn/sast/sql_review_fixes_spec.rb +38 -0
- data/spec/lib/pwn/sdr/decoder/base_iq_spec.rb +21 -18
- data/spec/lib/pwn/sdr/decoder/base_review_fixes_spec.rb +49 -0
- data/spec/lib/pwn/sdr/decoder/base_validation_spec.rb +78 -0
- data/spec/lib/pwn/sdr/decoder/lora_spec.rb +9 -0
- data/spec/lib/pwn/sdr/flipper_zero_review_fixes_spec.rb +34 -0
- data/spec/lib/pwn/sdr/gqrx_operational_spec.rb +83 -0
- data/spec/lib/pwn/sdr/gqrx_review_fixes_spec.rb +22 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_review_fixes_spec.rb +113 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_spec.rb +39 -0
- data/spec/lib/pwn/sdr_spec.rb +5 -0
- data/spec/lib/pwn/session_cleanup_concurrency_spec.rb +21 -0
- data/spec/lib/pwn/session_cleanup_default_spec.rb +1 -1
- data/spec/lib/pwn/session_cleanup_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/session_cleanup_payload_spec.rb +3 -2
- data/spec/lib/pwn/session_trace_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/sessions_archive_closure_spec.rb +126 -0
- data/spec/lib/pwn/sessions_lifecycle_closure_spec.rb +373 -0
- data/spec/lib/pwn/sessions_lifecycle_supplement_spec.rb +204 -0
- data/spec/lib/pwn/setup_operational_regression_spec.rb +36 -0
- data/spec/lib/pwn/www/browser_review_fixes_spec.rb +70 -0
- data/spec/lib/pwn/www/browser_runtime_regression_spec.rb +100 -0
- data/spec/lib/pwn/www/hacker_one_runtime_regression_spec.rb +146 -0
- data/spec/lib/pwn/www/pagination_review_fixes_spec.rb +84 -0
- data/spec/spec_helper.rb +34 -5
- data/spec/support/namespace_controller_observability_fixture.rb +141 -0
- data/spec/support/sandbox.rb +8 -5
- data/third_party/pwn_rdoc.jsonl +83 -32
- metadata +7690 -7386
- data/etc/default_skills/pwn/aws/elastic_transcoder/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/lambda_preview/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works_cm/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/sms/SKILL.md +0 -48
- data/lib/pwn/aws/elastic_transcoder.rb +0 -95
- data/lib/pwn/aws/lambda_preview.rb +0 -95
- data/lib/pwn/aws/ops_works.rb +0 -95
- data/lib/pwn/aws/ops_works_cm.rb +0 -95
- data/lib/pwn/aws/sms.rb +0 -95
- data/spec/lib/pwn/aws/elastic_transcoder_spec.rb +0 -15
- data/spec/lib/pwn/aws/lambda_preview_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_cm_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_spec.rb +0 -15
- data/spec/lib/pwn/aws/sms_spec.rb +0 -15
|
@@ -318,7 +318,8 @@ module PWN
|
|
|
318
318
|
def call
|
|
319
319
|
if @source.wait_readable(@buffer.empty? ? (@interval || 0.04) : 0)
|
|
320
320
|
chunk = @source.read_nonblock(4096, exception: false)
|
|
321
|
-
|
|
321
|
+
@eof = chunk.nil?
|
|
322
|
+
return :eof if @eof && @buffer.empty?
|
|
322
323
|
|
|
323
324
|
@buffer << chunk if chunk.is_a?(String)
|
|
324
325
|
end
|
|
@@ -329,7 +330,7 @@ module PWN
|
|
|
329
330
|
|
|
330
331
|
cursor = cursor_key
|
|
331
332
|
return cursor unless cursor == :pending
|
|
332
|
-
return if KEYS.keys.any? { |key| key.start_with?(@buffer) } && @source.wait_readable(0.04)
|
|
333
|
+
return if !@eof && KEYS.keys.any? { |key| key.start_with?(@buffer) } && @source.wait_readable(0.04)
|
|
333
334
|
|
|
334
335
|
decode_character
|
|
335
336
|
end
|
|
@@ -360,6 +361,7 @@ module PWN
|
|
|
360
361
|
second = prefix[1]
|
|
361
362
|
valid &&= !(second && ((lead == 224 && second < 160) || (lead == 237 && second > 159) ||
|
|
362
363
|
(lead == 240 && second < 144) || (lead == 244 && second > 143)))
|
|
364
|
+
valid &&= !(@eof && @buffer.bytesize < size)
|
|
363
365
|
if valid
|
|
364
366
|
return if @buffer.bytesize < size
|
|
365
367
|
|
|
@@ -470,7 +472,10 @@ module PWN
|
|
|
470
472
|
end
|
|
471
473
|
|
|
472
474
|
def <<(event)
|
|
473
|
-
@mutex.synchronize
|
|
475
|
+
@mutex.synchronize do
|
|
476
|
+
@io.write("#{JSON.generate([@generation, *event])}\n")
|
|
477
|
+
@io.flush
|
|
478
|
+
end
|
|
474
479
|
self
|
|
475
480
|
end
|
|
476
481
|
end
|
|
@@ -654,7 +659,7 @@ module PWN
|
|
|
654
659
|
when :command_state
|
|
655
660
|
if text[:ai].is_a?(Hash)
|
|
656
661
|
text[:ai][:active] = text[:ai][:active].to_sym if PWN::Env.dig(:ai, :active).is_a?(Symbol) && text[:ai][:active].is_a?(String)
|
|
657
|
-
PWN::Env[:ai]
|
|
662
|
+
PWN::Env[:ai].replace(text[:ai])
|
|
658
663
|
end
|
|
659
664
|
text.fetch(:config, {}).each do |key, value|
|
|
660
665
|
@pry.config.public_send("#{key}=", value) if %i[pwn_ai_session_id pwn_ai_debug pwn_ai_trace].include?(key)
|
|
@@ -801,7 +806,12 @@ module PWN
|
|
|
801
806
|
events << [:session_title, PWN::Sessions.refresh_title(session_id: session_id, ai_config: title_config, on_error: ->(kind) { events << [:warning, "Session title refresh unavailable (#{kind}); previous title retained."] })]
|
|
802
807
|
end
|
|
803
808
|
rescue StandardError, Interrupt, Control::Stopped => e
|
|
804
|
-
|
|
809
|
+
warning = if e.respond_to?(:http_code) && e.http_code == 403
|
|
810
|
+
'Access denied (HTTP 403). Check that your account can use the selected model and endpoint.'
|
|
811
|
+
else
|
|
812
|
+
"#{e.class}: #{e.message}"
|
|
813
|
+
end
|
|
814
|
+
events << [:warning, warning]
|
|
805
815
|
ensure
|
|
806
816
|
output.flush
|
|
807
817
|
writer.close
|
|
@@ -1105,8 +1115,10 @@ module PWN
|
|
|
1105
1115
|
|
|
1106
1116
|
def send_tool_input(line)
|
|
1107
1117
|
text = "#{line.delete_prefix('/input ')}\n"
|
|
1118
|
+
return add(:warning, 'Tool input not sent: line exceeds 4096 bytes.') if text.bytesize > 4096
|
|
1119
|
+
|
|
1108
1120
|
written = @tool_input.write_nonblock(text, exception: false)
|
|
1109
|
-
if
|
|
1121
|
+
if written == :wait_writable
|
|
1110
1122
|
add(:warning, 'Tool input not sent: pipe full or line exceeds 4096 bytes.')
|
|
1111
1123
|
else
|
|
1112
1124
|
add(:notice, 'Input sent to tool (not echoed).')
|
|
@@ -784,6 +784,14 @@ class << PWN::Plugins::REPL # rubocop:disable Metrics/ClassLength
|
|
|
784
784
|
kwargs[:ack_timeout] = mqtt[:ack_timeout] unless mqtt[:ack_timeout].nil?
|
|
785
785
|
mesh_mqtt_connect(options: kwargs)
|
|
786
786
|
end
|
|
787
|
+
rescue StandardError, Interrupt => e
|
|
788
|
+
begin
|
|
789
|
+
mesh_disconnect(env: env, obj: obj, transport: opts[:transport]) if obj
|
|
790
|
+
rescue StandardError
|
|
791
|
+
# Preserve the handshake/cancellation error if cleanup also fails.
|
|
792
|
+
nil
|
|
793
|
+
end
|
|
794
|
+
raise e
|
|
787
795
|
end
|
|
788
796
|
|
|
789
797
|
# mqtt 0.7 raises reader failures asynchronously into the thread that
|
|
@@ -1980,6 +1988,9 @@ class << PWN::Plugins::REPL # rubocop:disable Metrics/ClassLength
|
|
|
1980
1988
|
# Serial.subscribe prints this on startup. It is not a diagnostic,
|
|
1981
1989
|
# and capturing it opens a NOTICE before the TUI can be used.
|
|
1982
1990
|
text.gsub!('Subscribing to serial FromRadio stream...', '')
|
|
1991
|
+
# Ruby prints this to stderr when a worker dies. The TUI captures stderr
|
|
1992
|
+
# and would open a NOTICE that hides the real failure.
|
|
1993
|
+
text.gsub!(/^#<Thread:0x[0-9a-f]+ .+> terminated with exception \(report_on_exception is true\):\s*/m, '')
|
|
1983
1994
|
text.strip!
|
|
1984
1995
|
text.empty? ? nil : text
|
|
1985
1996
|
end
|
|
@@ -3326,7 +3337,7 @@ class << PWN::Plugins::REPL # rubocop:disable Metrics/ClassLength
|
|
|
3326
3337
|
unless state[:last_line] == current_line
|
|
3327
3338
|
rx_body_win = PWN.const_get(:MeshRxBodyWin)
|
|
3328
3339
|
state[:detail_rows] ||= []
|
|
3329
|
-
index = state[:detail_rows].
|
|
3340
|
+
index = (state[:detail_rows].last&.fetch(:index) || -1) + 1
|
|
3330
3341
|
focused = mesh_focus == :conversation
|
|
3331
3342
|
mutex.synchronize do
|
|
3332
3343
|
width = [rx_body_win.maxx - 2, 1].max
|
|
@@ -3484,33 +3495,45 @@ class << PWN::Plugins::REPL # rubocop:disable Metrics/ClassLength
|
|
|
3484
3495
|
raw = defined?(PWN::Env) && PWN::Env.is_a?(Hash) ? PWN::Env.dig(:ai, :active).to_s : ''
|
|
3485
3496
|
engine = raw.empty? ? nil : raw.downcase.to_sym
|
|
3486
3497
|
Thread.new do
|
|
3498
|
+
Thread.current.report_on_exception = false
|
|
3487
3499
|
stage = 'AI'
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3500
|
+
session = nil
|
|
3501
|
+
begin
|
|
3502
|
+
Thread.current[:pwn_swarm_engine] = nil
|
|
3503
|
+
session = mesh_ai_session(env: env, channel_name: channel_name, network_path: opts[:network_path], from: from, to: opts[:to])
|
|
3504
|
+
reply = PWN::AI::Agent::Loop.run(request: text, session_id: session[:id], nested: true, engine: engine)
|
|
3505
|
+
stage = 'TX'
|
|
3506
|
+
raise IOError, 'Origin connection closed; AI reply remains unsent.' if opts[:connection] && (!opts[:connection][:active] || opts[:connection][:stopped])
|
|
3507
|
+
|
|
3508
|
+
mesh_send_text(
|
|
3509
|
+
env: env,
|
|
3510
|
+
obj: obj,
|
|
3511
|
+
transport: kind,
|
|
3512
|
+
connection: opts[:connection],
|
|
3513
|
+
from: mesh_self_node_id(env: env, obj: obj),
|
|
3514
|
+
to: dest,
|
|
3515
|
+
text: reply.to_s,
|
|
3516
|
+
channel_name: channel_name,
|
|
3517
|
+
radio: radio,
|
|
3518
|
+
region: slot[:region],
|
|
3519
|
+
topic: slot[:topic],
|
|
3520
|
+
channel: slot[:channel_num] || channel_name,
|
|
3521
|
+
psks: mesh_channel_psks(env: env)
|
|
3522
|
+
)
|
|
3523
|
+
rescue Exception => e # rubocop:disable Lint/RescueException -- a dead worker must not dump onto the mesh TUI
|
|
3524
|
+
begin
|
|
3525
|
+
mesh_ui_puts(text: "#{stage} failed: #{e.class}: #{e.message}", connection: opts[:connection])
|
|
3526
|
+
rescue Exception # rubocop:disable Lint/RescueException -- reporting the failure must not become a second thread dump
|
|
3527
|
+
nil
|
|
3528
|
+
end
|
|
3529
|
+
ensure
|
|
3530
|
+
begin
|
|
3531
|
+
PWN::Sessions.deactivate(lease: session&.dig(:lease))
|
|
3532
|
+
rescue Exception # rubocop:disable Lint/RescueException -- lease cleanup must not replace the dispatch error
|
|
3533
|
+
nil
|
|
3534
|
+
end
|
|
3535
|
+
PWN.send(:remove_const, :MeshDispatchLock) if PWN.const_defined?(:MeshDispatchLock)
|
|
3536
|
+
end
|
|
3514
3537
|
end
|
|
3515
3538
|
:dispatched
|
|
3516
3539
|
end
|
|
@@ -3872,7 +3895,7 @@ class << PWN::Plugins::REPL # rubocop:disable Metrics/ClassLength
|
|
|
3872
3895
|
sub = choice
|
|
3873
3896
|
end
|
|
3874
3897
|
|
|
3875
|
-
case
|
|
3898
|
+
case mesh_bound_transport(env: env)
|
|
3876
3899
|
when :serial
|
|
3877
3900
|
env[:serial] ||= {}
|
|
3878
3901
|
env[:serial][:port] = sub
|
data/lib/pwn/plugins/sbom.rb
CHANGED
|
@@ -18,7 +18,7 @@ module PWN
|
|
|
18
18
|
engine = (opts[:engine] || select_engine(target: target)).to_s
|
|
19
19
|
rows = case engine
|
|
20
20
|
when 'grype' then parse_grype(target: target)
|
|
21
|
-
when 'trivy' then parse_trivy(target: target)
|
|
21
|
+
when 'trivy' then parse_trivy(target: target, image: opts[:image] && !opts[:path_or_image] && !opts[:path])
|
|
22
22
|
when 'osv-scanner' then parse_osv(target: target)
|
|
23
23
|
when 'syft+grype', 'syft'
|
|
24
24
|
inv = parse_syft(target: target)
|
|
@@ -30,6 +30,8 @@ module PWN
|
|
|
30
30
|
else
|
|
31
31
|
raise IOError, 'no SBOM engine installed (syft, grype, trivy, or osv-scanner)'
|
|
32
32
|
end
|
|
33
|
+
return engine_failure(engine: engine, target: target, exit: rows[:exit]) if rows.is_a?(Hash) && rows[:ok] == false
|
|
34
|
+
|
|
33
35
|
observations = []
|
|
34
36
|
if defined?(PWN::Plugins::Recon) && opts[:record] == true
|
|
35
37
|
rows.each do |row|
|
|
@@ -82,32 +84,45 @@ module PWN
|
|
|
82
84
|
private_class_method def self.run!(opts = {})
|
|
83
85
|
argv = opts[:argv]
|
|
84
86
|
out, st = Open3.capture2(*argv)
|
|
85
|
-
|
|
87
|
+
exit_code = st.success? ? 0 : st.exitstatus
|
|
88
|
+
accepted = st.success? || Array(opts[:accepted_exits]).include?(exit_code)
|
|
89
|
+
{ output: accepted ? out : '', exit: exit_code, ok: accepted }
|
|
90
|
+
end
|
|
86
91
|
|
|
87
|
-
|
|
92
|
+
private_class_method def self.engine_failure(opts = {})
|
|
93
|
+
{ engine: opts[:engine].to_s, target: opts[:target].to_s, vulns: [], observations: [], ok: false, success: false, status: 'failed', error: "#{opts[:engine]} failed", exit: opts[:exit] }
|
|
88
94
|
end
|
|
89
95
|
|
|
90
96
|
private_class_method def self.parse_grype(opts = {})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
ran = run!(argv: ['grype', '-o', 'json', opts[:target]])
|
|
98
|
+
return ran unless ran[:ok]
|
|
99
|
+
return engine_failure(engine: 'grype', target: opts[:target], exit: ran[:exit]) if ran[:output].to_s.strip.empty?
|
|
100
|
+
|
|
101
|
+
json = parse_engine_json(text: ran[:output])
|
|
102
|
+
matches = json['matches'] || json[:matches] if json.is_a?(Hash)
|
|
103
|
+
return engine_failure(engine: 'grype', target: opts[:target], exit: ran[:exit]) unless matches.is_a?(Array)
|
|
104
|
+
|
|
105
|
+
matches.map do |row|
|
|
106
|
+
art = row['artifact'] || row[:artifact] || {}
|
|
107
|
+
vuln = row['vulnerability'] || row[:vulnerability] || {}
|
|
108
|
+
normalize(package: art['name'] || art[:name], version: art['version'] || art[:version], cve: vuln['id'] || vuln[:id], severity: vuln['severity'] || vuln[:severity], fix: vuln.dig('fix', 'versions') || vuln.dig(:fix, :versions))
|
|
99
109
|
end
|
|
100
110
|
end
|
|
101
111
|
|
|
102
112
|
private_class_method def self.parse_trivy(opts = {})
|
|
103
113
|
target = opts[:target].to_s
|
|
104
114
|
sub = File.file?(target) && target.match?(/\.(tar|tar\.gz|tgz|tar\.zst)\z/i) ? 'image' : 'fs'
|
|
105
|
-
sub = 'image' if target.include?(':') && !File.exist?(target)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
sub = 'image' if opts[:image] || (target.include?(':') && !File.exist?(target))
|
|
116
|
+
ran = run!(argv: ['trivy', sub, '--format', 'json', target])
|
|
117
|
+
return engine_failure(engine: 'trivy', target: target, exit: ran[:exit]) unless ran[:ok]
|
|
118
|
+
|
|
119
|
+
json = parse_engine_json(text: ran[:output])
|
|
120
|
+
results = json['Results'] || json[:Results] if json.is_a?(Hash)
|
|
121
|
+
return engine_failure(engine: 'trivy', target: target, exit: ran[:exit]) unless results.is_a?(Array)
|
|
122
|
+
|
|
123
|
+
results.flat_map do |res|
|
|
124
|
+
Array(res['Vulnerabilities'] || res[:Vulnerabilities]).map do |vuln|
|
|
125
|
+
normalize(package: vuln['PkgName'] || vuln[:PkgName], version: vuln['InstalledVersion'] || vuln[:InstalledVersion], cve: vuln['VulnerabilityID'] || vuln[:VulnerabilityID], severity: vuln['Severity'] || vuln[:Severity], fix: vuln['FixedVersion'] || vuln[:FixedVersion])
|
|
111
126
|
end
|
|
112
127
|
end
|
|
113
128
|
end
|
|
@@ -116,25 +131,42 @@ module PWN
|
|
|
116
131
|
target = opts[:target].to_s
|
|
117
132
|
argv = ['osv-scanner', '--json']
|
|
118
133
|
argv.concat(File.file?(target) ? [target] : ['-r', target])
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
ran = run!(argv: argv, accepted_exits: [1])
|
|
135
|
+
return engine_failure(engine: 'osv-scanner', target: target, exit: ran[:exit]) unless ran[:ok]
|
|
136
|
+
|
|
137
|
+
json = parse_engine_json(text: ran[:output])
|
|
138
|
+
results = json['results'] || json[:results] if json.is_a?(Hash)
|
|
139
|
+
return engine_failure(engine: 'osv-scanner', target: target, exit: ran[:exit]) unless results.is_a?(Array)
|
|
140
|
+
|
|
141
|
+
results.flat_map do |res|
|
|
142
|
+
Array(res['packages'] || res[:packages]).flat_map do |pkg|
|
|
143
|
+
package = pkg['package'] || pkg[:package] || {}
|
|
144
|
+
Array(pkg['vulnerabilities'] || pkg[:vulnerabilities]).map do |vuln|
|
|
145
|
+
normalize(package: package['name'] || package[:name], version: package['version'] || package[:version], cve: vuln['id'] || vuln[:id], severity: 'unknown', fix: nil)
|
|
125
146
|
end
|
|
126
147
|
end
|
|
127
148
|
end
|
|
128
149
|
end
|
|
129
150
|
|
|
130
151
|
private_class_method def self.parse_syft(opts = {})
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
152
|
+
ran = run!(argv: ['syft', '-o', 'json', opts[:target]])
|
|
153
|
+
return engine_failure(engine: 'syft', target: opts[:target], exit: ran[:exit]) unless ran[:ok]
|
|
154
|
+
|
|
155
|
+
json = parse_engine_json(text: ran[:output])
|
|
156
|
+
artifacts = json['artifacts'] || json[:artifacts] if json.is_a?(Hash)
|
|
157
|
+
return engine_failure(engine: 'syft', target: opts[:target], exit: ran[:exit]) unless artifacts.is_a?(Array)
|
|
158
|
+
|
|
159
|
+
artifacts.map do |art|
|
|
160
|
+
normalize(package: art['name'] || art[:name], version: art['version'] || art[:version], cve: nil, severity: 'info', fix: nil)
|
|
135
161
|
end
|
|
136
162
|
end
|
|
137
163
|
|
|
164
|
+
private_class_method def self.parse_engine_json(opts = {})
|
|
165
|
+
JSON.parse(opts[:text].to_s)
|
|
166
|
+
rescue JSON::ParserError
|
|
167
|
+
nil
|
|
168
|
+
end
|
|
169
|
+
|
|
138
170
|
private_class_method def self.normalize(opts = {})
|
|
139
171
|
{
|
|
140
172
|
package: opts[:package].to_s,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'barby'
|
|
4
|
+
require 'barby/barcode/code_128'
|
|
5
|
+
require 'barby/outputter/png_outputter'
|
|
4
6
|
require 'base64'
|
|
5
7
|
require 'fileutils'
|
|
6
8
|
require 'chunky_png'
|
|
@@ -37,7 +39,7 @@ module PWN
|
|
|
37
39
|
case type
|
|
38
40
|
when :barcode
|
|
39
41
|
barcode = Barby::Code128B.new(data)
|
|
40
|
-
barcode.to_png
|
|
42
|
+
File.binwrite(path, barcode.to_png)
|
|
41
43
|
when :qrcode
|
|
42
44
|
size ||= 200
|
|
43
45
|
qrcode = RQRCode::QRCode.new(data)
|
data/lib/pwn/plugins/serial.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'English'
|
|
4
|
+
|
|
3
5
|
require 'uart'
|
|
4
6
|
require 'io/wait'
|
|
5
7
|
|
|
@@ -8,7 +10,8 @@ module PWN
|
|
|
8
10
|
# This plugin is used for interacting with serial devices including, but not limited to,
|
|
9
11
|
# modems (including cellphone radios), legacy equipment, arduinos, & other misc ftdi devices
|
|
10
12
|
module Serial
|
|
11
|
-
@
|
|
13
|
+
@sessions = []
|
|
14
|
+
@sessions_mutex = Mutex.new
|
|
12
15
|
|
|
13
16
|
# Supported Method Parameters::
|
|
14
17
|
# serial_obj = PWN::Plugins::Serial.connect(
|
|
@@ -20,13 +23,13 @@ module PWN
|
|
|
20
23
|
# )
|
|
21
24
|
|
|
22
25
|
public_class_method def self.connect(opts = {})
|
|
23
|
-
block_dev = opts
|
|
24
|
-
raise
|
|
26
|
+
block_dev = opts.fetch(:block_dev, '/dev/ttyUSB0')
|
|
27
|
+
raise ArgumentError, 'Invalid serial block device' unless block_dev.is_a?(String) && !block_dev.empty? && !block_dev.include?("\0") && File.exist?(block_dev)
|
|
25
28
|
|
|
26
|
-
baud = opts
|
|
27
|
-
data_bits = opts
|
|
28
|
-
stop_bits = opts
|
|
29
|
-
parity = opts
|
|
29
|
+
baud = opts.fetch(:baud, 9_600)
|
|
30
|
+
data_bits = opts.fetch(:data_bits, 8)
|
|
31
|
+
stop_bits = opts.fetch(:stop_bits, 1)
|
|
32
|
+
parity = opts.fetch(:parity, :none)
|
|
30
33
|
|
|
31
34
|
case parity.to_s.to_sym
|
|
32
35
|
when :even
|
|
@@ -47,16 +50,20 @@ module PWN
|
|
|
47
50
|
mode
|
|
48
51
|
)
|
|
49
52
|
|
|
50
|
-
serial_obj = {}
|
|
53
|
+
serial_obj = { session_data: [], session_mutex: Mutex.new }
|
|
51
54
|
serial_obj[:serial_conn] = serial_conn
|
|
55
|
+
@sessions_mutex.synchronize { @sessions << serial_obj }
|
|
52
56
|
serial_obj[:session_thread] = init_session_thread(
|
|
53
|
-
|
|
57
|
+
serial_obj: serial_obj
|
|
54
58
|
)
|
|
55
59
|
|
|
60
|
+
handed_off = true
|
|
56
61
|
serial_obj
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
ensure
|
|
63
|
+
unless handed_off
|
|
64
|
+
serial_obj ||= { serial_conn: serial_conn } if serial_conn
|
|
65
|
+
cleanup_failed_session(serial_obj: serial_obj) if serial_obj
|
|
66
|
+
end
|
|
60
67
|
end
|
|
61
68
|
|
|
62
69
|
# Supported Method Parameters::
|
|
@@ -65,27 +72,20 @@ module PWN
|
|
|
65
72
|
# )
|
|
66
73
|
|
|
67
74
|
private_class_method def self.init_session_thread(opts = {})
|
|
68
|
-
|
|
75
|
+
serial_obj = opts[:serial_obj]
|
|
76
|
+
serial_conn = serial_obj[:serial_conn]
|
|
69
77
|
|
|
70
|
-
# Spin up a serial_obj session_thread
|
|
71
78
|
Thread.new do
|
|
72
|
-
# serial_conn.read_timeout = -1
|
|
73
79
|
serial_conn.flush
|
|
74
80
|
|
|
75
81
|
loop do
|
|
76
82
|
serial_conn.wait_readable
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
# later.
|
|
80
|
-
@session_data << serial_conn.readchar
|
|
83
|
+
byte = serial_conn.readchar
|
|
84
|
+
serial_obj[:session_mutex].synchronize { serial_obj[:session_data] << byte }
|
|
81
85
|
end
|
|
86
|
+
rescue StandardError => e
|
|
87
|
+
serial_obj[:session_mutex].synchronize { serial_obj[:session_error] = e }
|
|
82
88
|
end
|
|
83
|
-
rescue StandardError => e
|
|
84
|
-
session_thread&.terminate
|
|
85
|
-
serial_conn&.close
|
|
86
|
-
serial_conn = nil
|
|
87
|
-
|
|
88
|
-
raise e
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# Supported Method Parameters::
|
|
@@ -98,9 +98,14 @@ module PWN
|
|
|
98
98
|
serial_conn = serial_obj[:serial_conn]
|
|
99
99
|
# Should return something like:
|
|
100
100
|
# {"rts"=>1, "dtr"=>1, "cts"=>1, "dsr"=>1, "dcd"=>0, "ri"=>0}
|
|
101
|
-
|
|
101
|
+
buffer = [0].pack('i')
|
|
102
|
+
serial_conn.ioctl(Termios::TIOCMGET, buffer)
|
|
103
|
+
flags = buffer.unpack1('i')
|
|
104
|
+
{ 'rts' => Termios::TIOCM_RTS, 'dtr' => Termios::TIOCM_DTR,
|
|
105
|
+
'cts' => Termios::TIOCM_CTS, 'dsr' => Termios::TIOCM_DSR,
|
|
106
|
+
'dcd' => Termios::TIOCM_CAR, 'ri' => Termios::TIOCM_RNG }.transform_values { |mask| flags.anybits?(mask) ? 1 : 0 }
|
|
102
107
|
rescue StandardError => e
|
|
103
|
-
|
|
108
|
+
cleanup_failed_session(serial_obj: serial_obj) unless serial_obj.nil?
|
|
104
109
|
raise e
|
|
105
110
|
end
|
|
106
111
|
|
|
@@ -114,9 +119,20 @@ module PWN
|
|
|
114
119
|
serial_conn = serial_obj[:serial_conn]
|
|
115
120
|
# Should return something like:
|
|
116
121
|
# {"baud"=>9600, "data_bits"=>8, "stop_bits"=>1, "parity"=>0}
|
|
117
|
-
serial_conn
|
|
122
|
+
attributes = Termios.tcgetattr(serial_conn)
|
|
123
|
+
baud_name = Termios.constants.find { |name| name.to_s.match?(/\AB[0-9]+\z/) && Termios.const_get(name) == attributes.ospeed }
|
|
124
|
+
raise IOError, 'Unrecognized UART baud rate' unless baud_name
|
|
125
|
+
|
|
126
|
+
bits = (5..8).find { |width| (attributes.cflag & Termios::CSIZE) == Termios.const_get("CS#{width}") }
|
|
127
|
+
parity = if attributes.cflag.nobits?(Termios::PARENB)
|
|
128
|
+
0
|
|
129
|
+
else
|
|
130
|
+
attributes.cflag.anybits?(Termios::PARODD) ? 1 : 2
|
|
131
|
+
end
|
|
132
|
+
{ 'baud' => baud_name.to_s.delete_prefix('B').to_i, 'data_bits' => bits,
|
|
133
|
+
'stop_bits' => attributes.cflag.anybits?(Termios::CSTOPB) ? 2 : 1, 'parity' => parity }
|
|
118
134
|
rescue StandardError => e
|
|
119
|
-
|
|
135
|
+
cleanup_failed_session(serial_obj: serial_obj) unless serial_obj.nil?
|
|
120
136
|
raise e
|
|
121
137
|
end
|
|
122
138
|
|
|
@@ -143,7 +159,7 @@ module PWN
|
|
|
143
159
|
sleep(0.1)
|
|
144
160
|
serial_conn.flush
|
|
145
161
|
rescue StandardError => e
|
|
146
|
-
|
|
162
|
+
cleanup_failed_session(serial_obj: serial_obj) unless serial_obj.nil?
|
|
147
163
|
raise e
|
|
148
164
|
end
|
|
149
165
|
|
|
@@ -155,7 +171,7 @@ module PWN
|
|
|
155
171
|
public_class_method def self.response(opts = {})
|
|
156
172
|
serial_obj = opts[:serial_obj]
|
|
157
173
|
|
|
158
|
-
raw_byte_arr = dump_session_data
|
|
174
|
+
raw_byte_arr = dump_session_data(serial_obj: serial_obj)
|
|
159
175
|
|
|
160
176
|
hex_esc_raw_resp = ''
|
|
161
177
|
raw_byte_arr.each do |byte|
|
|
@@ -180,7 +196,7 @@ module PWN
|
|
|
180
196
|
cmd_response_arr.map(&:strip)
|
|
181
197
|
rescue StandardError => e
|
|
182
198
|
# Flush Responses for Next Request
|
|
183
|
-
flush_session_data
|
|
199
|
+
flush_session_data(serial_obj: serial_obj) if serial_obj
|
|
184
200
|
|
|
185
201
|
raise e
|
|
186
202
|
end
|
|
@@ -188,8 +204,15 @@ module PWN
|
|
|
188
204
|
# Supported Method Parameters::
|
|
189
205
|
# session_data = PWN::Plugins::Serial.dump_session_data
|
|
190
206
|
|
|
191
|
-
public_class_method def self.dump_session_data
|
|
192
|
-
|
|
207
|
+
public_class_method def self.dump_session_data(opts = {})
|
|
208
|
+
serial_obj = session_for_data(serial_obj: opts[:serial_obj])
|
|
209
|
+
return [] unless serial_obj
|
|
210
|
+
|
|
211
|
+
serial_obj[:session_mutex].synchronize do
|
|
212
|
+
raise serial_obj[:session_error] if serial_obj[:session_error] && serial_obj[:session_data].empty?
|
|
213
|
+
|
|
214
|
+
serial_obj[:session_data].dup
|
|
215
|
+
end
|
|
193
216
|
rescue StandardError => e
|
|
194
217
|
raise e
|
|
195
218
|
end
|
|
@@ -197,8 +220,11 @@ module PWN
|
|
|
197
220
|
# Supported Method Parameters::
|
|
198
221
|
# session_data = PWN::Plugins::Serial.flush_session_data
|
|
199
222
|
|
|
200
|
-
public_class_method def self.flush_session_data
|
|
201
|
-
|
|
223
|
+
public_class_method def self.flush_session_data(opts = {})
|
|
224
|
+
serial_obj = session_for_data(serial_obj: opts[:serial_obj])
|
|
225
|
+
return [] unless serial_obj
|
|
226
|
+
|
|
227
|
+
serial_obj[:session_mutex].synchronize { serial_obj[:session_data].clear }
|
|
202
228
|
rescue StandardError => e
|
|
203
229
|
raise e
|
|
204
230
|
end
|
|
@@ -209,15 +235,43 @@ module PWN
|
|
|
209
235
|
# )
|
|
210
236
|
|
|
211
237
|
public_class_method def self.disconnect(opts = {})
|
|
238
|
+
primary_error = nil
|
|
212
239
|
serial_obj = opts[:serial_obj]
|
|
240
|
+
return unless serial_obj
|
|
241
|
+
|
|
213
242
|
serial_conn = serial_obj[:serial_conn]
|
|
214
243
|
session_thread = serial_obj[:session_thread]
|
|
215
|
-
|
|
216
|
-
session_thread.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
rescue StandardError => e
|
|
220
|
-
|
|
244
|
+
session_thread&.terminate
|
|
245
|
+
session_thread&.join unless session_thread == Thread.current
|
|
246
|
+
flush_session_data(serial_obj: serial_obj) if serial_obj[:session_mutex]
|
|
247
|
+
nil
|
|
248
|
+
rescue StandardError, Interrupt => e
|
|
249
|
+
primary_error = e
|
|
250
|
+
raise
|
|
251
|
+
ensure
|
|
252
|
+
@sessions_mutex.synchronize { @sessions.delete_if { |session| session.equal?(serial_obj) } }
|
|
253
|
+
begin
|
|
254
|
+
serial_conn.close if serial_conn && !serial_conn.closed?
|
|
255
|
+
rescue StandardError, Interrupt
|
|
256
|
+
raise unless primary_error
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
private_class_method def self.cleanup_failed_session(opts = {})
|
|
261
|
+
disconnect(serial_obj: opts[:serial_obj])
|
|
262
|
+
rescue StandardError, Interrupt
|
|
263
|
+
# Invoked only while the caller is already propagating its own failure.
|
|
264
|
+
nil
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
private_class_method def self.session_for_data(opts = {})
|
|
268
|
+
return opts[:serial_obj] if opts[:serial_obj]
|
|
269
|
+
|
|
270
|
+
@sessions_mutex.synchronize do
|
|
271
|
+
raise ArgumentError, 'serial_obj is required when multiple serial sessions are open' if @sessions.length > 1
|
|
272
|
+
|
|
273
|
+
@sessions.first
|
|
274
|
+
end
|
|
221
275
|
end
|
|
222
276
|
|
|
223
277
|
# Author(s):: 0day Inc. <support@0dayinc.com>
|
|
@@ -263,10 +317,14 @@ module PWN
|
|
|
263
317
|
)
|
|
264
318
|
|
|
265
319
|
# Run dump session data and return its result
|
|
266
|
-
#{self}.dump_session_data
|
|
320
|
+
#{self}.dump_session_data(
|
|
321
|
+
serial_obj: 'optional - selected connection; required when multiple sessions are open'
|
|
322
|
+
)
|
|
267
323
|
|
|
268
324
|
# Run flush session data and return its result
|
|
269
|
-
#{self}.flush_session_data
|
|
325
|
+
#{self}.flush_session_data(
|
|
326
|
+
serial_obj: 'optional - selected connection; required when multiple sessions are open'
|
|
327
|
+
)
|
|
270
328
|
|
|
271
329
|
# Run disconnect and return its result
|
|
272
330
|
#{self}.disconnect(
|
data/lib/pwn/plugins/shodan.rb
CHANGED
|
@@ -382,16 +382,10 @@ module PWN
|
|
|
382
382
|
|
|
383
383
|
public_class_method def self.saved_search_queries(opts = {})
|
|
384
384
|
api_key = opts[:api_key].to_s.scrub
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
params = {
|
|
390
|
-
key: api_key,
|
|
391
|
-
page: page,
|
|
392
|
-
sort: sort.to_s,
|
|
393
|
-
order: order.to_s
|
|
394
|
-
}
|
|
385
|
+
params = { key: api_key }
|
|
386
|
+
params[:page] = opts[:page].to_i if opts[:page]
|
|
387
|
+
params[:sort] = opts[:sort].to_s if opts[:sort]
|
|
388
|
+
params[:order] = opts[:order].to_s if opts[:order]
|
|
395
389
|
|
|
396
390
|
shodan_rest_call(
|
|
397
391
|
api_key: api_key,
|