lushun2014/lushibo-skills / ida-reverse
ida-reverse
VerifiedIDA Pro 逆向分析辅助技能(binary reverse engineering)。能力:通过 idalib-mcp 的 idapro_* 工具做反编译、反汇编、交叉引用与数据流追踪、类型恢复、批量改名注释与 patch,并用自带 scripts/start.ps1、scripts/open.ps1 稳定管理服务器与打开文件,避免手写临时命令。Use when 用户提到逆向、反编译、破解、找密码、注册机、漏洞分析、病毒分析、固件分析、IDA、idapro、idalib,或需要分析 exe、dll、so、elf、macho、sys、apk、dex 等任意二进制;即使用户只说看看这个exe、分析这个dll、帮我破解、找一下密码、这个软件怎么注册,也应使用本 skill。交付物:函数与结构体分析结论、重命名与注释后的 IDB、关键算法还原说明与 report.md 分析报告。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.9 KB |
| references/ida-mcp-cheatsheet.md | markdown | 10.8 KB |
| scripts/open.ps1 | script | 7.9 KB |
| scripts/start.ps1 | script | 6.0 KB |
scripts/open.ps1
View on GitHub<#
.SYNOPSIS
Open binary file via IDA HTTP API (bypass MCP schema issue)
.PARAMETER Path
Binary file path (required)
.PARAMETER SessionId
Session ID (optional, auto-generated)
.PARAMETER NoAutoAnalysis
Skip automatic analysis (faster open for large files)
.PARAMETER TimeoutSeconds
Open timeout in seconds, returns timeout instead of blocking forever
#>
param(
[Parameter(Mandatory=$true)]
[string]$Path,
[string]$SessionId = "",
[switch]$NoAutoAnalysis = $false,
[int]$TimeoutSeconds = 120
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if (-not [string]::IsNullOrWhiteSpace($env:IDADIR)) {
$env:IDADIR = $env:IDADIR
}
else {
# Fallback: check common IDA installation paths
$idaCandidates = @(
'C:\Program Files\IDA Pro',
'C:\IDA Pro',
'D:\IDA',
(Join-Path $env:USERPROFILE 'Tools\IDA')
)
$foundIda = $idaCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if ($foundIda) {
$env:IDADIR = $foundIda
} else {
Write-Error "ERR:IDADIR not set and IDA Pro not found at common paths. Set IDADIR environment variable to your IDA installation directory."
exit 1
}
}
$Port = 13337
$TempDir = Join-Path $env:TEMP 'reverse-skill'
if (-not (Test-Path -LiteralPath $TempDir)) {
New-Item -ItemType Directory -Path $TempDir -Force | Out-Null
}
$PollIntervalMs = 2000
$ProgressIntervalSeconds = 10
function Get-OpenReadySession {
param(
[string]$ExpectedSessionId,
[string]$ExpectedPath,
[int]$RequestPort
)
$listBody = '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_list","arguments":{}}}'
$listResult = Invoke-RestMethod "http://127.0.0.1:$RequestPort/mcp" -Method Post -Body $listBody `
-ContentType "application/json" -TimeoutSec 10 -ErrorAction Stop
$sessions = @($listResult.result.structuredContent.sessions)
foreach ($candidate in $sessions) {
if (-not $candidate) {
continue
}
$sameSession = $candidate.session_id -eq $ExpectedSessionId
$samePath = $candidate.input_path -eq $ExpectedPath
$sameFile = [System.IO.Path]::GetFileName($candidate.input_path) -eq [System.IO.Path]::GetFileName($ExpectedPath)
if (($sameSession -or $samePath -or $sameFile) -and $candidate.is_analyzing -eq $false) {
return $candidate
}
}
return $null
}
if (-not (Test-Path $Path)) {
Write-Output "ERR:file_not_found"
exit 1
}
if ($TimeoutSeconds -le 0) {
Write-Output "ERR:invalid_timeout"
exit 1
}
# 判断是否用了临时副本(避免递归复制)
$isTempCopy = $Path.StartsWith($TempDir, [StringComparison]::OrdinalIgnoreCase)
# System32 文件自动复制到 Temp
if (-not $isTempCopy -and $Path -match "C:\\Windows\\System32") {
$Filename = [System.IO.Path]::GetFileName($Path)
$TempPath = "$TempDir\$Filename"
Copy-Item $Path $TempPath -Force -ErrorAction SilentlyContinue
if ($?) {
$Path = $TempPath
$isTempCopy = $true
}
}
# 清理同名旧数据库文件(只在非 Temp 副本时尝试)
if (-not $isTempCopy) {
$dir = [System.IO.Path]::GetDirectoryName($Path)
$base = [System.IO.Path]::GetFileNameWithoutExtension($Path)
$oldExts = @(".id0", ".id1", ".id2", ".nam", ".til", ".i64")
$hasLocked = $false
foreach ($ext in $oldExts) {
$f = Join-Path $dir "$base$ext"
if (Test-Path $f) {
Remove-Item $f -Force -ErrorAction SilentlyContinue
if (Test-Path $f) { $hasLocked = $true }
}
}
# 旧数据库文件被锁,自动用 Temp 副本
if ($hasLocked) {
$guid = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
$newName = "$guid-$([System.IO.Path]::GetFileName($Path))"
$TempPath = "$TempDir\$newName"
Copy-Item $Path $TempPath -Force
$Path = $TempPath
$isTempCopy = $true
}
}
$autoAnalysis = if ($NoAutoAnalysis) { "false" } else { "true" }
$escapedPath = $Path -replace '\\', '\\'
# 始终使用明确的会话 ID,便于超时时轮询会话状态判断是否已成功打开
if (-not $SessionId) {
$SessionId = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
}
$body = @"
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_open","arguments":{"input_path":"$escapedPath","run_auto_analysis":$autoAnalysis,"session_id":null}}}
"@
if ($SessionId) {
$body = @"
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_open","arguments":{"input_path":"$escapedPath","run_auto_analysis":$autoAnalysis,"session_id":"$SessionId"}}}
"@
}
# 将打开请求放到后台,避免 HTTP 长时间不回包时阻塞整个脚本
$openJob = Start-Job -ScriptBlock {
param($RequestBody, $RequestPort)
try {
Invoke-RestMethod "http://127.0.0.1:$RequestPort/mcp" -Method Post -Body $RequestBody `
-ContentType "application/json" -ErrorAction Stop
} catch {
$_.Exception.Message
}
} -ArgumentList $body, $Port
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
$openCompleted = $false
$startTime = Get-Date
$lastProgressAt = $startTime.AddSeconds(-$ProgressIntervalSeconds)
try {
while ((Get-Date) -lt $deadline) {
if (Wait-Job -Job $openJob -Timeout 1) {
$openCompleted = $true
break
}
try {
$session = Get-OpenReadySession -ExpectedSessionId $SessionId -ExpectedPath $Path -RequestPort $Port
if ($session) {
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
exit 0
}
} catch {}
$now = Get-Date
if (($now - $lastProgressAt).TotalSeconds -ge $ProgressIntervalSeconds) {
$elapsed = [math]::Floor(($now - $startTime).TotalSeconds)
Write-Output "INFO:opening:$elapsed/${TimeoutSeconds}s"
$lastProgressAt = $now
}
Start-Sleep -Milliseconds $PollIntervalMs
}
if (-not $openCompleted) {
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
try {
$session = Get-OpenReadySession -ExpectedSessionId $SessionId -ExpectedPath $Path -RequestPort $Port
if ($session) {
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
exit 0
}
} catch {}
Write-Output "ERR:open_timeout_${TimeoutSeconds}s"
exit 1
}
$jobResult = Receive-Job -Job $openJob
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
if ($jobResult -is [string]) {
Write-Output "ERR:$jobResult"
exit 1
}
if ($jobResult.result.structuredContent.success -eq $true) {
$session = $jobResult.result.structuredContent.session
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
} else {
# 自动降级:非 Temp 副本失败时,复制到 Temp 重试
if (-not $isTempCopy) {
$guid = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
$newName = "$guid-$([System.IO.Path]::GetFileName($Path))"
$TempPath = "$TempDir\$newName"
Copy-Item $Path $TempPath -Force
& $PSCommandPath -Path $TempPath -SessionId $SessionId -NoAutoAnalysis:$NoAutoAnalysis -TimeoutSeconds $TimeoutSeconds
} else {
Write-Output "ERR:$($jobResult.result.structuredContent.error)"
}
}
} finally {
if ($openJob) {
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |