docs: verify restored Windows access and preserved transport identity
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""One local provenance correction: pin the actually deployed original bootstrap.
|
||||
|
||||
Actual User readonly values identify the published original file, not an unknown
|
||||
hash. Preserve the same absent console case and every other byte/guard/effect.
|
||||
No Windows/server access, new expiry, alias/policy change or effect retry.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import zipfile
|
||||
|
||||
import console_access_hash_command as previous
|
||||
|
||||
require, sha, save = previous.require, previous.sha, previous.save
|
||||
STATE = previous.previous.original.cb.EVIDENCE / 'dev-access-console-original-bootstrap-correction'
|
||||
MAIN = Path('/home/kevin/Schreibtisch/Coding/rust-discovery')
|
||||
OLD_NAME = 'Recover-ExistingDevAccess-HashFix.ps1'
|
||||
NEW_NAME = 'Recover-ExistingDevAccess-OriginalBootstrap.ps1'
|
||||
OLD_SCRIPT_SHA = 'd366ae1705dac3252726dedf369c04462e42534ddcf6e15dc27bba8583427d2c'
|
||||
PARENT_SOURCE_SHA = 'b682ced57bf7ac71c0b1ba67eb5a51a20dde814fe361e1ae2cc17872147444ad'
|
||||
REPO_BOOTSTRAP_SHA = '9e992602034026efbe17f833d4d6be694da3e223ac6b4a394c502eb140ec0189'
|
||||
PUBLISHED_BOOTSTRAP_SHA = '332ceeedf49f597eac353e0ef1f6e614c85cef20a5a20cce68d947085aa9d50f'
|
||||
CONFIG_SHA = '4ad28ec55027718a4e384c79ff7cc15ec9c798411a991a5d479e960310ed6823'
|
||||
BUNDLE_SHA = 'cba159469efad9039562633fd60213d8f6a62f169fc3d1bba915e49d22c764d2'
|
||||
REPAIR_BUNDLE_SHA = '2558448b7812b95de1612fca5f11da8f4a868764fb45666b128d03eb0c423eb4'
|
||||
|
||||
|
||||
def build(facts_path):
|
||||
require(sha(previous.__file__) == PARENT_SOURCE_SHA, 'immutable reviewed parent hash fix source')
|
||||
facts = previous.previous.original.cb.contract.protected_json(facts_path)
|
||||
require(set(facts) == {'case_present', 'config_sha256', 'bootstrap_sha256', 'configured_expiry', 'account_expiry_filetime'} and facts['case_present'] is False and facts['config_sha256'] == CONFIG_SHA and facts['bootstrap_sha256'] == PUBLISHED_BOOTSTRAP_SHA and facts['configured_expiry'] == '2026-11-14T12:55:31.254999+00:00' and facts['account_expiry_filetime'] == '134391345312549990', 'exact actual User readonly original baseline, no unknown hash adoption')
|
||||
public = MAIN / 'devstate/windows-bootstrap'
|
||||
require(sha(public / 'windows-dev-access.zip') == BUNDLE_SHA and sha(public / 'windows-dev-repair.zip') == REPAIR_BUNDLE_SHA, 'immutable originally published bundles')
|
||||
with zipfile.ZipFile(public / 'windows-dev-access.zip') as archive:
|
||||
bootstrap = archive.read('Bootstrap-DevAccess.ps1'); config = archive.read('bootstrap-public.json')
|
||||
with zipfile.ZipFile(public / 'windows-dev-repair.zip') as archive:
|
||||
repair = json.loads(archive.read('repair-public.json'))
|
||||
raw_sha = previous.previous.original.pair.raw_sha
|
||||
require(raw_sha(bootstrap) == PUBLISHED_BOOTSTRAP_SHA == repair['previous_bootstrap_sha256'] and raw_sha(config) == CONFIG_SHA, 'actual file equals original publication and independently pinned repair prerequisite')
|
||||
original_path = previous.STATE / OLD_NAME
|
||||
require(sha(original_path) == OLD_SCRIPT_SHA, 'exact reviewed parent PS1')
|
||||
source = original_path.read_bytes().decode('utf-8')
|
||||
old = "$expectedBootstrap='" + REPO_BOOTSTRAP_SHA + "'"
|
||||
new = "$expectedBootstrap='" + PUBLISHED_BOOTSTRAP_SHA + "'"
|
||||
require(source.count(old) == 1 and new not in source, 'single exact original constant')
|
||||
corrected = source.replace(old, new, 1)
|
||||
require(corrected.replace(new, old, 1) == source, 'all other bytes including expiry/case/alias/clock/effects unchanged')
|
||||
STATE.mkdir(mode=0o700, parents=True, exist_ok=False)
|
||||
save(STATE / 'actual-user-readonly.json', facts)
|
||||
previous.previous.original.pair.write_bytes(STATE / NEW_NAME, corrected.encode())
|
||||
digest = raw_sha(corrected.encode())
|
||||
patch = r'''$ErrorActionPreference='Stop'
|
||||
$inputPath=Join-Path (Get-Location) 'Recover-ExistingDevAccess-HashFix.ps1';$newPath=Join-Path (Get-Location) 'Recover-ExistingDevAccess-OriginalBootstrap.ps1'
|
||||
if((Get-FileHash -LiteralPath $inputPath -Algorithm SHA256).Hash.ToLowerInvariant()-cne'@@INPUT@@'-or(Test-Path -LiteralPath $newPath)){throw 'Originalhash falsch oder neue Datei bereits vorhanden; nichts ausfuehren'}
|
||||
$text=[Text.Encoding]::UTF8.GetString([IO.File]::ReadAllBytes($inputPath));$text=$text.Replace("`$expectedBootstrap='@@OLD@@'","`$expectedBootstrap='@@PIN@@'");$bytes=(New-Object Text.UTF8Encoding($false)).GetBytes($text);$file=[IO.File]::Open($newPath,'CreateNew','Write','Read');try{$file.Write($bytes,0,$bytes.Length);$file.Flush($true)}finally{$file.Dispose()}
|
||||
if((Get-FileHash -LiteralPath $newPath -Algorithm SHA256).Hash.ToLowerInvariant()-cne'@@OUTPUT@@'){throw 'Neuer Hash falsch; nichts ausfuehren'}
|
||||
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -File $newPath
|
||||
'''
|
||||
for token, value in {'INPUT': OLD_SCRIPT_SHA, 'OLD': REPO_BOOTSTRAP_SHA, 'PIN': PUBLISHED_BOOTSTRAP_SHA, 'OUTPUT': digest}.items():
|
||||
patch = patch.replace('@@' + token + '@@', value)
|
||||
previous.previous.original.pair.write_bytes(STATE / 'Create-VerifiedOriginalBootstrapFix.ps1', patch.encode())
|
||||
save(STATE / 'qualification.json', dict(source_only=True, source_sha256=sha(__file__), parent_source_sha256=PARENT_SOURCE_SHA, actual_user_readonly_sha256=sha(STATE / 'actual-user-readonly.json'), same_console_case=previous.CASE, input_script_sha256=OLD_SCRIPT_SHA, corrected_script_sha256=digest, original_bundle_sha256=BUNDLE_SHA, repair_bundle_sha256=REPAIR_BUNDLE_SHA, published_bootstrap_sha256=PUBLISHED_BOOTSTRAP_SHA, corrected_exactly_one_constant=True, all_other_bytes_unchanged=True, no_unknown_hash_adoption=True, original_scripts_and_zip_retained=True, no_windows_or_server_access=True))
|
||||
print('source_sha256=' + sha(__file__))
|
||||
print('corrected_script_sha256=' + digest)
|
||||
print('patch_sha256=' + sha(STATE / 'Create-VerifiedOriginalBootstrapFix.ps1'))
|
||||
print('patch=' + str((STATE / 'Create-VerifiedOriginalBootstrapFix.ps1').resolve()))
|
||||
|
||||
|
||||
def main():
|
||||
os.umask(0o077)
|
||||
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('phase',choices=('build',));parser.add_argument('--actual-user-readonly',required=True,type=Path);args=parser.parse_args();build(args.actual_user_readonly)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user