Skip to content

Commit

Permalink
Add ghidrecomp venv
Browse files Browse the repository at this point in the history
  • Loading branch information
reuteras committed Jan 24, 2024
1 parent 9849337 commit 161b5a7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
"gftrace",
"Ghidra",
"Ghidrathon",
"ghidrecomp",
"ghidrecompvenv",
"ghidriff",
"Gidhra",
"gitbash",
Expand Down
40 changes: 13 additions & 27 deletions resources/download/python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Write-DateLog "Pip packages done." >> "${ROOT_PATH}\log\python.txt"
42 changes: 40 additions & 2 deletions setup/install_python_tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 161b5a7

Please sign in to comment.