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
|
@@ -11,85 +11,34 @@
|
|
|
11
11
|
//! Because decoding has no side effects, constant calls can be replaced wherever they occur.
|
|
12
12
|
//! Removes the decoder when no reads remain.
|
|
13
13
|
|
|
14
|
+
use anyhow::Result;
|
|
15
|
+
use base64::Engine;
|
|
14
16
|
use base64::engine::general_purpose::STANDARD;
|
|
15
|
-
use
|
|
16
|
-
use
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
use oxc::allocator::{Allocator, GetAllocator};
|
|
18
|
+
use oxc::ast::ast::{
|
|
19
|
+
BinaryExpression, Expression, Program, Statement, VariableDeclaration, VariableDeclarator,
|
|
20
|
+
};
|
|
21
|
+
use oxc::ast_visit::{Visit, VisitMut, walk, walk_mut};
|
|
22
|
+
use oxc::str::{JSStr, JSStrBuilder};
|
|
23
|
+
use oxc::syntax::operator::BinaryOperator;
|
|
24
|
+
use oxc::syntax::scope::ScopeFlags;
|
|
19
25
|
|
|
20
|
-
use super::analysis::Analysis;
|
|
21
|
-
use super::{HashMap,
|
|
22
|
-
use crate::js::ast;
|
|
26
|
+
use super::analysis::{Analysis, Id};
|
|
27
|
+
use super::{HashMap, ast, pipeline, removal};
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
let bindings = analysis.bindings(program);
|
|
26
|
-
let mut decoders = Decoders::default();
|
|
27
|
-
program.visit_with(&mut decoders);
|
|
28
|
-
decoders.0.retain(|id, _| bindings.is_written_once(id));
|
|
29
|
-
if decoders.0.is_empty() {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
let mut decode = DecodeCalls {
|
|
33
|
-
decoders: &decoders.0,
|
|
34
|
-
decoded: HashMap::default(),
|
|
35
|
-
};
|
|
36
|
-
program.visit_mut_with(&mut decode);
|
|
37
|
-
let unread = removal::unread(&decode.decoded, bindings);
|
|
38
|
-
program.visit_mut_with(&mut DropDecoders(unread));
|
|
39
|
-
!decode.decoded.is_empty()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// A string decoder call with constant arguments in the original script, including the encoded
|
|
43
|
-
/// input, key, and decoded text.
|
|
29
|
+
/// A constant decoder call in the original script, with its encoded input, key, and decoded text.
|
|
44
30
|
pub(crate) struct Encoded {
|
|
45
31
|
pub(crate) encoded: String,
|
|
46
32
|
pub(crate) key: u16,
|
|
47
33
|
pub(crate) decoded: String,
|
|
48
34
|
}
|
|
49
35
|
|
|
50
|
-
///
|
|
51
|
-
/// declared names.
|
|
52
|
-
pub(crate) fn inline_strings(script: &Script) -> Vec<Encoded> {
|
|
53
|
-
struct Calls<'decoders> {
|
|
54
|
-
decoders: &'decoders HashMap<Id, u16>,
|
|
55
|
-
found: Vec<Encoded>,
|
|
56
|
-
}
|
|
57
|
-
impl Visit for Calls<'_> {
|
|
58
|
-
fn visit_expr(&mut self, expression: &Expr) {
|
|
59
|
-
if let Some((callee, [argument])) = ast::direct_call(expression)
|
|
60
|
-
&& argument.spread.is_none()
|
|
61
|
-
&& let Some(&key) = self.decoders.get(&callee.to_id())
|
|
62
|
-
&& let Some(encoded) = ast::static_str(&argument.expr)
|
|
63
|
-
&& let Some(decoded) = decode(encoded, key)
|
|
64
|
-
&& let Some(decoded) = decoded.as_str()
|
|
65
|
-
{
|
|
66
|
-
self.found.push(Encoded {
|
|
67
|
-
encoded: encoded.to_owned(),
|
|
68
|
-
key,
|
|
69
|
-
decoded: decoded.to_owned(),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
expression.visit_children_with(self);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
let mut decoders = Decoders::default();
|
|
76
|
-
script.visit_with(&mut decoders);
|
|
77
|
-
let mut calls = Calls {
|
|
78
|
-
decoders: &decoders.0,
|
|
79
|
-
found: Vec::new(),
|
|
80
|
-
};
|
|
81
|
-
script.visit_with(&mut calls);
|
|
82
|
-
calls.found
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/// Encodes `text` so that [`decode`] with `key` returns it.
|
|
36
|
+
/// Encodes `text` so that [`decode`] with the same key recovers its UTF-16 code units.
|
|
86
37
|
pub(crate) fn encode(text: &str, mut key: u16) -> String {
|
|
87
|
-
use base64::Engine;
|
|
88
|
-
|
|
89
38
|
let mut bytes = Vec::new();
|
|
90
39
|
let mut push = |byte: u8| {
|
|
91
40
|
key = key.rotate_left(8);
|
|
92
|
-
bytes.push(byte ^ (key >> 8) as u8)
|
|
41
|
+
bytes.push(byte ^ (key >> 8) as u8)
|
|
93
42
|
};
|
|
94
43
|
for unit in text.encode_utf16() {
|
|
95
44
|
match u8::try_from(unit) {
|
|
@@ -105,179 +54,238 @@ pub(crate) fn encode(text: &str, mut key: u16) -> String {
|
|
|
105
54
|
STANDARD.encode(bytes)
|
|
106
55
|
}
|
|
107
56
|
|
|
108
|
-
/// Decodes
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
57
|
+
/// Decodes base64 with the key's alternating byte order. A 255 byte escapes a little-endian
|
|
58
|
+
/// UTF-16 code unit. The arena string preserves lone surrogates; malformed base64 or a truncated
|
|
59
|
+
/// escape returns `None` instead of inventing replacement characters.
|
|
60
|
+
fn decode<'a>(encoded: &str, mut key: u16, allocator: &'a Allocator) -> Option<JSStr<'a>> {
|
|
112
61
|
let mut bytes = STANDARD.decode(encoded).ok()?.into_iter();
|
|
113
62
|
let mut next = || {
|
|
114
63
|
key = key.rotate_left(8);
|
|
115
64
|
Some(bytes.next()? ^ (key >> 8) as u8)
|
|
116
65
|
};
|
|
117
|
-
let mut
|
|
66
|
+
let mut decoded = JSStrBuilder::new_in(&allocator);
|
|
118
67
|
while let Some(unit) = next() {
|
|
119
|
-
|
|
68
|
+
decoded.push_code_unit(if unit == 255 {
|
|
120
69
|
u16::from_le_bytes([next()?, next()?])
|
|
121
70
|
} else {
|
|
122
71
|
u16::from(unit)
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
Some(Wtf8Atom::from(Wtf8Buf::from_ill_formed_utf16(&units)))
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/// Decoders by binding, with their keys.
|
|
129
|
-
#[derive(Default)]
|
|
130
|
-
struct Decoders(HashMap<Id, u16>);
|
|
131
|
-
|
|
132
|
-
impl Visit for Decoders {
|
|
133
|
-
fn visit_var_declarator(&mut self, declarator: &VarDeclarator) {
|
|
134
|
-
if let Some(name) = declarator.name.as_ident()
|
|
135
|
-
&& let Some(key) = declarator.init.as_deref().and_then(decoder_key)
|
|
136
|
-
{
|
|
137
|
-
self.0.insert(name.to_id(), key);
|
|
138
|
-
}
|
|
139
|
-
declarator.visit_children_with(self);
|
|
72
|
+
})
|
|
140
73
|
}
|
|
74
|
+
Some(decoded.into_js_str())
|
|
141
75
|
}
|
|
142
76
|
|
|
143
|
-
///
|
|
144
|
-
///
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
77
|
+
/// Recognizes `function(global) { ...; return function(encoded) { ... } }(globalThis)` and returns
|
|
78
|
+
/// its key.
|
|
79
|
+
fn decoder_key<'a>(expression: &Expression<'a>, analysis: &Analysis<'a>) -> Option<u16> {
|
|
80
|
+
let Expression::CallExpression(call) = expression.get_inner_expression() else {
|
|
81
|
+
return None;
|
|
82
|
+
};
|
|
83
|
+
let [global] = call.arguments.as_slice() else {
|
|
149
84
|
return None;
|
|
150
85
|
};
|
|
151
|
-
if global.
|
|
86
|
+
if global.as_expression()?.get_identifier_reference()?.name != "globalThis" {
|
|
152
87
|
return None;
|
|
153
88
|
}
|
|
154
|
-
let outer = call.callee.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.
|
|
162
|
-
|
|
163
|
-
let [parameter] = &decoder.params[..] else {
|
|
89
|
+
let Expression::FunctionExpression(outer) = call.callee.get_inner_expression() else {
|
|
90
|
+
return None;
|
|
91
|
+
};
|
|
92
|
+
let Statement::ReturnStatement(returned) = outer.body.as_ref()?.statements.last()? else {
|
|
93
|
+
return None;
|
|
94
|
+
};
|
|
95
|
+
let Expression::FunctionExpression(decoder) =
|
|
96
|
+
returned.argument.as_ref()?.get_inner_expression()
|
|
97
|
+
else {
|
|
164
98
|
return None;
|
|
165
99
|
};
|
|
166
|
-
let
|
|
167
|
-
|
|
100
|
+
let [parameter] = decoder.params.items.as_slice() else {
|
|
101
|
+
return None;
|
|
102
|
+
};
|
|
103
|
+
let mut search = KeySearch {
|
|
104
|
+
analysis,
|
|
105
|
+
encoded: ast::pattern_id(¶meter.pattern)?,
|
|
168
106
|
key: None,
|
|
107
|
+
value: 0,
|
|
169
108
|
rotated: false,
|
|
170
109
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
keys.rotated.then_some(key)
|
|
110
|
+
search.visit_function(decoder, ScopeFlags::Function);
|
|
111
|
+
(search.key.is_some() && search.rotated).then_some(search.value)
|
|
174
112
|
}
|
|
175
113
|
|
|
176
|
-
/// Finds the key
|
|
177
|
-
|
|
114
|
+
/// Finds the key declared beside `bytes = global.atob(encoded)`, and whether that same binding is
|
|
115
|
+
/// rotated with `(key << 8 | key >>> 8) & 65535`. Resolved identities distinguish shadows.
|
|
116
|
+
struct KeySearch<'b, 'a> {
|
|
117
|
+
analysis: &'b Analysis<'a>,
|
|
178
118
|
encoded: Id,
|
|
179
|
-
key: Option<
|
|
119
|
+
key: Option<Id>,
|
|
120
|
+
/// The initial value of `key`.
|
|
121
|
+
value: u16,
|
|
180
122
|
rotated: bool,
|
|
181
123
|
}
|
|
182
124
|
|
|
183
|
-
impl
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
125
|
+
impl<'a> KeySearch<'_, 'a> {
|
|
126
|
+
/// Matches `key << 8` or `key >>> 8`.
|
|
127
|
+
fn shifts(&self, expression: &Expression<'a>, operator: BinaryOperator, key: Id) -> bool {
|
|
128
|
+
matches!(
|
|
129
|
+
expression.get_inner_expression(),
|
|
130
|
+
Expression::BinaryExpression(shift) if shift.operator == operator
|
|
131
|
+
&& self.analysis.expression_id(&shift.left) == Some(key)
|
|
132
|
+
&& ast::number(&shift.right) == Some(8.0)
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
impl<'a> Visit<'a> for KeySearch<'_, 'a> {
|
|
138
|
+
fn visit_variable_declaration(&mut self, declaration: &VariableDeclaration<'a>) {
|
|
139
|
+
for pair in declaration.declarations.windows(2) {
|
|
140
|
+
let [bytes, key] = pair else { continue };
|
|
141
|
+
if let Some(init) = &bytes.init
|
|
188
142
|
&& let Some((_, [argument])) = ast::method_call(init, "atob")
|
|
189
143
|
&& argument
|
|
190
|
-
.
|
|
191
|
-
.
|
|
192
|
-
.is_some_and(|
|
|
193
|
-
&& let Some(
|
|
194
|
-
&& let Some(value) = key.init.
|
|
144
|
+
.as_expression()
|
|
145
|
+
.and_then(Expression::get_identifier_reference)
|
|
146
|
+
.is_some_and(|encoded| self.analysis.id(encoded) == Some(self.encoded))
|
|
147
|
+
&& let Some(id) = ast::pattern_id(&key.id)
|
|
148
|
+
&& let Some(value) = key.init.as_ref().and_then(ast::number)
|
|
195
149
|
&& value.fract() == 0.0
|
|
196
|
-
&&
|
|
150
|
+
&& (0.0..=u16::MAX as f64).contains(&value)
|
|
197
151
|
{
|
|
198
|
-
self.key = Some(
|
|
152
|
+
self.key = Some(id);
|
|
153
|
+
self.value = value as u16;
|
|
199
154
|
}
|
|
200
155
|
}
|
|
201
|
-
|
|
156
|
+
walk::walk_variable_declaration(self, declaration)
|
|
202
157
|
}
|
|
203
158
|
|
|
204
|
-
fn
|
|
205
|
-
if let Some(
|
|
206
|
-
&&
|
|
159
|
+
fn visit_binary_expression(&mut self, binary: &BinaryExpression<'a>) {
|
|
160
|
+
if let Some(key) = self.key
|
|
161
|
+
&& binary.operator == BinaryOperator::BitwiseAnd
|
|
162
|
+
&& ast::number(&binary.right) == Some(65535.0)
|
|
163
|
+
&& let Expression::BinaryExpression(swap) = binary.left.get_inner_expression()
|
|
164
|
+
&& swap.operator == BinaryOperator::BitwiseOR
|
|
207
165
|
{
|
|
208
|
-
self.rotated
|
|
166
|
+
self.rotated |= self.shifts(&swap.left, BinaryOperator::ShiftLeft, key)
|
|
167
|
+
&& self.shifts(&swap.right, BinaryOperator::ShiftRightZeroFill, key);
|
|
209
168
|
}
|
|
210
|
-
|
|
169
|
+
walk::walk_binary_expression(self, binary)
|
|
211
170
|
}
|
|
212
171
|
}
|
|
213
172
|
|
|
214
|
-
///
|
|
215
|
-
fn
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
&& shift
|
|
220
|
-
.left
|
|
221
|
-
.as_ident()
|
|
222
|
-
.is_some_and(|name| name.to_id() == *key)
|
|
223
|
-
&& ast::number(&shift.right) == Some(8.0)
|
|
224
|
-
})
|
|
173
|
+
/// Finds decoder initializers by their declared binding and recovers each key.
|
|
174
|
+
fn decoders<'a>(program: &Program<'a>, analysis: &Analysis<'a>) -> HashMap<Id, u16> {
|
|
175
|
+
let mut decoders = Decoders {
|
|
176
|
+
analysis,
|
|
177
|
+
found: HashMap::default(),
|
|
225
178
|
};
|
|
226
|
-
|
|
227
|
-
|
|
179
|
+
decoders.visit_program(program);
|
|
180
|
+
decoders.found
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
struct Decoders<'b, 'a> {
|
|
184
|
+
analysis: &'b Analysis<'a>,
|
|
185
|
+
found: HashMap<Id, u16>,
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
impl<'a> Visit<'a> for Decoders<'_, 'a> {
|
|
189
|
+
fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
|
|
190
|
+
if let Some(id) = ast::pattern_id(&declarator.id)
|
|
191
|
+
&& let Some(value) = &declarator.init
|
|
192
|
+
&& let Some(key) = decoder_key(value, self.analysis)
|
|
193
|
+
{
|
|
194
|
+
self.found.insert(id, key);
|
|
195
|
+
}
|
|
196
|
+
walk::walk_variable_declarator(self, declarator)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
pub(super) fn run<'a>(program: &mut Program<'a>, analysis: &mut Analysis<'a>) -> bool {
|
|
201
|
+
let mut decoders = decoders(program, analysis);
|
|
202
|
+
decoders.retain(|id, _| analysis.bindings.is_written_once(id));
|
|
203
|
+
let mut inline = Inline {
|
|
204
|
+
analysis,
|
|
205
|
+
decoders: &decoders,
|
|
206
|
+
replaced: HashMap::default(),
|
|
228
207
|
};
|
|
229
|
-
|
|
208
|
+
inline.visit_program(program);
|
|
209
|
+
if inline.replaced.is_empty() {
|
|
230
210
|
return false;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
&& shifts_key(&swap.left, BinaryOp::LShift)
|
|
236
|
-
&& shifts_key(&swap.right, BinaryOp::ZeroFillRShift)
|
|
211
|
+
}
|
|
212
|
+
let unread = removal::unread(&inline.replaced, analysis);
|
|
213
|
+
removal::remove_initializers(program, &unread);
|
|
214
|
+
true
|
|
237
215
|
}
|
|
238
216
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
decoders: &'
|
|
242
|
-
|
|
217
|
+
struct Inline<'b, 'a> {
|
|
218
|
+
analysis: &'b Analysis<'a>,
|
|
219
|
+
decoders: &'b HashMap<Id, u16>,
|
|
220
|
+
/// Replacement counts by decoder.
|
|
221
|
+
replaced: HashMap<Id, usize>,
|
|
243
222
|
}
|
|
244
223
|
|
|
245
|
-
impl VisitMut for
|
|
246
|
-
fn
|
|
247
|
-
|
|
248
|
-
if let Some((callee, [
|
|
249
|
-
&&
|
|
250
|
-
&& let Some(&key) = self.decoders.get(&
|
|
251
|
-
&& let Some(
|
|
224
|
+
impl<'a> VisitMut<'a> for Inline<'_, 'a> {
|
|
225
|
+
fn visit_expression(&mut self, expression: &mut Expression<'a>) {
|
|
226
|
+
walk_mut::walk_expression(self, expression);
|
|
227
|
+
if let Some((callee, [argument])) = ast::direct_call(expression)
|
|
228
|
+
&& let Some(id) = self.analysis.id(callee)
|
|
229
|
+
&& let Some(&key) = self.decoders.get(&id)
|
|
230
|
+
&& let Some(encoded) = argument.as_expression().and_then(ast::static_str)
|
|
231
|
+
&& let Some(value) = decode(encoded, key, self.analysis.allocator())
|
|
252
232
|
{
|
|
253
|
-
*self.
|
|
254
|
-
*expression =
|
|
255
|
-
|
|
256
|
-
value,
|
|
257
|
-
raw: None,
|
|
258
|
-
}));
|
|
233
|
+
*self.replaced.entry(id).or_default() += 1;
|
|
234
|
+
*expression =
|
|
235
|
+
Expression::new_string_literal(callee.span, value, None, &self.analysis.ast);
|
|
259
236
|
}
|
|
260
237
|
}
|
|
261
238
|
}
|
|
262
239
|
|
|
263
|
-
///
|
|
264
|
-
|
|
240
|
+
/// Parses and resolves the original script as deobfuscation does, then finds constant calls to
|
|
241
|
+
/// recognized decoders. Returns an owned inventory for capture rewriting; strings with lone
|
|
242
|
+
/// surrogates are omitted from this Rust-string inventory, while the AST rewrite preserves their
|
|
243
|
+
/// code units.
|
|
244
|
+
pub(crate) fn inline_strings(source: &str) -> Result<Vec<Encoded>> {
|
|
245
|
+
let allocator = Allocator::default();
|
|
246
|
+
let (program, analysis) = pipeline::parse(&allocator, source)?;
|
|
247
|
+
let decoders = decoders(&program, &analysis);
|
|
248
|
+
let mut calls = Calls {
|
|
249
|
+
analysis: &analysis,
|
|
250
|
+
decoders: &decoders,
|
|
251
|
+
found: Vec::new(),
|
|
252
|
+
};
|
|
253
|
+
calls.visit_program(&program);
|
|
254
|
+
Ok(calls.found)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
struct Calls<'b, 'a> {
|
|
258
|
+
analysis: &'b Analysis<'a>,
|
|
259
|
+
decoders: &'b HashMap<Id, u16>,
|
|
260
|
+
found: Vec<Encoded>,
|
|
261
|
+
}
|
|
265
262
|
|
|
266
|
-
impl
|
|
267
|
-
fn
|
|
268
|
-
if
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
263
|
+
impl<'a> Visit<'a> for Calls<'_, 'a> {
|
|
264
|
+
fn visit_expression(&mut self, expression: &Expression<'a>) {
|
|
265
|
+
if let Some((callee, [argument])) = ast::direct_call(expression)
|
|
266
|
+
&& let Some(&key) = self
|
|
267
|
+
.analysis
|
|
268
|
+
.id(callee)
|
|
269
|
+
.and_then(|id| self.decoders.get(&id))
|
|
270
|
+
&& let Some(encoded) = argument.as_expression().and_then(ast::static_str)
|
|
271
|
+
&& let Some(decoded) = decode(encoded, key, self.analysis.allocator())
|
|
272
|
+
&& let Some(decoded) = decoded.as_str()
|
|
272
273
|
{
|
|
273
|
-
|
|
274
|
+
self.found.push(Encoded {
|
|
275
|
+
encoded: encoded.to_owned(),
|
|
276
|
+
key,
|
|
277
|
+
decoded: decoded.to_owned(),
|
|
278
|
+
})
|
|
274
279
|
}
|
|
275
|
-
|
|
280
|
+
walk::walk_expression(self, expression)
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
|
|
279
284
|
#[cfg(test)]
|
|
280
285
|
mod tests {
|
|
286
|
+
use base64::Engine;
|
|
287
|
+
use oxc::allocator::Allocator;
|
|
288
|
+
|
|
281
289
|
use crate::deobfuscate::testing;
|
|
282
290
|
|
|
283
291
|
/// The decoder of a challenge script, with its key.
|
|
@@ -311,19 +319,14 @@ mod tests {
|
|
|
311
319
|
|
|
312
320
|
#[test]
|
|
313
321
|
fn decodes_constant_calls_and_drops_an_unread_decoder() {
|
|
314
|
-
let transform =
|
|
315
|
-
testing::rewrite(
|
|
316
|
-
&format!("{DECODER}\n{source}"),
|
|
317
|
-
super::run,
|
|
318
|
-
/* fix= */ true,
|
|
319
|
-
)
|
|
320
|
-
};
|
|
322
|
+
let transform =
|
|
323
|
+
|source: &str| testing::rewrite(&format!("{DECODER}\n{source}"), super::run);
|
|
321
324
|
let output = transform("f(decode(`ZJd1i3w=`), decode('ZoZpiw=='));");
|
|
322
|
-
testing::assert_contains(&output, &["\"apply\"", "\"call\""
|
|
325
|
+
testing::assert_contains(&output, &["\"apply\"", "\"call\"", "var decode;"]);
|
|
323
326
|
// Dynamic calls keep the decoder; reassignment disables decoding.
|
|
324
327
|
let output = transform("f(decode(`ZJd1i3w=`), decode(name));");
|
|
325
|
-
let expected = ["\"apply\"", "decode(name)"];
|
|
326
|
-
testing::assert_contains(&output, &expected
|
|
328
|
+
let expected = ["\"apply\"", "decode(name)", "var decode = function"];
|
|
329
|
+
testing::assert_contains(&output, &expected);
|
|
327
330
|
let output = transform("decode = other; f(decode(`ZJd1i3w=`));");
|
|
328
331
|
assert!(output.contains("decode(`ZJd1i3w=`)"), "{output}");
|
|
329
332
|
}
|
|
@@ -331,8 +334,7 @@ mod tests {
|
|
|
331
334
|
#[test]
|
|
332
335
|
fn finds_and_reencodes_the_strings_a_served_script_decodes() {
|
|
333
336
|
let source = format!("{DECODER}\nf(decode(`ZJd1i3w=`), decode('ZoZpiw=='), other(`x`));");
|
|
334
|
-
let
|
|
335
|
-
let strings = super::inline_strings(&parsed.script);
|
|
337
|
+
let strings = super::inline_strings(&source).unwrap();
|
|
336
338
|
let decoded: Vec<(&str, &str)> = strings
|
|
337
339
|
.iter()
|
|
338
340
|
.map(|string| (string.encoded.as_str(), string.decoded.as_str()))
|
|
@@ -341,19 +343,13 @@ mod tests {
|
|
|
341
343
|
assert_eq!(super::encode("apply", strings[0].key), "ZJd1i3w=");
|
|
342
344
|
// Code units of 255 or greater need an escape byte followed by two bytes.
|
|
343
345
|
let encoded = super::encode("a€", 59141);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let encoded = super::STANDARD.encode([255 ^ 0x05, 0x00 ^ 0xe7, 0xd8 ^ 0x05]);
|
|
353
|
-
let decoded = super::decode(&encoded, 59141).unwrap();
|
|
354
|
-
assert_eq!(
|
|
355
|
-
decoded.as_wtf8().to_ill_formed_utf16().collect::<Vec<_>>(),
|
|
356
|
-
[0xd800]
|
|
357
|
-
);
|
|
346
|
+
let allocator = Allocator::default();
|
|
347
|
+
let decoded = super::decode(&encoded, 59141, &allocator).expect("valid encoding");
|
|
348
|
+
assert_eq!(decoded.as_str(), Some("a€"));
|
|
349
|
+
// 255 escapes the code unit U+D800, a lone surrogate. The bytes 255, 0x00, 0xd8 are
|
|
350
|
+
// XORed with the key 59141 (0xe705), low byte first.
|
|
351
|
+
let encoded = super::STANDARD.encode([255 ^ 0x05, 0xe7, 0xd8 ^ 0x05]);
|
|
352
|
+
let decoded = super::decode(&encoded, 59141, &allocator).expect("valid encoding");
|
|
353
|
+
assert_eq!(decoded.encode_utf16().collect::<Vec<_>>(), [0xd800]);
|
|
358
354
|
}
|
|
359
355
|
}
|
|
@@ -7,56 +7,51 @@
|
|
|
7
7
|
//!
|
|
8
8
|
//! Counts parameters before the first default or rest parameter, as `length` does.
|
|
9
9
|
|
|
10
|
-
use
|
|
11
|
-
use
|
|
10
|
+
use oxc::ast::ast::{Expression, Program};
|
|
11
|
+
use oxc::ast_visit::{VisitMut, walk_mut};
|
|
12
|
+
use oxc::span::GetSpan;
|
|
12
13
|
|
|
13
14
|
use super::analysis::Analysis;
|
|
14
|
-
use
|
|
15
|
+
use super::ast;
|
|
15
16
|
|
|
16
|
-
pub(super) fn run(program: &mut Program
|
|
17
|
-
let mut lengths =
|
|
18
|
-
|
|
17
|
+
pub(super) fn run<'a>(program: &mut Program<'a>, analysis: &mut Analysis<'a>) -> bool {
|
|
18
|
+
let mut lengths = Lengths {
|
|
19
|
+
analysis,
|
|
20
|
+
changed: false,
|
|
21
|
+
};
|
|
22
|
+
lengths.visit_program(program);
|
|
19
23
|
lengths.changed
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
struct
|
|
26
|
+
struct Lengths<'b, 'a> {
|
|
27
|
+
analysis: &'b Analysis<'a>,
|
|
23
28
|
changed: bool,
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
impl VisitMut for
|
|
27
|
-
fn
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
impl<'a> VisitMut<'a> for Lengths<'_, 'a> {
|
|
32
|
+
fn visit_expression(&mut self, expression: &mut Expression<'a>) {
|
|
33
|
+
walk_mut::walk_expression(self, expression);
|
|
34
|
+
let Some(member) = expression.as_member_expression() else {
|
|
35
|
+
return;
|
|
36
|
+
};
|
|
37
|
+
if member
|
|
38
|
+
.static_property_name()
|
|
39
|
+
.is_none_or(|key| key != "length")
|
|
32
40
|
{
|
|
33
|
-
|
|
34
|
-
span: member.span,
|
|
35
|
-
value: length as f64,
|
|
36
|
-
raw: None,
|
|
37
|
-
}));
|
|
38
|
-
self.changed = true;
|
|
41
|
+
return;
|
|
39
42
|
}
|
|
43
|
+
let parameters = match member.object().get_inner_expression() {
|
|
44
|
+
Expression::FunctionExpression(function) => &function.params,
|
|
45
|
+
Expression::ArrowFunctionExpression(function) => &function.params,
|
|
46
|
+
_ => return,
|
|
47
|
+
};
|
|
48
|
+
let items = parameters.items.iter();
|
|
49
|
+
let length = items.take_while(|item| item.initializer.is_none()).count() as f64;
|
|
50
|
+
*expression = ast::number_literal(expression.span(), length, &self.analysis.ast);
|
|
51
|
+
self.changed = true;
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
/// The `length` of a function or arrow literal, possibly parenthesized.
|
|
44
|
-
fn literal_length(expression: &Expr) -> Option<usize> {
|
|
45
|
-
let counted = |pattern: &&Pat| !matches!(pattern, Pat::Assign(_) | Pat::Rest(_));
|
|
46
|
-
let length = match expression.unwrap_parens() {
|
|
47
|
-
Expr::Arrow(arrow) => arrow.params.iter().take_while(counted).count(),
|
|
48
|
-
Expr::Fn(function) => function
|
|
49
|
-
.function
|
|
50
|
-
.params
|
|
51
|
-
.iter()
|
|
52
|
-
.map(|parameter| ¶meter.pat)
|
|
53
|
-
.take_while(counted)
|
|
54
|
-
.count(),
|
|
55
|
-
_ => return None,
|
|
56
|
-
};
|
|
57
|
-
Some(length)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
55
|
#[cfg(test)]
|
|
61
56
|
mod tests {
|
|
62
57
|
use crate::deobfuscate::testing;
|
|
@@ -67,8 +62,7 @@ mod tests {
|
|
|
67
62
|
"f((a => a).length, (function(a, b) {}).length, ((a, b = 1, c) => a).length,
|
|
68
63
|
((...a) => a).length, g.length);",
|
|
69
64
|
super::run,
|
|
70
|
-
/* fix= */ true,
|
|
71
65
|
);
|
|
72
|
-
testing::assert_contains(&output, &[
|
|
66
|
+
testing::assert_contains(&output, &["f(1, 2, 1, 0, g.length)"]);
|
|
73
67
|
}
|
|
74
68
|
}
|