cfsolve 0.1.1 → 0.1.3
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 +18 -0
- data/README.md +10 -9
- 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 +10 -8
- 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/safari-26-ios/answers.json +2570 -1894
- data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
- data/lib/cfsolve/profiles/safari-26-ios.json +102 -156
- data/lib/cfsolve/version.rb +2 -2
- data/vendor/cfsolve/Cargo.lock +561 -1729
- data/vendor/cfsolve/Cargo.toml +26 -8
- data/vendor/cfsolve/README.md +4 -35
- data/vendor/cfsolve/examples/build_profile.rs +17 -15
- data/vendor/cfsolve/examples/capture_session.rs +37 -0
- data/vendor/cfsolve/examples/check_answers.rs +66 -0
- data/vendor/cfsolve/examples/compare_session.rs +189 -0
- 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 +6 -3
- data/vendor/cfsolve/examples/tls_echo.rs +3 -3
- data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
- data/vendor/cfsolve/profiles/safari-26-ios/answers.json +2570 -1894
- data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +1867 -1192
- data/vendor/cfsolve/profiles/safari-26-ios.json +102 -156
- data/vendor/cfsolve/scripts/capture_cssom.mjs +42 -0
- data/vendor/cfsolve/scripts/serve_cssom.py +111 -0
- 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/profile.rs +7 -18
- data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
- data/vendor/cfsolve/src/capture/proxy.rs +44 -13
- data/vendor/cfsolve/src/capture/recorded.rs +42 -7
- 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 +132 -0
- data/vendor/cfsolve/src/challenge/installed.rs +127 -269
- 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 +175 -35
- 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 +236 -122
- 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 +201 -205
- data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
- data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +346 -536
- 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 +361 -322
- 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 +23 -32
- data/vendor/cfsolve/src/embedding_page/page.rs +28 -2
- 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 +9 -1
- data/vendor/cfsolve/src/http/requests.rs +2 -2
- data/vendor/cfsolve/src/js/ast.rs +479 -254
- data/vendor/cfsolve/src/js/objects.rs +9 -2
- data/vendor/cfsolve/src/lib.rs +1 -0
- data/vendor/cfsolve/src/listing/fold.rs +19 -92
- data/vendor/cfsolve/src/listing/query.rs +26 -291
- data/vendor/cfsolve/src/listing.rs +0 -1
- 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 +19 -10
- data/vendor/cfsolve/src/session/probes.rs +160 -125
- 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/timing.rs +58 -53
- data/vendor/cfsolve/src/session/widget.rs +5 -6
- data/vendor/cfsolve/src/session.rs +1 -1
- data/vendor/cfsolve/src/solver.rs +3 -1
- data/vendor/cfsolve/src/stage2/analysis/analyze.rs +50 -33
- data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
- data/vendor/cfsolve/src/stage2/analysis/discovery.rs +61 -66
- data/vendor/cfsolve/src/stage2/analysis/envelope.rs +33 -22
- data/vendor/cfsolve/src/stage2/analysis/recognize.rs +3 -5
- data/vendor/cfsolve/src/stage2/analysis.rs +0 -1
- data/vendor/cfsolve/src/stage2/audit_globals.rs +378 -0
- data/vendor/cfsolve/src/stage2/benchmark.rs +66 -38
- data/vendor/cfsolve/src/stage2/call_stack.rs +1463 -1017
- data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
- 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/native.rs +2 -1
- data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -7
- data/vendor/cfsolve/src/stage2/payload/recover.rs +56 -25
- data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
- data/vendor/cfsolve/src/stage2/probes/ice.rs +11 -10
- data/vendor/cfsolve/src/stage2/probes/media.rs +47 -33
- data/vendor/cfsolve/src/stage2/probes/performance.rs +13 -8
- data/vendor/cfsolve/src/stage2/probes/rects.rs +12 -17
- data/vendor/cfsolve/src/stage2/probes/stack.rs +50 -103
- data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +17 -86
- data/vendor/cfsolve/src/stage2/probes.rs +0 -1
- data/vendor/cfsolve/src/stage2/queries.rs +50 -0
- data/vendor/cfsolve/src/stage2/records.rs +4 -13
- data/vendor/cfsolve/src/stage2/reference.json +1 -1
- data/vendor/cfsolve/src/stage2/reference.rs +98 -100
- data/vendor/cfsolve/src/stage2/registry.rs +41 -34
- data/vendor/cfsolve/src/stage2/replay.rs +182 -254
- data/vendor/cfsolve/src/stage2/stylesheets.rs +176 -0
- data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
- data/vendor/cfsolve/src/stage2/trace.rs +152 -108
- data/vendor/cfsolve/src/stage2/vocabulary.rs +103 -403
- data/vendor/cfsolve/src/stage2.rs +4 -1
- data/vendor/cfsolve/src/vm/disassemble.rs +46 -13
- data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
- data/vendor/cfsolve/src/vm/extract.rs +347 -250
- data/vendor/cfsolve/src/vm/interpret/access.rs +67 -68
- data/vendor/cfsolve/src/vm/interpret/builtin.rs +16 -63
- data/vendor/cfsolve/src/vm/interpret/call.rs +192 -51
- data/vendor/cfsolve/src/vm/interpret/compile.rs +643 -0
- data/vendor/cfsolve/src/vm/interpret/copies.rs +232 -120
- data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +149 -40
- data/vendor/cfsolve/src/vm/interpret/evaluate.rs +189 -572
- data/vendor/cfsolve/src/vm/interpret/explore.rs +159 -46
- data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
- data/vendor/cfsolve/src/vm/interpret/frozen.rs +169 -0
- data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +414 -0
- 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 +1736 -0
- data/vendor/cfsolve/src/vm/interpret/plan.rs +605 -330
- data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +384 -0
- data/vendor/cfsolve/src/vm/interpret/run.rs +314 -54
- 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 +16 -3
- data/vendor/cfsolve/src/vm/machine.rs +58 -47
- data/vendor/cfsolve/src/vm/output.rs +13 -5
- data/vendor/cfsolve/src/vm/packed_names.rs +311 -0
- data/vendor/cfsolve/src/vm/session.rs +197 -110
- data/vendor/cfsolve/src/vm/value.rs +35 -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
- data/vendor/cfsolve/vendor/btls-sys/src/lib.rs +3 -0
- metadata +106 -183
- 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/vendor/cfsolve/src/listing/normalize.rs +0 -264
- data/vendor/cfsolve/src/stage2/analysis/outputs.rs +0 -327
- data/vendor/cfsolve/src/stage2/probes/stylesheets.rs +0 -249
- data/vendor/cfsolve/src/stage2/reference-expanded.json +0 -42
- data/vendor/cfsolve/src/stage2/session_names.rs +0 -470
- /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
|
@@ -7,12 +7,15 @@ use std::ops::RangeInclusive;
|
|
|
7
7
|
use anyhow::{Context, Result};
|
|
8
8
|
use base64::engine::general_purpose::STANDARD;
|
|
9
9
|
use num_bigint::BigUint;
|
|
10
|
-
use
|
|
11
|
-
use
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
use oxc::ast::AstKind;
|
|
11
|
+
use oxc::ast::ast::{
|
|
12
|
+
Argument, ArrowFunctionExpression, AssignmentExpression, AssignmentTarget, BindingPattern,
|
|
13
|
+
CallExpression, Expression, Function, FunctionBody, IfStatement, ObjectExpression, Statement,
|
|
14
|
+
VariableDeclarator,
|
|
14
15
|
};
|
|
15
|
-
use
|
|
16
|
+
use oxc::ast_visit::{Visit, walk};
|
|
17
|
+
use oxc::semantic::ScopeFlags;
|
|
18
|
+
use serde::Serialize;
|
|
16
19
|
use url::Url;
|
|
17
20
|
|
|
18
21
|
use crate::challenge::codec::{Codec, KEY_LENGTH, SEED_LENGTH};
|
|
@@ -22,7 +25,7 @@ use crate::challenge::merge::Mapping;
|
|
|
22
25
|
use crate::challenge::payload::Field;
|
|
23
26
|
use crate::challenge::source::{self, InitialRequest};
|
|
24
27
|
use crate::challenge::state::ScriptState;
|
|
25
|
-
use crate::js::ast::{self,
|
|
28
|
+
use crate::js::ast::{self, Binding, Script};
|
|
26
29
|
use crate::js::{JsValue, Options, Payload};
|
|
27
30
|
use crate::script::Source;
|
|
28
31
|
use crate::{candidates, vm};
|
|
@@ -57,15 +60,10 @@ impl ExtractedProgram {
|
|
|
57
60
|
pub fn session_encoder(&self) -> Result<SessionEncoder> {
|
|
58
61
|
let mut seed = [0; SEED_LENGTH];
|
|
59
62
|
getrandom::fill(&mut seed).context("drawing the session key seed")?;
|
|
60
|
-
Ok(
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#[must_use]
|
|
64
|
-
pub fn session_encoder_with_seed(&self, seed: [u8; SEED_LENGTH]) -> SessionEncoder {
|
|
65
|
-
SessionEncoder {
|
|
63
|
+
Ok(SessionEncoder {
|
|
66
64
|
codec: self.codec.clone(),
|
|
67
65
|
seed,
|
|
68
|
-
}
|
|
66
|
+
})
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
#[must_use]
|
|
@@ -122,7 +120,7 @@ pub struct ExportedField<'program> {
|
|
|
122
120
|
/// An extracted program and its parsed source. Parameter merging and iframe state are recovered
|
|
123
121
|
/// from the source on demand.
|
|
124
122
|
pub struct PreparedSession<'source> {
|
|
125
|
-
|
|
123
|
+
script: Script<'source>,
|
|
126
124
|
program: ExtractedProgram,
|
|
127
125
|
}
|
|
128
126
|
|
|
@@ -132,33 +130,32 @@ impl<'source> PreparedSession<'source> {
|
|
|
132
130
|
pub fn try_new(source: &'source Source, iframe_url: &Url) -> Result<Self> {
|
|
133
131
|
use base64::Engine;
|
|
134
132
|
|
|
135
|
-
let
|
|
136
|
-
let request = InitialRequest::
|
|
137
|
-
let runner =
|
|
138
|
-
vm::runner_name(&parsed.script).context("the script installs no program runner")?;
|
|
133
|
+
let script = source.script();
|
|
134
|
+
let request = InitialRequest::from_script(script, iframe_url)?;
|
|
135
|
+
let runner = vm::runner_name(script).context("the script installs no program runner")?;
|
|
139
136
|
let mut components = Components {
|
|
140
|
-
|
|
137
|
+
script,
|
|
141
138
|
options: &request.options,
|
|
142
139
|
runner,
|
|
143
140
|
encoders: BTreeSet::new(),
|
|
144
141
|
programs: BTreeMap::new(),
|
|
145
142
|
templates: Vec::new(),
|
|
146
143
|
};
|
|
147
|
-
|
|
144
|
+
components.visit_program(script.program);
|
|
148
145
|
let encoder = candidates::exactly_one(components.encoders, "XHR body encoder")?;
|
|
149
146
|
let (initial_program, initialize_key) =
|
|
150
147
|
candidates::exactly_one(components.programs, "literal initial VM program")?;
|
|
151
148
|
let payload_fields =
|
|
152
|
-
candidates::exactly_one(components.templates, "first payload template")
|
|
149
|
+
candidates::exactly_one(components.templates, "first payload template")??;
|
|
153
150
|
|
|
154
151
|
// The encoder assignment may be a standalone statement or part of a sequence or chain.
|
|
155
152
|
// Search within IIFE statements without entering their nested functions.
|
|
156
153
|
let mut root = EncoderRoot {
|
|
157
|
-
|
|
158
|
-
encoder
|
|
154
|
+
script,
|
|
155
|
+
encoder,
|
|
159
156
|
found: None,
|
|
160
157
|
};
|
|
161
|
-
|
|
158
|
+
root.visit_program(script.program);
|
|
162
159
|
let root = root
|
|
163
160
|
.found
|
|
164
161
|
.context("could not locate encoder's enclosing IIFE")??;
|
|
@@ -185,7 +182,7 @@ impl<'source> PreparedSession<'source> {
|
|
|
185
182
|
let program = ExtractedProgram {
|
|
186
183
|
request,
|
|
187
184
|
iframe_url: iframe_url.clone(),
|
|
188
|
-
encoder,
|
|
185
|
+
encoder: script.name(encoder).to_owned(),
|
|
189
186
|
key_transform: root.key_transform,
|
|
190
187
|
initialize_key,
|
|
191
188
|
installed,
|
|
@@ -193,7 +190,7 @@ impl<'source> PreparedSession<'source> {
|
|
|
193
190
|
codec: Codec::try_new(&root.alphabet, root.modulus, secret)?,
|
|
194
191
|
payload_fields,
|
|
195
192
|
};
|
|
196
|
-
Ok(Self {
|
|
193
|
+
Ok(Self { script, program })
|
|
197
194
|
}
|
|
198
195
|
|
|
199
196
|
#[must_use]
|
|
@@ -208,11 +205,11 @@ impl<'source> PreparedSession<'source> {
|
|
|
208
205
|
|
|
209
206
|
/// How this session merges the embedding page's `extraParams`.
|
|
210
207
|
pub fn mapping(&self) -> Result<Mapping> {
|
|
211
|
-
Mapping::
|
|
208
|
+
Mapping::from_script(self.script)
|
|
212
209
|
}
|
|
213
210
|
|
|
214
211
|
pub fn state(&self) -> Result<ScriptState> {
|
|
215
|
-
ScriptState::
|
|
212
|
+
ScriptState::from_script(self.script, &self.program.request.options)
|
|
216
213
|
}
|
|
217
214
|
}
|
|
218
215
|
|
|
@@ -225,78 +222,74 @@ struct Root {
|
|
|
225
222
|
}
|
|
226
223
|
|
|
227
224
|
impl Root {
|
|
228
|
-
fn read
|
|
225
|
+
fn read<'a>(
|
|
226
|
+
script: Script<'a>,
|
|
227
|
+
root: &FunctionBody<'a>,
|
|
228
|
+
definition: &Expression<'a>,
|
|
229
|
+
) -> Result<Self> {
|
|
229
230
|
Ok(Self {
|
|
230
|
-
key_transform: key_transform(
|
|
231
|
-
alphabet: base64_alphabet(ast::string_literals(
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
key_transform: key_transform(script, definition)?,
|
|
232
|
+
alphabet: base64_alphabet(ast::string_literals(|literals| {
|
|
233
|
+
literals.visit_function_body(root);
|
|
234
|
+
}))?,
|
|
235
|
+
modulus: rsa_modulus(script, root)?,
|
|
236
|
+
bootstrap: bootstrap(script, root),
|
|
234
237
|
})
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
|
|
238
241
|
/// Finds the outermost immediately invoked function that defines the encoder. Calls `read`
|
|
239
242
|
/// while the borrowed syntax node is valid.
|
|
240
|
-
struct EncoderRoot<'
|
|
241
|
-
|
|
242
|
-
encoder:
|
|
243
|
+
struct EncoderRoot<'a> {
|
|
244
|
+
script: Script<'a>,
|
|
245
|
+
encoder: Binding<'a>,
|
|
243
246
|
found: Option<Result<Root>>,
|
|
244
247
|
}
|
|
245
248
|
|
|
246
|
-
impl Visit for EncoderRoot<'
|
|
247
|
-
fn
|
|
249
|
+
impl<'a> Visit<'a> for EncoderRoot<'a> {
|
|
250
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
248
251
|
if self.found.is_some() {
|
|
249
252
|
return;
|
|
250
253
|
}
|
|
251
|
-
if let
|
|
252
|
-
&& let
|
|
253
|
-
&& let Some(body) = &function.function.body
|
|
254
|
+
if let Expression::FunctionExpression(function) = call.callee.without_parentheses()
|
|
255
|
+
&& let Some(body) = &function.body
|
|
254
256
|
&& let Some(definition) = body
|
|
255
|
-
.
|
|
257
|
+
.statements
|
|
256
258
|
.iter()
|
|
257
|
-
.find_map(|statement| defines(statement, self.encoder))
|
|
259
|
+
.find_map(|statement| defines(self.script, statement, self.encoder))
|
|
258
260
|
{
|
|
259
|
-
self.found = Some(Root::read(body,
|
|
261
|
+
self.found = Some(Root::read(self.script, body, definition));
|
|
260
262
|
return;
|
|
261
263
|
}
|
|
262
|
-
|
|
264
|
+
walk::walk_call_expression(self, call);
|
|
263
265
|
}
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
/// Finds the encoder callee created by the VM at runtime. It is the only callee
|
|
267
|
-
///
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
/// Finds the encoder callee created by the VM at runtime. It is the only callee in `definition`
|
|
269
|
+
/// that no binding of the script declares and that the script never assigns as a global; any
|
|
270
|
+
/// remaining deobfuscation helpers have bindings.
|
|
271
|
+
fn key_transform(script: Script<'_>, definition: &Expression<'_>) -> Result<String> {
|
|
272
|
+
let mut calls = Calls {
|
|
273
|
+
script,
|
|
274
|
+
globals: BTreeSet::new(),
|
|
275
|
+
};
|
|
276
|
+
calls.visit_expression(definition);
|
|
277
|
+
let unresolved = script.scoping.root_unresolved_references();
|
|
278
|
+
let assigned = |name: &str| {
|
|
279
|
+
unresolved.get(name).is_some_and(|references| {
|
|
280
|
+
references
|
|
281
|
+
.iter()
|
|
282
|
+
.any(|&reference| script.scoping.get_reference(reference).is_write())
|
|
283
|
+
})
|
|
284
|
+
};
|
|
273
285
|
let unbound = calls
|
|
274
|
-
.
|
|
286
|
+
.globals
|
|
275
287
|
.into_iter()
|
|
276
|
-
.filter(|name| name != "Number" && !
|
|
288
|
+
.filter(|name| *name != "Number" && !assigned(name))
|
|
289
|
+
.map(str::to_owned);
|
|
277
290
|
candidates::exactly_one(unbound, "VM-defined key transform")
|
|
278
291
|
}
|
|
279
292
|
|
|
280
|
-
/// Names declared or assigned anywhere in the script.
|
|
281
|
-
#[derive(Default)]
|
|
282
|
-
struct Bound(BTreeSet<String>);
|
|
283
|
-
|
|
284
|
-
impl Visit for Bound {
|
|
285
|
-
fn visit_binding_ident(&mut self, identifier: &BindingIdent) {
|
|
286
|
-
self.0.insert(identifier.sym.to_string());
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
fn visit_fn_decl(&mut self, declaration: &FnDecl) {
|
|
290
|
-
self.0.insert(declaration.ident.sym.to_string());
|
|
291
|
-
declaration.visit_children_with(self);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
fn visit_class_decl(&mut self, declaration: &ClassDecl) {
|
|
295
|
-
self.0.insert(declaration.ident.sym.to_string());
|
|
296
|
-
declaration.visit_children_with(self);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
293
|
/// Finds the custom base64 alphabet in `candidates`: a string with 64 distinct ASCII characters and
|
|
301
294
|
/// optional trailing padding.
|
|
302
295
|
pub(crate) fn base64_alphabet(candidates: impl IntoIterator<Item = String>) -> Result<String> {
|
|
@@ -313,177 +306,208 @@ pub(crate) fn base64_alphabet(candidates: impl IntoIterator<Item = String>) -> R
|
|
|
313
306
|
}
|
|
314
307
|
|
|
315
308
|
/// Finds the `BigInt("0x...")` modulus wide enough to encrypt the seed.
|
|
316
|
-
fn rsa_modulus(root: &
|
|
309
|
+
fn rsa_modulus(script: Script<'_>, root: &FunctionBody<'_>) -> Result<BigUint> {
|
|
317
310
|
let moduli = expression::assignments(root)
|
|
318
|
-
.filter_map(|assignment| big_int(&assignment.right))
|
|
311
|
+
.filter_map(|assignment| big_int(script, &assignment.right))
|
|
319
312
|
.filter_map(|literal| BigUint::parse_bytes(literal.strip_prefix("0x")?.as_bytes(), 16))
|
|
320
313
|
.filter(|modulus| modulus.bits().div_ceil(8) == SEED_LENGTH as u64);
|
|
321
314
|
candidates::exactly_one(moduli, "RSA modulus")
|
|
322
315
|
}
|
|
323
316
|
|
|
324
|
-
/// The string `BigInt` is called with.
|
|
325
|
-
fn big_int(expression: &
|
|
317
|
+
/// The string the global `BigInt` is called with.
|
|
318
|
+
fn big_int<'a>(script: Script<'_>, expression: &Expression<'a>) -> Option<&'a str> {
|
|
326
319
|
let (name, arguments) = ast::direct_call(expression)?;
|
|
327
|
-
|
|
320
|
+
let global = name.name == "BigInt" && script.symbol(name).is_none();
|
|
321
|
+
ast::static_str(arguments.first()?.as_expression()?).filter(|_| global)
|
|
328
322
|
}
|
|
329
323
|
|
|
330
324
|
/// Returns source for the IIFE without browser activity. Keeps VM tables, declarations, key
|
|
331
325
|
/// generation, and the encoder. Removes startup calls, timers, UI code, and event collection.
|
|
332
|
-
fn bootstrap(
|
|
326
|
+
fn bootstrap(script: Script<'_>, root: &FunctionBody<'_>) -> String {
|
|
333
327
|
let inert: Vec<&str> = root
|
|
334
|
-
.
|
|
328
|
+
.statements
|
|
335
329
|
.iter()
|
|
336
330
|
.filter(|statement| is_inert(statement))
|
|
337
|
-
.map(|statement|
|
|
331
|
+
.map(|statement| script.text(statement))
|
|
338
332
|
.collect();
|
|
339
333
|
inert.join("\n")
|
|
340
334
|
}
|
|
341
335
|
|
|
342
336
|
/// Whether a top-level statement can run without starting browser work.
|
|
343
|
-
fn is_inert(statement: &
|
|
337
|
+
fn is_inert(statement: &Statement<'_>) -> bool {
|
|
344
338
|
match statement {
|
|
345
339
|
// A conditional that only installs functions does not run their bodies.
|
|
346
|
-
|
|
347
|
-
block.
|
|
348
|
-
expression::assignment(statement)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
340
|
+
Statement::IfStatement(conditional) => match &conditional.consequent {
|
|
341
|
+
Statement::BlockStatement(block) => block.body.iter().all(|statement| {
|
|
342
|
+
expression::assignment(statement).is_some_and(|assigned| {
|
|
343
|
+
matches!(assigned.right, Expression::FunctionExpression(_))
|
|
344
|
+
})
|
|
345
|
+
}),
|
|
346
|
+
_ => false,
|
|
347
|
+
},
|
|
352
348
|
// A property assignment from a call publishes browser work that must be skipped.
|
|
353
349
|
// Indexed writes such as `seed[0] = Number(two)` update encoder state and are allowed.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if !
|
|
357
|
-
|
|
350
|
+
Statement::ExpressionStatement(statement) => {
|
|
351
|
+
!matches!(&statement.expression, Expression::AssignmentExpression(assignment)
|
|
352
|
+
if matches!(
|
|
353
|
+
assignment.left,
|
|
354
|
+
AssignmentTarget::StaticMemberExpression(_)
|
|
355
|
+
| AssignmentTarget::PrivateFieldExpression(_)
|
|
356
|
+
) && matches!(assignment.right, Expression::CallExpression(_)))
|
|
357
|
+
}
|
|
358
358
|
_ => true,
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
362
|
+
/// Reads the fields of a payload `template`, parsing each from its source in `script`.
|
|
363
|
+
fn payload_fields(
|
|
364
|
+
script: Script<'_>,
|
|
365
|
+
template: &ObjectExpression<'_>,
|
|
366
|
+
options: &Options,
|
|
367
|
+
) -> Result<Vec<Field>> {
|
|
368
|
+
let fields = ast::key_values(template).filter_map(|property| {
|
|
369
|
+
Some(Field::parse(
|
|
370
|
+
ast::static_key_str(&property.key, property.computed)?.to_owned(),
|
|
371
|
+
script.text(&property.value).to_owned(),
|
|
372
|
+
expression::static_value(script, &property.value, options),
|
|
373
|
+
))
|
|
374
|
+
});
|
|
375
|
+
fields.collect()
|
|
375
376
|
}
|
|
376
377
|
|
|
377
|
-
/// Finds the function assigned to `
|
|
378
|
-
fn defines
|
|
379
|
-
|
|
380
|
-
statement
|
|
378
|
+
/// Finds the function assigned to `encoder` within a statement.
|
|
379
|
+
fn defines<'a>(
|
|
380
|
+
script: Script<'a>,
|
|
381
|
+
statement: &Statement<'a>,
|
|
382
|
+
encoder: Binding<'a>,
|
|
383
|
+
) -> Option<&'a Expression<'a>> {
|
|
384
|
+
let mut definition = Definition {
|
|
385
|
+
script,
|
|
386
|
+
encoder,
|
|
387
|
+
found: None,
|
|
388
|
+
};
|
|
389
|
+
definition.visit_statement(statement);
|
|
381
390
|
definition.found
|
|
382
391
|
}
|
|
383
392
|
|
|
384
|
-
struct Definition<'
|
|
385
|
-
|
|
386
|
-
|
|
393
|
+
struct Definition<'a> {
|
|
394
|
+
script: Script<'a>,
|
|
395
|
+
encoder: Binding<'a>,
|
|
396
|
+
found: Option<&'a Expression<'a>>,
|
|
387
397
|
}
|
|
388
398
|
|
|
389
|
-
impl Visit for Definition<'
|
|
399
|
+
impl<'a> Visit<'a> for Definition<'a> {
|
|
390
400
|
// A declared function's own body belongs to it, not to the IIFE around it.
|
|
391
|
-
fn visit_function(&mut self, _: &Function) {}
|
|
392
|
-
fn
|
|
393
|
-
|
|
394
|
-
fn
|
|
395
|
-
if let
|
|
396
|
-
&&
|
|
397
|
-
&& let Some(function) = yielded_function(
|
|
401
|
+
fn visit_function(&mut self, _: &Function<'a>, _: ScopeFlags) {}
|
|
402
|
+
fn visit_arrow_function_expression(&mut self, _: &ArrowFunctionExpression<'a>) {}
|
|
403
|
+
|
|
404
|
+
fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
|
|
405
|
+
if let AssignmentTarget::AssignmentTargetIdentifier(target) = &assignment.left
|
|
406
|
+
&& self.script.binding(target) == self.encoder
|
|
407
|
+
&& let Some(function) = yielded_function(
|
|
408
|
+
&self
|
|
409
|
+
.script
|
|
410
|
+
.lend(assignment, AstKind::as_assignment_expression)
|
|
411
|
+
.right,
|
|
412
|
+
)
|
|
398
413
|
{
|
|
399
|
-
self.found = Some(function
|
|
414
|
+
self.found = Some(function);
|
|
400
415
|
}
|
|
401
|
-
|
|
416
|
+
walk::walk_assignment_expression(self, assignment);
|
|
402
417
|
}
|
|
403
418
|
|
|
404
|
-
fn
|
|
405
|
-
if let
|
|
406
|
-
&& target.
|
|
407
|
-
&& let Some(
|
|
419
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
420
|
+
if let BindingPattern::BindingIdentifier(target) = &declarator.id
|
|
421
|
+
&& Binding::Symbol(target.symbol_id()) == self.encoder
|
|
422
|
+
&& let Some(init) = &self
|
|
423
|
+
.script
|
|
424
|
+
.lend(declarator, AstKind::as_variable_declarator)
|
|
425
|
+
.init
|
|
426
|
+
&& let Some(function) = yielded_function(init)
|
|
408
427
|
{
|
|
409
|
-
self.found = Some(function
|
|
428
|
+
self.found = Some(function);
|
|
410
429
|
}
|
|
411
|
-
|
|
430
|
+
walk::walk_variable_declarator(self, declarator);
|
|
412
431
|
}
|
|
413
432
|
}
|
|
414
433
|
|
|
415
434
|
/// Finds the function produced by `value`, including through sequence expressions. Some sessions
|
|
416
435
|
/// reset the seed just before returning the encoder function.
|
|
417
|
-
fn yielded_function(value: &
|
|
418
|
-
let mut value = value.
|
|
419
|
-
while let
|
|
420
|
-
value = sequence.
|
|
436
|
+
fn yielded_function<'b, 'a>(value: &'b Expression<'a>) -> Option<&'b Expression<'a>> {
|
|
437
|
+
let mut value = value.without_parentheses();
|
|
438
|
+
while let Expression::SequenceExpression(sequence) = value {
|
|
439
|
+
value = sequence.expressions.last()?.without_parentheses();
|
|
421
440
|
}
|
|
422
|
-
matches!(
|
|
441
|
+
matches!(
|
|
442
|
+
value,
|
|
443
|
+
Expression::FunctionExpression(_) | Expression::ArrowFunctionExpression(_)
|
|
444
|
+
)
|
|
445
|
+
.then_some(value)
|
|
423
446
|
}
|
|
424
447
|
|
|
425
|
-
/// The
|
|
426
|
-
|
|
427
|
-
|
|
448
|
+
/// The globals called directly, as `name(...)`.
|
|
449
|
+
struct Calls<'a> {
|
|
450
|
+
script: Script<'a>,
|
|
451
|
+
globals: BTreeSet<&'a str>,
|
|
452
|
+
}
|
|
428
453
|
|
|
429
|
-
impl Visit for Calls {
|
|
430
|
-
fn
|
|
431
|
-
if let
|
|
432
|
-
&&
|
|
454
|
+
impl<'a> Visit<'a> for Calls<'a> {
|
|
455
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
456
|
+
if let Expression::Identifier(name) = &call.callee
|
|
457
|
+
&& self.script.symbol(name).is_none()
|
|
433
458
|
{
|
|
434
|
-
self.
|
|
459
|
+
self.globals.insert(name.name.as_str());
|
|
435
460
|
}
|
|
436
|
-
|
|
461
|
+
walk::walk_call_expression(self, call);
|
|
437
462
|
}
|
|
438
463
|
}
|
|
439
464
|
|
|
440
465
|
/// Collects components for [`PreparedSession::try_new`].
|
|
441
|
-
struct Components<'session> {
|
|
442
|
-
|
|
466
|
+
struct Components<'session, 'a> {
|
|
467
|
+
script: Script<'a>,
|
|
443
468
|
options: &'session Options,
|
|
444
469
|
/// The name the program runner is installed under.
|
|
445
470
|
runner: String,
|
|
446
471
|
/// Functions whose result is handed straight to `send`.
|
|
447
|
-
encoders: BTreeSet<
|
|
472
|
+
encoders: BTreeSet<Binding<'a>>,
|
|
448
473
|
/// Literal programs passed to the runner, each with the source of its first call.
|
|
449
474
|
/// Orchestrators may repeat a program for different startup paths.
|
|
450
475
|
programs: BTreeMap<String, String>,
|
|
451
|
-
templates: Vec<Vec<Field
|
|
476
|
+
templates: Vec<Result<Vec<Field>>>,
|
|
452
477
|
}
|
|
453
478
|
|
|
454
|
-
impl Visit for Components<'_> {
|
|
455
|
-
fn
|
|
479
|
+
impl<'a> Visit<'a> for Components<'_, 'a> {
|
|
480
|
+
fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
|
|
456
481
|
if vm::calls_runner(call, &self.runner)
|
|
457
482
|
&& let Some(program) = call
|
|
458
|
-
.
|
|
483
|
+
.arguments
|
|
459
484
|
.first()
|
|
460
|
-
.and_then(|argument| ast::static_str(
|
|
485
|
+
.and_then(|argument| ast::static_str(argument.as_expression()?))
|
|
461
486
|
{
|
|
462
|
-
let text = self.
|
|
487
|
+
let text = self.script.text(call).to_owned();
|
|
463
488
|
self.programs.entry(program.to_owned()).or_insert(text);
|
|
464
489
|
}
|
|
465
|
-
if let
|
|
466
|
-
&&
|
|
467
|
-
&&
|
|
468
|
-
&& let Some(
|
|
469
|
-
&& let Some((encoder, _)) = ast::direct_call(&argument.expr)
|
|
490
|
+
if let Some(member) = call.callee.without_parentheses().as_member_expression()
|
|
491
|
+
&& ast::member_str(member) == Some("send")
|
|
492
|
+
&& let Some(argument) = call.arguments.first().and_then(Argument::as_expression)
|
|
493
|
+
&& let Some((encoder, _)) = ast::direct_call(argument)
|
|
470
494
|
{
|
|
471
|
-
self.encoders.insert(
|
|
495
|
+
self.encoders.insert(self.script.binding(encoder));
|
|
472
496
|
}
|
|
473
|
-
|
|
497
|
+
walk::walk_call_expression(self, call);
|
|
474
498
|
}
|
|
475
499
|
|
|
476
|
-
fn
|
|
500
|
+
fn visit_if_statement(&mut self, conditional: &IfStatement<'a>) {
|
|
477
501
|
let options = self.options;
|
|
478
502
|
source::visit_taken_branches(self, conditional, options);
|
|
479
503
|
}
|
|
480
504
|
|
|
481
|
-
fn
|
|
505
|
+
fn visit_object_expression(&mut self, object: &ObjectExpression<'a>) {
|
|
482
506
|
if source::is_payload_template(object, self.options) {
|
|
483
507
|
self.templates
|
|
484
|
-
.push(payload_fields(
|
|
508
|
+
.push(payload_fields(self.script, object, self.options));
|
|
485
509
|
}
|
|
486
|
-
|
|
510
|
+
walk::walk_object_expression(self, object);
|
|
487
511
|
}
|
|
488
512
|
}
|
|
489
513
|
|
|
@@ -504,15 +528,13 @@ impl SessionEncoder {
|
|
|
504
528
|
#[cfg(test)]
|
|
505
529
|
mod tests {
|
|
506
530
|
use super::*;
|
|
531
|
+
use crate::js::ast::ParsedScript;
|
|
507
532
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
.into_iter()
|
|
514
|
-
.next()
|
|
515
|
-
.unwrap()
|
|
533
|
+
/// Whether the first statement of `source` defines the global `P3`.
|
|
534
|
+
fn defines_p3(source: &str) -> bool {
|
|
535
|
+
let parsed = ParsedScript::parse("t.js", source).unwrap();
|
|
536
|
+
let script = parsed.script();
|
|
537
|
+
defines(script, &script.program.body[0], Binding::Global("P3")).is_some()
|
|
516
538
|
}
|
|
517
539
|
|
|
518
540
|
#[test]
|
|
@@ -525,17 +547,14 @@ mod tests {
|
|
|
525
547
|
"P3 = (Ge[0] = 0, function(Z) { return Z; });",
|
|
526
548
|
"P3 = (Ge[0] = 0, (Ge[1] = 1, (Z => Z)));",
|
|
527
549
|
] {
|
|
528
|
-
assert!(
|
|
529
|
-
defines(&statement(source), "P3").is_some(),
|
|
530
|
-
"missed the encoder in: {source}"
|
|
531
|
-
);
|
|
550
|
+
assert!(defines_p3(source), "missed the encoder in: {source}");
|
|
532
551
|
}
|
|
533
552
|
assert!(
|
|
534
|
-
|
|
553
|
+
!defines_p3("function f() { P3 = function() {}; }"),
|
|
535
554
|
"a declared function's own body is not the IIFE's, so an assignment inside one must \
|
|
536
555
|
not claim the enclosing statement"
|
|
537
556
|
);
|
|
538
|
-
assert!(
|
|
539
|
-
assert!(
|
|
557
|
+
assert!(!defines_p3("P3 = 1;"));
|
|
558
|
+
assert!(!defines_p3("P3 = (function() {}, 1);"));
|
|
540
559
|
}
|
|
541
560
|
}
|