diff --git a/.vscode/settings.json b/.vscode/settings.json index 13c8183..4d40fdd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -129,6 +129,8 @@ "gftrace", "Ghidra", "Ghidrathon", + "ghidrecomp", + "ghidrecompvenv", "ghidriff", "Gidhra", "gitbash", diff --git a/resources/download/python.ps1 b/resources/download/python.ps1 index cdf43ec..3587625 100644 --- a/resources/download/python.ps1 +++ b/resources/download/python.ps1 @@ -2,45 +2,31 @@ param ( [String] $ScriptRoot=$PSScriptRoot ) -$ScriptRoot = "$ScriptRoot\resources\download" -${ROOT_PATH} = Resolve-Path "$ScriptRoot\..\..\" +${ScriptRoot} = "${ScriptRoot}\resources\download" +${ROOT_PATH} = Resolve-Path "${ScriptRoot}\..\..\" -. $ScriptRoot\common.ps1 +. "${ScriptRoot}\common.ps1" -Write-DateLog "Start Sandbox to install Python pip packages for dfirws." > ${ROOT_PATH}\log\python.txt +Write-DateLog "Start Sandbox to install Python pip packages for dfirws." > "${ROOT_PATH}\log\python.txt" -$mutex = New-Object System.Threading.Mutex($false, $mutexName) +$mutex = New-Object System.Threading.Mutex($false, ${mutexName}) -if (! (Test-Path -Path ${ROOT_PATH}\mount\venv )) { - New-Item -ItemType Directory -Force -Path ${ROOT_PATH}\mount\venv | Out-Null +if (! (Test-Path -Path "${ROOT_PATH}\mount\venv")) { + New-Item -ItemType Directory -Force -Path "${ROOT_PATH}\mount\venv" | Out-Null } -$venvs = @("chepy", "default", "dfir-unfurl", "dissect", "evt2sigma", "jep", "maldump", "pe2pic", "pySigma", "scare", "Zircolite") - -foreach ($venv in $venvs) { - if (! (Test-Path -Path ${ROOT_PATH}\mount\venv\${venv} )) { - New-Item -ItemType Directory -Force -Path ${ROOT_PATH}\mount\venv\${venv} | Out-Null - } -} - -foreach ($venv in $venvs) { - if (Test-Path -Path ${ROOT_PATH}\mount\venv\${venv}\${venv}.txt ) { - Copy-Item "${ROOT_PATH}\mount\venv\${venv}\${venv}.txt" "${ROOT_PATH}\tmp\mount\venv\${venv}\${venv}.txt" - } -} - -if (Test-Path -Path ${ROOT_PATH}\mount\venv\default\done ) { - Remove-Item ${ROOT_PATH}\mount\venv\default\done | Out-Null +if (Test-Path -Path "${ROOT_PATH}\mount\venv\default\done") { + Remove-Item "${ROOT_PATH}\mount\venv\default\done" | Out-Null } Copy-Item "${ROOT_PATH}\config.ps1" "${ROOT_PATH}\mount\venv\default\config.ps1" -(Get-Content ${ROOT_PATH}\resources\templates\generate_venv.wsb.template).replace('__SANDBOX__', ${ROOT_PATH}) | Set-Content ${ROOT_PATH}\tmp\generate_venv.wsb +(Get-Content ${ROOT_PATH}\resources\templates\generate_venv.wsb.template).replace('__SANDBOX__', "${ROOT_PATH}") | Set-Content "${ROOT_PATH}\tmp\generate_venv.wsb" $mutex.WaitOne() | Out-Null -& ${ROOT_PATH}\tmp\generate_venv.wsb +& "${ROOT_PATH}\tmp\generate_venv.wsb" Start-Sleep 10 -Remove-Item ${ROOT_PATH}\tmp\generate_venv.wsb | Out-Null +Remove-Item "${ROOT_PATH}\tmp\generate_venv.wsb" | Out-Null Stop-SandboxWhenDone "${ROOT_PATH}\mount\venv\default\done" $mutex | Out-Null @@ -55,4 +41,4 @@ Get-ChildItem -Path "${ROOT_PATH}\mount\venv\default\Scripts" -Filter *.py | For } } -Write-DateLog "Pip packages done." >> ${ROOT_PATH}\log\python.txt \ No newline at end of file +Write-DateLog "Pip packages done." >> "${ROOT_PATH}\log\python.txt" \ No newline at end of file diff --git a/setup/install_python_tools.ps1 b/setup/install_python_tools.ps1 index b20d2ca..6dfaf59 100644 --- a/setup/install_python_tools.ps1 +++ b/setup/install_python_tools.ps1 @@ -361,8 +361,7 @@ if ((Get-FileHash C:\tmp\pySigma.txt).Hash -ne (Get-FileHash $CURRENT_VENV).Hash --no-interaction poetry add ` - pySigma>=0.9.6 ` - wheel>=0.41.3 2>&1 >> "C:\log\python.txt" + pySigma>=0.9.6 2>&1 >> "C:\log\python.txt" Copy-Item ${TEMP}\pySigma.txt "C:\venv\pySigma\pySigma.txt" -Force 2>&1 >> "C:\log\python.txt" deactivate @@ -596,4 +595,43 @@ if ((Get-FileHash C:\tmp\dissect.txt).Hash -ne (Get-FileHash $CURRENT_VENV).Hash Write-DateLog "dissect has not been updated, don't update dissect venv." >> "C:\log\python.txt" } + +# +# venv ghidrecomp +# + +& "$PYTHON_BIN" -m pip index versions ghidrecomp 2>&1 | findstr "Available versions:" | ForEach-Object { $_.split(" ")[2] } | ForEach-Object { $_.split(",")[0] } | Select-Object -Last 1 > ${TEMP}\ghidrecomp.txt + +if (Test-Path "C:\venv\ghidrecomp\ghidrecomp.txt") { + $CURRENT_VENV = "C:\venv\ghidrecomp\ghidrecomp.txt" +} else { + $CURRENT_VENV = "C:\Progress.ps1" +} + +if ((Get-FileHash C:\tmp\ghidrecomp.txt).Hash -ne (Get-FileHash $CURRENT_VENV).Hash) { + Write-DateLog "Install ghidrecomp in venv ghidrecomp in sandbox." >> "C:\log\python.txt" + Get-ChildItem C:\venv\ghidrecomp\* -Exclude ghidrecomp.txt -Recurse | Remove-Item -Force 2>&1 | Out-null + Start-Process -Wait -FilePath "$PYTHON_BIN" -ArgumentList "-m venv C:\venv\ghidrecomp" + C:\venv\ghidrecomp\Scripts\Activate.ps1 >> "C:\log\python.txt" + Set-Location "C:\venv\ghidrecomp" + python -m pip install -U pip >> "C:\log\python.txt" + python -m pip install -U poetry >> "C:\log\python.txt" + + poetry init ` + --name ghidrecompvenv ` + --description "Python venv for ghidrecomp." ` + --author "dfirws" ` + --license "MIT" ` + --no-interaction + + poetry add ` + ghidrecomp 2>&1 >> "C:\log\python.txt" + + Copy-Item ${TEMP}\ghidrecomp.txt "C:\venv\ghidrecomp\ghidrecomp.txt" -Force 2>&1 >> "C:\log\python.txt" + deactivate + Write-DateLog "Python venv ghidrecomp done." >> "C:\log\python.txt" +} else { + Write-DateLog "ghidrecomp has not been updated, don't update ghidrecomp venv." >> "C:\log\python.txt" +} + Write-Output "" > C:\venv\default\done \ No newline at end of file