cfsolve 0.1.2 → 0.1.4
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/CHANGELOG.md +22 -0
- data/README.md +8 -3
- data/THIRD_PARTY_LICENSES/README.md +71 -254
- data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
- data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
- data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
- data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
- data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
- data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
- data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
- data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
- data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
- data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
- data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
- data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
- data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
- data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
- data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
- data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
- data/UPSTREAM.md +14 -6
- data/ext/cfsolve/Cargo.lock +534 -1727
- data/ext/cfsolve/Cargo.toml +4 -0
- data/ext/cfsolve/src/main.rs +1 -1
- data/lib/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
- data/lib/cfsolve/profiles/chrome-157-macos.json +613 -0
- data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
- data/lib/cfsolve/version.rb +2 -2
- data/lib/cfsolve.rb +1 -1
- data/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +57 -5
- data/vendor/cfsolve/examples/check_answers.rs +2 -2
- data/vendor/cfsolve/examples/compare_session.rs +1 -2
- data/vendor/cfsolve/examples/solver_profile.rs +84 -0
- data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
- data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
- data/vendor/cfsolve/examples/tls_echo.rs +3 -3
- data/vendor/cfsolve/examples/turnstile_smoke.rs +58 -0
- data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
- data/vendor/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
- data/vendor/cfsolve/profiles/chrome-157-macos.json +613 -0
- data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
- data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
- data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
- data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
- data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
- data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
- data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
- data/vendor/cfsolve/src/capture/proxy.rs +44 -13
- data/vendor/cfsolve/src/capture/sessions.rs +4 -3
- data/vendor/cfsolve/src/capture/upstream.rs +1 -1
- data/vendor/cfsolve/src/challenge/codec.rs +4 -2
- data/vendor/cfsolve/src/challenge/expression.rs +161 -117
- data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
- data/vendor/cfsolve/src/challenge/installed.rs +13 -6
- data/vendor/cfsolve/src/challenge/merge.rs +120 -80
- data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
- data/vendor/cfsolve/src/challenge/payload.rs +69 -31
- data/vendor/cfsolve/src/challenge/program.rs +197 -178
- data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
- data/vendor/cfsolve/src/challenge/source.rs +151 -96
- data/vendor/cfsolve/src/challenge/state.rs +180 -148
- data/vendor/cfsolve/src/challenge/tally.rs +64 -50
- data/vendor/cfsolve/src/challenge.rs +1 -0
- data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
- data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
- data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
- data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
- data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
- data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
- data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
- data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
- data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
- data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
- data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
- data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
- data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
- data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
- data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
- data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
- data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
- data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
- data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
- data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
- data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
- data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
- data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
- data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
- data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
- data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
- data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
- data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
- data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
- data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
- data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
- data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
- data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
- data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
- data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
- data/vendor/cfsolve/src/deobfuscate.rs +15 -11
- data/vendor/cfsolve/src/embedding_page/extra_params.rs +132 -24
- data/vendor/cfsolve/src/embedding_page/page.rs +41 -1
- data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
- data/vendor/cfsolve/src/error.rs +40 -5
- data/vendor/cfsolve/src/fingerprint.rs +8 -2
- data/vendor/cfsolve/src/http/client.rs +7 -10
- data/vendor/cfsolve/src/http/requests.rs +2 -2
- data/vendor/cfsolve/src/js/ast.rs +479 -263
- data/vendor/cfsolve/src/lib.rs +1 -0
- data/vendor/cfsolve/src/listing/fold.rs +19 -9
- data/vendor/cfsolve/src/listing/query.rs +1 -47
- data/vendor/cfsolve/src/performance_clock.rs +20 -1
- data/vendor/cfsolve/src/profiling.rs +49 -0
- data/vendor/cfsolve/src/script.rs +35 -24
- data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
- data/vendor/cfsolve/src/session/channel.rs +2 -2
- data/vendor/cfsolve/src/session/initial.rs +12 -11
- data/vendor/cfsolve/src/session/probes.rs +1 -0
- data/vendor/cfsolve/src/session/sink.rs +26 -1
- data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
- data/vendor/cfsolve/src/session.rs +1 -1
- data/vendor/cfsolve/src/solver.rs +3 -1
- data/vendor/cfsolve/src/stage2/analysis/analyze.rs +33 -4
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/discovery.rs +13 -2
- data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
- data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
- data/vendor/cfsolve/src/stage2/benchmark.rs +113 -41
- data/vendor/cfsolve/src/stage2/call_stack.rs +1564 -1041
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- data/vendor/cfsolve/src/stage2/fixtures/encoded_benchmark_worker.js +1 -0
- data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
- data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
- data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
- data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
- data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
- data/vendor/cfsolve/src/stage2/probes/dates.rs +44 -0
- data/vendor/cfsolve/src/stage2/probes/parent_info_array.rs +326 -0
- data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
- data/vendor/cfsolve/src/stage2/probes/stack.rs +117 -4
- data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +80 -2
- data/vendor/cfsolve/src/stage2/probes.rs +1 -0
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/reference.rs +5 -0
- data/vendor/cfsolve/src/stage2/registry.rs +8 -2
- data/vendor/cfsolve/src/stage2/replay.rs +34 -3
- data/vendor/cfsolve/src/stage2/stylesheets.rs +35 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +134 -108
- data/vendor/cfsolve/src/stage2/value_labels.rs +185 -0
- data/vendor/cfsolve/src/stage2/vocabulary.rs +112 -17
- data/vendor/cfsolve/src/stage2.rs +3 -0
- data/vendor/cfsolve/src/vm/disassemble.rs +75 -7
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/encoded_names.rs +635 -0
- data/vendor/cfsolve/src/vm/extract.rs +550 -250
- data/vendor/cfsolve/src/vm/fixtures/free_functions/README.md +9 -0
- data/vendor/cfsolve/src/vm/fixtures/free_functions/machine.js +7438 -0
- data/vendor/cfsolve/src/vm/fixtures/free_functions/program.base64 +1 -0
- data/vendor/cfsolve/src/vm/interpret/access.rs +71 -50
- data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
- data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
- data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
- data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
- data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
- data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
- data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
- data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
- data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
- data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +160 -58
- data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
- data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
- data/vendor/cfsolve/src/vm/interpret/pattern.rs +1765 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +392 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +120 -45
- data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
- data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
- data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
- data/vendor/cfsolve/src/vm/interpret.rs +9 -1
- data/vendor/cfsolve/src/vm/machine.rs +116 -51
- data/vendor/cfsolve/src/vm/output.rs +19 -6
- data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
- data/vendor/cfsolve/src/vm/registers.rs +35 -21
- data/vendor/cfsolve/src/vm/session.rs +189 -121
- data/vendor/cfsolve/src/vm/value.rs +22 -19
- data/vendor/cfsolve/src/vm.rs +3 -1
- data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
- data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
- metadata +106 -178
- data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
- data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
- data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
- data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
- data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
- data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
- data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
- data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
- data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
- data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
- data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
- data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
- data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
- data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
- data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
- data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
- data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
- data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
- data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
- data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
- data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
- data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
- /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
- /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
- /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
- /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
- /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
- /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
//! Folds calls to the program's per-probe string decoders. These cache a base64 string,
|
|
2
|
+
//! rotate a 16-bit key by one byte before each XOR, and escape UTF-16 units with 255.
|
|
3
|
+
//! Decoder cells belong to their creating function and its closures, not the whole program.
|
|
4
|
+
|
|
5
|
+
use std::collections::{BTreeSet, HashMap, HashSet};
|
|
6
|
+
|
|
7
|
+
use base64::Engine;
|
|
8
|
+
use base64::engine::general_purpose::STANDARD;
|
|
9
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
10
|
+
|
|
11
|
+
use super::{Constant, Effect, Exit, Listing, Term};
|
|
12
|
+
use crate::listing::Index;
|
|
13
|
+
|
|
14
|
+
pub(super) fn fold(listing: &mut Listing) {
|
|
15
|
+
let index = Index::new(listing);
|
|
16
|
+
let decoders: HashMap<u32, u16> = index
|
|
17
|
+
.entries()
|
|
18
|
+
.iter()
|
|
19
|
+
.filter_map(|&entry| decoder(&index, entry).map(|seed| (entry, seed)))
|
|
20
|
+
.collect();
|
|
21
|
+
if decoders.is_empty() {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let factories: HashMap<u32, u16> = index
|
|
25
|
+
.entries()
|
|
26
|
+
.iter()
|
|
27
|
+
.filter_map(|&entry| {
|
|
28
|
+
let mut seeds = BTreeSet::new();
|
|
29
|
+
for (&pc, instruction) in listing.instructions.range(index.function_at(entry)) {
|
|
30
|
+
for path in &instruction.paths {
|
|
31
|
+
if matches!(path.exit, Exit::Return) {
|
|
32
|
+
let Some(Effect::Set(_, value)) = path.effects.first() else {
|
|
33
|
+
return None;
|
|
34
|
+
};
|
|
35
|
+
let (_, Term::Closure { pc, .. }) = index.dereference(pc, value)? else {
|
|
36
|
+
return None;
|
|
37
|
+
};
|
|
38
|
+
seeds.insert(*decoders.get(&pc)?);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
(seeds.len() == 1).then(|| (entry, *seeds.first().unwrap()))
|
|
43
|
+
})
|
|
44
|
+
.collect();
|
|
45
|
+
let cells = captured_values(&index, |pc, value| {
|
|
46
|
+
factory_result(&index, pc, value, &factories)
|
|
47
|
+
});
|
|
48
|
+
let mut replacements = Vec::new();
|
|
49
|
+
let mut decoded_inputs = Vec::new();
|
|
50
|
+
for (&pc, instruction) in &listing.instructions {
|
|
51
|
+
let Some(entry) = index.entry_at_or_before(pc) else {
|
|
52
|
+
continue;
|
|
53
|
+
};
|
|
54
|
+
for (path_index, path) in instruction.paths.iter().enumerate() {
|
|
55
|
+
for (effect_index, effect) in path.effects.iter().enumerate() {
|
|
56
|
+
let (Effect::Let(
|
|
57
|
+
_,
|
|
58
|
+
Term::Call {
|
|
59
|
+
callee,
|
|
60
|
+
this: None,
|
|
61
|
+
arguments,
|
|
62
|
+
},
|
|
63
|
+
)
|
|
64
|
+
| Effect::Set(
|
|
65
|
+
_,
|
|
66
|
+
Term::Call {
|
|
67
|
+
callee,
|
|
68
|
+
this: None,
|
|
69
|
+
arguments,
|
|
70
|
+
},
|
|
71
|
+
)) = effect
|
|
72
|
+
else {
|
|
73
|
+
continue;
|
|
74
|
+
};
|
|
75
|
+
let [argument] = &arguments[..] else {
|
|
76
|
+
continue;
|
|
77
|
+
};
|
|
78
|
+
let seed = match index.dereference(pc, callee) {
|
|
79
|
+
Some((_, Term::Cell(cell))) => cells.get(&(entry, cell)).copied(),
|
|
80
|
+
_ => factory_result(&index, pc, callee, &factories),
|
|
81
|
+
};
|
|
82
|
+
let Some(seed) = seed else {
|
|
83
|
+
continue;
|
|
84
|
+
};
|
|
85
|
+
if let Some((at, Term::Const(Constant::String(encoded)))) =
|
|
86
|
+
index.dereference(pc, argument)
|
|
87
|
+
&& let Some(decoded) = decode(&encoded, seed)
|
|
88
|
+
{
|
|
89
|
+
replacements.push((pc, path_index, effect_index, decoded));
|
|
90
|
+
decoded_inputs.push((at, encoded));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let decoded_at: HashSet<u32> = replacements.iter().map(|(pc, ..)| *pc).collect();
|
|
96
|
+
let string_decoders = decoders.keys().chain(factories.keys()).copied().collect();
|
|
97
|
+
for (pc, input) in decoded_inputs {
|
|
98
|
+
listing.decoded_inputs.entry(pc).or_default().insert(input);
|
|
99
|
+
}
|
|
100
|
+
listing.string_decoders = string_decoders;
|
|
101
|
+
for (pc, path, effect, decoded) in replacements {
|
|
102
|
+
let effects = &mut listing.instructions.get_mut(&pc).unwrap().paths[path].effects;
|
|
103
|
+
let temporary = match &effects[effect] {
|
|
104
|
+
Effect::Let(temporary, _) => Some(*temporary),
|
|
105
|
+
_ => None,
|
|
106
|
+
};
|
|
107
|
+
let value = Term::Const(Constant::String(decoded));
|
|
108
|
+
match &mut effects[effect] {
|
|
109
|
+
Effect::Let(_, term) | Effect::Set(_, term) => *term = value.clone(),
|
|
110
|
+
_ => unreachable!(),
|
|
111
|
+
}
|
|
112
|
+
if let Some(temporary) = temporary {
|
|
113
|
+
for following in &mut effects[effect + 1..] {
|
|
114
|
+
if let Effect::Set(_, term @ Term::Temp(_)) = following
|
|
115
|
+
&& *term == Term::Temp(temporary)
|
|
116
|
+
{
|
|
117
|
+
*term = value.clone();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
fold_cells(listing, &decoded_at);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
fn factory_result(
|
|
126
|
+
index: &Index<'_>,
|
|
127
|
+
pc: u32,
|
|
128
|
+
value: &Term,
|
|
129
|
+
factories: &HashMap<u32, u16>,
|
|
130
|
+
) -> Option<u16> {
|
|
131
|
+
let (at, Term::Call { callee, .. }) = index.dereference(pc, value)? else {
|
|
132
|
+
return None;
|
|
133
|
+
};
|
|
134
|
+
let (defined, Term::Closure { pc: factory, .. }) = index.dereference(at, &callee)? else {
|
|
135
|
+
return None;
|
|
136
|
+
};
|
|
137
|
+
let entry = index.entry_at_or_before(pc);
|
|
138
|
+
if entry != index.entry_at_or_before(at) || entry != index.entry_at_or_before(defined) {
|
|
139
|
+
return None;
|
|
140
|
+
}
|
|
141
|
+
factories.get(&factory).copied()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// Descendants capturing this cell, stopping at a new lexical binding of the same cell number.
|
|
145
|
+
fn scopes(index: &Index<'_>, parent: u32, cell: u32) -> HashSet<u32> {
|
|
146
|
+
let mut pending = vec![parent];
|
|
147
|
+
let mut seen = HashSet::new();
|
|
148
|
+
while let Some(entry) = pending.pop() {
|
|
149
|
+
if seen.contains(&entry)
|
|
150
|
+
|| (entry != parent
|
|
151
|
+
&& index.effects_in(index.function_at(entry)).any(
|
|
152
|
+
|(_, effect)| matches!(effect, Effect::NewCell(shadow) if *shadow == cell),
|
|
153
|
+
))
|
|
154
|
+
{
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
seen.insert(entry);
|
|
158
|
+
pending.extend(index.closures_in(index.function_at(entry)));
|
|
159
|
+
}
|
|
160
|
+
seen
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// Values assigned once in a lexical scope and captured by its descendants. Any other
|
|
164
|
+
/// write invalidates the binding, even if that write cannot itself be resolved.
|
|
165
|
+
fn captured_values<T: Clone + PartialEq>(
|
|
166
|
+
index: &Index<'_>,
|
|
167
|
+
resolve: impl Fn(u32, &Term) -> Option<T>,
|
|
168
|
+
) -> HashMap<(u32, u32), T> {
|
|
169
|
+
let mut values: HashMap<(u32, u32), Option<T>> = HashMap::new();
|
|
170
|
+
for (pc, effect) in index.effects_in(..) {
|
|
171
|
+
let Effect::SetCell(cell, assigned) = effect else {
|
|
172
|
+
continue;
|
|
173
|
+
};
|
|
174
|
+
let Some(value) = resolve(pc, assigned) else {
|
|
175
|
+
continue;
|
|
176
|
+
};
|
|
177
|
+
let Some(parent) = index.entry_at_or_before(pc) else {
|
|
178
|
+
continue;
|
|
179
|
+
};
|
|
180
|
+
let scopes = scopes(index, parent, *cell);
|
|
181
|
+
if scopes.iter().any(|&entry| {
|
|
182
|
+
index
|
|
183
|
+
.effects_in(index.function_at(entry))
|
|
184
|
+
.any(|(other, effect)| {
|
|
185
|
+
matches!(effect, Effect::SetCell(written, term)
|
|
186
|
+
if written == cell && (other != pc || term != assigned))
|
|
187
|
+
})
|
|
188
|
+
}) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
for entry in scopes {
|
|
192
|
+
values
|
|
193
|
+
.entry((entry, *cell))
|
|
194
|
+
.and_modify(|known| {
|
|
195
|
+
if known.as_ref() != Some(&value) {
|
|
196
|
+
*known = None;
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
.or_insert_with(|| Some(value.clone()));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
values
|
|
203
|
+
.into_iter()
|
|
204
|
+
.filter_map(|(cell, value)| value.map(|value| (cell, value)))
|
|
205
|
+
.collect()
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/// Decoder initialization commonly stores property names in cells for nested collectors. Only
|
|
209
|
+
/// propagate decoded strings whose captured binding has no other assignment in its scope.
|
|
210
|
+
fn fold_cells(listing: &mut Listing, decoded_at: &HashSet<u32>) {
|
|
211
|
+
let index = Index::new(listing);
|
|
212
|
+
let constants = captured_values(&index, |pc, value| {
|
|
213
|
+
let (at, Term::Const(Constant::String(text))) = index.dereference(pc, value)? else {
|
|
214
|
+
return None;
|
|
215
|
+
};
|
|
216
|
+
(decoded_at.contains(&at) && index.entry_at_or_before(at) == index.entry_at_or_before(pc))
|
|
217
|
+
.then_some(text)
|
|
218
|
+
});
|
|
219
|
+
let entries = index.entries().clone();
|
|
220
|
+
for (&pc, instruction) in &mut listing.instructions {
|
|
221
|
+
let Some(&entry) = entries.range(..=pc).next_back() else {
|
|
222
|
+
continue;
|
|
223
|
+
};
|
|
224
|
+
for path in &mut instruction.paths {
|
|
225
|
+
for effect in &mut path.effects {
|
|
226
|
+
if let Effect::Set(_, term @ Term::Cell(_)) = effect
|
|
227
|
+
&& let Term::Cell(cell) = term
|
|
228
|
+
&& let Some(text) = constants.get(&(entry, *cell))
|
|
229
|
+
{
|
|
230
|
+
*term = Term::Const(Constant::String(text.clone()));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/// Recognizes the decoder's byte rotation and its base64 / UTF-16 operations. The seed must
|
|
238
|
+
/// be a literal assignment before the first rotation; later iterations cannot invent a key.
|
|
239
|
+
fn decoder(index: &Index<'_>, entry: u32) -> Option<u16> {
|
|
240
|
+
let mut methods = HashSet::new();
|
|
241
|
+
let mut seeds = BTreeSet::new();
|
|
242
|
+
let mut escape = false;
|
|
243
|
+
for (pc, effect) in index.effects_in(index.function_at(entry)) {
|
|
244
|
+
effect.visit_terms(&mut |term| {
|
|
245
|
+
if let Term::Call { callee, .. } = term
|
|
246
|
+
&& let Some(method) = index.method(pc, callee)
|
|
247
|
+
{
|
|
248
|
+
methods.insert(method);
|
|
249
|
+
}
|
|
250
|
+
if let Term::Const(Constant::String(text)) = term {
|
|
251
|
+
methods.insert(text.clone());
|
|
252
|
+
}
|
|
253
|
+
if matches!(term, Term::Const(Constant::Number(255.0))) {
|
|
254
|
+
escape = true;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
if let Effect::Set(register, term) = effect
|
|
258
|
+
&& let Some(expanded) = expand(index, pc, term, *register, 14)
|
|
259
|
+
&& rotation(&expanded, *register)
|
|
260
|
+
&& let Some((_, Term::Const(Constant::Number(seed)))) = index.assignment(pc, *register)
|
|
261
|
+
&& (0.0..=65535.0).contains(&seed)
|
|
262
|
+
&& seed.fract() == 0.0
|
|
263
|
+
{
|
|
264
|
+
seeds.insert(seed as u16);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
(escape
|
|
268
|
+
&& ["atob", "push", "fromCharCode"]
|
|
269
|
+
.iter()
|
|
270
|
+
.all(|method| methods.contains(*method))
|
|
271
|
+
&& seeds.len() == 1)
|
|
272
|
+
.then(|| *seeds.first().unwrap())
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
fn expand(index: &Index<'_>, pc: u32, term: &Term, stop: u8, fuel: usize) -> Option<Term> {
|
|
276
|
+
if fuel == 0 {
|
|
277
|
+
return None;
|
|
278
|
+
}
|
|
279
|
+
match term {
|
|
280
|
+
Term::Reg(register) if *register != stop => {
|
|
281
|
+
let (at, value) = index.assignment(pc, *register)?;
|
|
282
|
+
expand(index, at, &value, stop, fuel - 1)
|
|
283
|
+
}
|
|
284
|
+
Term::Binary(operator, left, right) => {
|
|
285
|
+
let left = expand(index, pc, left, stop, fuel - 1)?;
|
|
286
|
+
let right = expand(index, pc, right, stop, fuel - 1)?;
|
|
287
|
+
if *operator == BinaryOperator::BitwiseXOR {
|
|
288
|
+
if left == Term::Const(Constant::Number(0.0)) {
|
|
289
|
+
return Some(right);
|
|
290
|
+
}
|
|
291
|
+
if right == Term::Const(Constant::Number(0.0)) {
|
|
292
|
+
return Some(left);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
Some(Term::Binary(*operator, Box::new(left), Box::new(right)))
|
|
296
|
+
}
|
|
297
|
+
Term::Reg(_) | Term::Const(Constant::Number(_)) => Some(term.clone()),
|
|
298
|
+
_ => None,
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
fn rotation(term: &Term, register: u8) -> bool {
|
|
303
|
+
let Term::Binary(BinaryOperator::BitwiseAnd, left, right) = term else {
|
|
304
|
+
return false;
|
|
305
|
+
};
|
|
306
|
+
let rotated = if **left == Term::Const(Constant::Number(65535.0)) {
|
|
307
|
+
right
|
|
308
|
+
} else if **right == Term::Const(Constant::Number(65535.0)) {
|
|
309
|
+
left
|
|
310
|
+
} else {
|
|
311
|
+
return false;
|
|
312
|
+
};
|
|
313
|
+
let Term::Binary(BinaryOperator::BitwiseOR, left, right) = &**rotated else {
|
|
314
|
+
return false;
|
|
315
|
+
};
|
|
316
|
+
let shift = |term: &Term, operator| {
|
|
317
|
+
matches!(term, Term::Binary(op, value, count)
|
|
318
|
+
if *op == operator && **value == Term::Reg(register)
|
|
319
|
+
&& **count == Term::Const(Constant::Number(8.0)))
|
|
320
|
+
};
|
|
321
|
+
(shift(left, BinaryOperator::ShiftLeft) && shift(right, BinaryOperator::ShiftRightZeroFill))
|
|
322
|
+
|| (shift(right, BinaryOperator::ShiftLeft)
|
|
323
|
+
&& shift(left, BinaryOperator::ShiftRightZeroFill))
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
fn decode(encoded: &str, mut key: u16) -> Option<String> {
|
|
327
|
+
let bytes = STANDARD.decode(encoded).ok()?;
|
|
328
|
+
let mut bytes = bytes.into_iter().map(|byte| {
|
|
329
|
+
key = key.rotate_left(8);
|
|
330
|
+
byte ^ (key >> 8) as u8
|
|
331
|
+
});
|
|
332
|
+
let mut units = Vec::new();
|
|
333
|
+
while let Some(byte) = bytes.next() {
|
|
334
|
+
units.push(if byte == 255 {
|
|
335
|
+
u16::from(bytes.next()?) | (u16::from(bytes.next()?) << 8)
|
|
336
|
+
} else {
|
|
337
|
+
u16::from(byte)
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
String::from_utf16(&units).ok()
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
#[cfg(test)]
|
|
344
|
+
mod tests {
|
|
345
|
+
use super::*;
|
|
346
|
+
use crate::vm::{Instruction, Path, Position};
|
|
347
|
+
|
|
348
|
+
#[test]
|
|
349
|
+
fn decodes_captured_names_and_utf16_escapes() {
|
|
350
|
+
assert_eq!(
|
|
351
|
+
decode("Ca8AsCyyC7g/sgazGw==", 56687).as_deref(),
|
|
352
|
+
Some("fromCodePoint")
|
|
353
|
+
);
|
|
354
|
+
assert_eq!(decode("Argcrg66Cg==", 56687).as_deref(), Some("message"));
|
|
355
|
+
// Literal 255, a surrogate pair, then ASCII. Every escaped byte advances the key.
|
|
356
|
+
let clear = [255, 255, 0, 255, 0x3d, 0xd8, 255, 0, 0xde, b'!'];
|
|
357
|
+
let cipher: Vec<u8> = clear
|
|
358
|
+
.iter()
|
|
359
|
+
.enumerate()
|
|
360
|
+
.map(|(i, byte)| byte ^ [0x34, 0x12][i % 2])
|
|
361
|
+
.collect();
|
|
362
|
+
assert_eq!(
|
|
363
|
+
decode(&STANDARD.encode(cipher), 0x1234).as_deref(),
|
|
364
|
+
Some("ÿ😀!")
|
|
365
|
+
);
|
|
366
|
+
assert!(decode("not base64!", 0).is_none());
|
|
367
|
+
assert!(decode(&STANDARD.encode([255, 1]), 0).is_none());
|
|
368
|
+
assert!(decode(&STANDARD.encode([255, 0, 0xd8]), 0).is_none());
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
fn number(value: f64) -> Term {
|
|
372
|
+
Term::Const(Constant::Number(value))
|
|
373
|
+
}
|
|
374
|
+
fn string(value: &str) -> Term {
|
|
375
|
+
Term::Const(Constant::String(value.to_owned()))
|
|
376
|
+
}
|
|
377
|
+
fn binary(op: BinaryOperator, left: Term, right: Term) -> Term {
|
|
378
|
+
Term::Binary(op, Box::new(left), Box::new(right))
|
|
379
|
+
}
|
|
380
|
+
fn rotate(mask: f64) -> Term {
|
|
381
|
+
binary(
|
|
382
|
+
BinaryOperator::BitwiseAnd,
|
|
383
|
+
number(mask),
|
|
384
|
+
binary(
|
|
385
|
+
BinaryOperator::BitwiseOR,
|
|
386
|
+
binary(BinaryOperator::ShiftLeft, Term::Reg(7), number(8.0)),
|
|
387
|
+
binary(
|
|
388
|
+
BinaryOperator::ShiftRightZeroFill,
|
|
389
|
+
Term::Reg(7),
|
|
390
|
+
number(8.0),
|
|
391
|
+
),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
fn closure(pc: u32) -> Term {
|
|
396
|
+
Term::Closure {
|
|
397
|
+
pc,
|
|
398
|
+
key: 0,
|
|
399
|
+
parameters: vec![],
|
|
400
|
+
arity: 1,
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
fn call(callee: Term, argument: Term) -> Term {
|
|
404
|
+
Term::Call {
|
|
405
|
+
callee: Box::new(callee),
|
|
406
|
+
this: None,
|
|
407
|
+
arguments: vec![argument],
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
fn insert(listing: &mut Listing, pc: u32, effects: Vec<Effect>, exit: Exit) {
|
|
411
|
+
listing.instructions.insert(
|
|
412
|
+
pc,
|
|
413
|
+
Instruction {
|
|
414
|
+
pc,
|
|
415
|
+
key: 0,
|
|
416
|
+
opcode: 0,
|
|
417
|
+
paths: vec![Path {
|
|
418
|
+
effects,
|
|
419
|
+
conditions: vec![],
|
|
420
|
+
exit,
|
|
421
|
+
}],
|
|
422
|
+
},
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
#[test]
|
|
427
|
+
fn folds_decoder_cells_only_inside_their_closure_scope() {
|
|
428
|
+
let mut listing = Listing {
|
|
429
|
+
functions: [0, 100, 200, 300, 400, 500]
|
|
430
|
+
.map(|pc| Position::new(pc, 0))
|
|
431
|
+
.into(),
|
|
432
|
+
..Listing::default()
|
|
433
|
+
};
|
|
434
|
+
let next = |pc| Exit::Next { pc, key: 0 };
|
|
435
|
+
// Decoder, factory, creator, child, unrelated function, shadowing child.
|
|
436
|
+
insert(
|
|
437
|
+
&mut listing,
|
|
438
|
+
0,
|
|
439
|
+
vec![Effect::Set(7, number(56687.0))],
|
|
440
|
+
next(1),
|
|
441
|
+
);
|
|
442
|
+
insert(
|
|
443
|
+
&mut listing,
|
|
444
|
+
1,
|
|
445
|
+
vec![
|
|
446
|
+
Effect::Set(7, rotate(65535.0)),
|
|
447
|
+
Effect::Set(8, string("atob")),
|
|
448
|
+
Effect::Set(9, string("push")),
|
|
449
|
+
Effect::Set(10, string("fromCharCode")),
|
|
450
|
+
Effect::Set(11, number(255.0)),
|
|
451
|
+
],
|
|
452
|
+
Exit::Return,
|
|
453
|
+
);
|
|
454
|
+
insert(
|
|
455
|
+
&mut listing,
|
|
456
|
+
100,
|
|
457
|
+
vec![Effect::Set(1, closure(0))],
|
|
458
|
+
next(101),
|
|
459
|
+
);
|
|
460
|
+
insert(
|
|
461
|
+
&mut listing,
|
|
462
|
+
101,
|
|
463
|
+
vec![Effect::Set(63, Term::Reg(1))],
|
|
464
|
+
Exit::Return,
|
|
465
|
+
);
|
|
466
|
+
insert(
|
|
467
|
+
&mut listing,
|
|
468
|
+
200,
|
|
469
|
+
vec![Effect::Set(1, closure(100))],
|
|
470
|
+
next(201),
|
|
471
|
+
);
|
|
472
|
+
insert(
|
|
473
|
+
&mut listing,
|
|
474
|
+
201,
|
|
475
|
+
vec![
|
|
476
|
+
Effect::Let(0, call(Term::Reg(1), Term::Global("globalThis".into()))),
|
|
477
|
+
Effect::Set(2, Term::Temp(0)),
|
|
478
|
+
],
|
|
479
|
+
next(202),
|
|
480
|
+
);
|
|
481
|
+
insert(
|
|
482
|
+
&mut listing,
|
|
483
|
+
202,
|
|
484
|
+
vec![
|
|
485
|
+
Effect::SetCell(17, Term::Reg(2)),
|
|
486
|
+
Effect::Set(3, closure(300)),
|
|
487
|
+
Effect::Set(4, closure(500)),
|
|
488
|
+
Effect::Set(5, string("Ca8AsCyyC7g/sgazGw==")),
|
|
489
|
+
Effect::Set(8, string("Argcrg66Cg==")),
|
|
490
|
+
],
|
|
491
|
+
next(203),
|
|
492
|
+
);
|
|
493
|
+
insert(
|
|
494
|
+
&mut listing,
|
|
495
|
+
203,
|
|
496
|
+
vec![
|
|
497
|
+
Effect::Let(0, call(Term::Reg(2), Term::Reg(5))),
|
|
498
|
+
Effect::Set(6, Term::Temp(0)),
|
|
499
|
+
Effect::Let(1, call(Term::Reg(2), Term::Reg(8))),
|
|
500
|
+
Effect::Set(9, Term::Temp(1)),
|
|
501
|
+
],
|
|
502
|
+
Exit::Return,
|
|
503
|
+
);
|
|
504
|
+
for entry in [300, 400, 500] {
|
|
505
|
+
let mut effects = vec![Effect::Set(1, string("Ca8AsCyyC7g/sgazGw=="))];
|
|
506
|
+
if entry == 500 {
|
|
507
|
+
effects.push(Effect::NewCell(17));
|
|
508
|
+
}
|
|
509
|
+
insert(&mut listing, entry, effects, next(entry + 1));
|
|
510
|
+
insert(
|
|
511
|
+
&mut listing,
|
|
512
|
+
entry + 1,
|
|
513
|
+
vec![
|
|
514
|
+
Effect::Let(0, call(Term::Cell(17), Term::Reg(1))),
|
|
515
|
+
Effect::Set(2, Term::Temp(0)),
|
|
516
|
+
],
|
|
517
|
+
Exit::Return,
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
let mut not_a_factory = listing.clone();
|
|
521
|
+
not_a_factory.instructions.get_mut(&101).unwrap().paths[0].effects = vec![
|
|
522
|
+
Effect::Set(63, Term::Const(Constant::Null)),
|
|
523
|
+
Effect::Set(10, closure(0)),
|
|
524
|
+
];
|
|
525
|
+
fold(&mut not_a_factory);
|
|
526
|
+
assert!(
|
|
527
|
+
not_a_factory.decoded_inputs.is_empty(),
|
|
528
|
+
"merely storing a decoder does not return it"
|
|
529
|
+
);
|
|
530
|
+
fold(&mut listing);
|
|
531
|
+
assert_eq!(
|
|
532
|
+
listing.instructions[&203].paths[0].effects[3],
|
|
533
|
+
Effect::Set(9, string("message"))
|
|
534
|
+
);
|
|
535
|
+
assert_eq!(
|
|
536
|
+
listing.decoded_inputs[&202],
|
|
537
|
+
BTreeSet::from(["Ca8AsCyyC7g/sgazGw==".to_owned(), "Argcrg66Cg==".to_owned(),])
|
|
538
|
+
);
|
|
539
|
+
assert_eq!(
|
|
540
|
+
listing.instructions[&203].paths[0].effects[1],
|
|
541
|
+
Effect::Set(6, string("fromCodePoint"))
|
|
542
|
+
);
|
|
543
|
+
assert_eq!(
|
|
544
|
+
listing.decoded_inputs.get(&300),
|
|
545
|
+
Some(&BTreeSet::from(["Ca8AsCyyC7g/sgazGw==".to_owned()]))
|
|
546
|
+
);
|
|
547
|
+
assert_eq!(
|
|
548
|
+
listing.instructions[&301].paths[0].effects[1],
|
|
549
|
+
Effect::Set(2, string("fromCodePoint"))
|
|
550
|
+
);
|
|
551
|
+
for pc in [401, 501] {
|
|
552
|
+
assert_eq!(
|
|
553
|
+
listing.instructions[&pc].paths[0].effects[1],
|
|
554
|
+
Effect::Set(2, Term::Temp(0))
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
assert!(rotation(&rotate(65535.0), 7));
|
|
558
|
+
assert!(!rotation(&rotate(255.0), 7));
|
|
559
|
+
assert!(!rotation(&rotate(65535.0), 8));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
#[test]
|
|
563
|
+
fn unknown_reassignments_invalidate_captured_values() {
|
|
564
|
+
for (write_pc, write) in [(0, Term::Reg(9)), (10, Term::Reg(9))] {
|
|
565
|
+
let mut listing = Listing {
|
|
566
|
+
functions: [0, 10].map(|pc| Position::new(pc, 0)).into(),
|
|
567
|
+
..Listing::default()
|
|
568
|
+
};
|
|
569
|
+
insert(
|
|
570
|
+
&mut listing,
|
|
571
|
+
0,
|
|
572
|
+
vec![
|
|
573
|
+
Effect::SetCell(7, number(42.0)),
|
|
574
|
+
Effect::Set(1, closure(10)),
|
|
575
|
+
],
|
|
576
|
+
Exit::Return,
|
|
577
|
+
);
|
|
578
|
+
insert(&mut listing, 10, vec![], Exit::Return);
|
|
579
|
+
listing.instructions.get_mut(&write_pc).unwrap().paths[0]
|
|
580
|
+
.effects
|
|
581
|
+
.push(Effect::SetCell(7, write));
|
|
582
|
+
let index = Index::new(&listing);
|
|
583
|
+
let values = captured_values(&index, |_, term| match term {
|
|
584
|
+
Term::Const(Constant::Number(value)) => Some(*value),
|
|
585
|
+
_ => None,
|
|
586
|
+
});
|
|
587
|
+
assert!(
|
|
588
|
+
values.is_empty(),
|
|
589
|
+
"an unknown write at {write_pc} must invalidate the binding"
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
#[test]
|
|
595
|
+
fn propagates_decoded_cells_but_keeps_mutable_bindings_unknown() {
|
|
596
|
+
for mutable in [false, true] {
|
|
597
|
+
let mut listing = Listing {
|
|
598
|
+
functions: [0, 10].map(|pc| Position::new(pc, 0)).into(),
|
|
599
|
+
..Listing::default()
|
|
600
|
+
};
|
|
601
|
+
insert(
|
|
602
|
+
&mut listing,
|
|
603
|
+
0,
|
|
604
|
+
vec![Effect::Set(1, string("length"))],
|
|
605
|
+
Exit::Next { pc: 1, key: 0 },
|
|
606
|
+
);
|
|
607
|
+
insert(
|
|
608
|
+
&mut listing,
|
|
609
|
+
1,
|
|
610
|
+
vec![
|
|
611
|
+
Effect::SetCell(7, Term::Reg(1)),
|
|
612
|
+
Effect::Set(2, closure(10)),
|
|
613
|
+
],
|
|
614
|
+
Exit::Return,
|
|
615
|
+
);
|
|
616
|
+
let mut effects = vec![Effect::Set(3, Term::Cell(7))];
|
|
617
|
+
if mutable {
|
|
618
|
+
effects.push(Effect::SetCell(7, string("changed")));
|
|
619
|
+
}
|
|
620
|
+
insert(&mut listing, 10, effects, Exit::Return);
|
|
621
|
+
fold_cells(&mut listing, &HashSet::from([0]));
|
|
622
|
+
assert_eq!(
|
|
623
|
+
listing.instructions[&10].paths[0].effects[0],
|
|
624
|
+
Effect::Set(
|
|
625
|
+
3,
|
|
626
|
+
if mutable {
|
|
627
|
+
Term::Cell(7)
|
|
628
|
+
} else {
|
|
629
|
+
string("length")
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|