mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GT-2740 corrected svrAdmin and createPdbXmlFiles script use in
development mode. Other minor cleanup.
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
#!/bin/bash
|
||||
# ***********************************************************
|
||||
# ** Arguments (each -argument option may be repeated):
|
||||
# ** [-add <sid>] [-remove <sid>] [-reset <sid>] [-dn <sid> "<x500_distinguished_name>"]
|
||||
# ** [-admin <sid> "<repository-name>"] [-list] [-migrate "<repository-name>"] [-migrate-all]
|
||||
# ** [-add <sid>] [-dn <sid> "<x500_distinguished_name>"]
|
||||
# ** [-remove <sid>]
|
||||
# ** [-reset <sid>]
|
||||
# ** [-admin <sid> "<repository-name>"]
|
||||
# ** [-list] [-users]
|
||||
# ** [-migrate "<repository-name>"] [-migrate-all]
|
||||
# **
|
||||
# ** add - add a new user to the server with the default password 'changeme'
|
||||
# ** dn - set a user's distinguished name for PKI authentication
|
||||
# ** remove - remove an existing user from the server
|
||||
# ** reset - reset an existing user's password to 'changeme'
|
||||
# ** dn - set a user's distinguished name for PKI authentication
|
||||
# ** admin - set the specified existing user as an admin of the specified repository
|
||||
# ** list - list all existing named repositories
|
||||
# ** users - list all users or those associated with each listed repository
|
||||
# ** migrate - migrate the specified named repository to an indexed data storage
|
||||
# ** migrate-all - migrate all named repositories to index data storage
|
||||
# ***********************************************************
|
||||
|
||||
UMASK=027
|
||||
SUDO=sudo
|
||||
|
||||
# Preserve quoted arguments
|
||||
ARGS=()
|
||||
WHITESPACE="[[:space:]]"
|
||||
for AA in "$@"; do
|
||||
if [[ $AA =~ $WHITESPACE ]]; then
|
||||
AA="\"$AA\""
|
||||
fi
|
||||
ARGS[${#ARGS[@]}]=$AA
|
||||
done
|
||||
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
|
||||
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
|
||||
MAXMEM=128M
|
||||
|
||||
# Resolve symbolic link if present and get the directory this script lives in.
|
||||
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
|
||||
@@ -34,49 +34,21 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo
|
||||
SCRIPT_DIR="${SCRIPT_FILE%/*}"
|
||||
|
||||
if [ -d "${SCRIPT_DIR}/../Ghidra" ]; then
|
||||
|
||||
# Production Environment
|
||||
CONFIG="${SCRIPT_DIR}/server.conf"
|
||||
GHIDRA_DIR="${SCRIPT_DIR}/../Ghidra"
|
||||
CPATH="${GHIDRA_DIR}/Features/GhidraServer/lib/GhidraServer.jar:${GHIDRA_DIR}/Framework/FileSystem/lib/FileSystem.jar:${GHIDRA_DIR}/Framework/DB/lib/DB.jar:${GHIDRA_DIR}/Framework/Generic/lib/Generic.jar:${GHIDRA_DIR}/Framework/Utility/lib/Utility.jar:${GHIDRA_DIR}/Framework/Generic/lib/log4j-core-2.8.1.jar:${GHIDRA_DIR}/Framework/Generic/lib/log4j-api-2.8.1.jar"
|
||||
LS_CPATH="${GHIDRA_DIR}/../support/LaunchSupport.jar"
|
||||
else
|
||||
|
||||
# Development Environment
|
||||
CONFIG="${SCRIPT_DIR}/../../Common/server/server.conf"
|
||||
GHIDRA_DIR="${SCRIPT_DIR}/../../.."
|
||||
GHIDRA_BIN_REPO="${GHIDRA_DIR}/../../ghidra.bin"
|
||||
CPATH="${GHIDRA_DIR}/Features/GhidraServer/bin/main:${GHIDRA_DIR}/Framework/FileSystem/bin/main:${GHIDRA_DIR}/Framework/DB/bin/main:${GHIDRA_DIR}/Framework/Generic/bin/main:${GHIDRA_DIR}/Framework/Utility/bin/main:${GHIDRA_BIN_REPO}/ExternalLibraries/libsForRuntime/log4j-core-2.8.1.jar:${GHIDRA_BIN_REPO}/ExternalLibraries/libsForRuntime/log4j-api-2.8.1.jar"
|
||||
LS_CPATH="${GHIDRA_DIR}/../GhidraBuild/LaunchSupport/bin/main"
|
||||
fi
|
||||
|
||||
# Make sure some kind of java is on the path. It's required to run the LaunchSupport program.
|
||||
if ! [ -x "$(command -v java)" ] ; then
|
||||
echo "Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the java that will be used to launch GhidraServer
|
||||
JAVA_HOME=$(java -cp "${LS_CPATH}" LaunchSupport "${GHIDRA_DIR}/.." -java_home)
|
||||
if [ ! $? -eq 0 ]; then
|
||||
echo "Failed to find a supported Java runtime. Please refer to the Ghidra Installation Guide's Troubleshooting section."
|
||||
exit 1
|
||||
fi
|
||||
JAVA_CMD="${JAVA_HOME}/bin/java"
|
||||
|
||||
VMARGS="-DUserAdmin.invocation=$(basename "${SCRIPT_FILE}") -DUserAdmin.config=\"${CONFIG}\""
|
||||
|
||||
OLD_UMASK=$(umask)
|
||||
umask $UMASK
|
||||
|
||||
# Identify server process owner if set within server.conf
|
||||
OWNER="$(grep '^wrapper.app.account=' "${CONFIG}" | sed -e 's/^.*=\(.*\)\s*.*$/\1/')"
|
||||
|
||||
if [ -z "${OWNER}" -o "${OWNER}" = "$(whoami)" ]; then
|
||||
eval "\"${JAVA_CMD}\" ${VMARGS} -cp \"${CPATH}\" ghidra.server.UserAdmin ${ARGS[@]}"
|
||||
umask $UMASK
|
||||
VMARGS="-DUserAdmin.invocation=$(basename "${SCRIPT_FILE}") -DUserAdmin.config=\"${CONFIG}\""
|
||||
. "${SCRIPT_DIR}"/../support/launch.sh fg svrAdmin "${MAXMEM}" "$VMARGS" ghidra.server.ServerAdmin "$@"
|
||||
else
|
||||
echo "Running svrAdmin with sudo as ${OWNER} ..."
|
||||
eval "sudo -u "${OWNER}" \"${JAVA_CMD}\" ${VMARGS} -cp \"${CPATH}\" ghidra.server.UserAdmin ${ARGS[@]}"
|
||||
echo "Running svrAdmin with $SUDO as ${OWNER} ..."
|
||||
$SUDO -u $OWNER "$0" "${ARGS[@]}"
|
||||
fi
|
||||
|
||||
umask $OLD_UMASK
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
@echo off
|
||||
|
||||
:: ***********************************************************
|
||||
:: ** Arguments (each argument set may be repeated):
|
||||
:: ** [-add <sid>] [-remove <sid>] [-reset <sid>] [-dn <sid> "<x500_distinguished_name>"]
|
||||
:: ** [-admin <sid> "<repository-name>"] [-list] [-migrate "<repository-name>"] [-migrate-all]
|
||||
:: ** Arguments (each -argument option may be repeated):
|
||||
:: ** [-add <sid>] [-dn <sid> "<x500_distinguished_name>"]
|
||||
:: ** [-remove <sid>]
|
||||
:: ** [-reset <sid>]
|
||||
:: ** [-admin <sid> "<repository-name>"]
|
||||
:: ** [-list] [-users]
|
||||
:: ** [-migrate "<repository-name>"] [-migrate-all]
|
||||
:: **
|
||||
:: ** add - add a new user to the server with the default password 'changeme'
|
||||
:: ** dn - set a user's distinguished name for PKI authentication
|
||||
:: ** remove - remove an existing user from the server
|
||||
:: ** reset - reset an existing user's password to 'changeme'
|
||||
:: ** dn - set a user's distinguished name for PKI authentication
|
||||
:: ** admin - set the specified existing user as an admin of the specified repository
|
||||
:: ** list - list all existing named repositories
|
||||
:: ** users - list all users or those associated with each listed repository
|
||||
:: ** migrate - migrate the specified named repository to an indexed data storage
|
||||
:: ** migrate-all - migrate all named repositories to index data storage
|
||||
:: ***********************************************************
|
||||
|
||||
setlocal
|
||||
|
||||
:: maximum heap memory may be change if inadequate
|
||||
set MAXMEM=128M
|
||||
|
||||
:: Sets SCRIPT_DIR to the directory that contains this file
|
||||
::
|
||||
:: '% ~' dereferences the value in param 0
|
||||
@@ -24,51 +32,16 @@ setlocal
|
||||
:: 'p' - path (without filename)
|
||||
set SCRIPT_DIR=%~dp0
|
||||
|
||||
:: Uncomment and set the value below as necessary
|
||||
:: set SCRIPT_DIR=<full Ghidra installation server directory path>
|
||||
|
||||
if not exist "%SCRIPT_DIR%" (
|
||||
echo Unable to set the Ghidra server script directory.
|
||||
echo.
|
||||
echo To run Ghidra in this mode you must set the
|
||||
echo value of SCRIPT_DIR in this file to be
|
||||
echo the full path containing this batch file
|
||||
goto :eof
|
||||
)
|
||||
|
||||
:: Production Environment
|
||||
set CONFIG=%SCRIPT_DIR%.\server.conf
|
||||
set GHIDRA_DIR=%SCRIPT_DIR%..\Ghidra
|
||||
set CPATH=%GHIDRA_DIR%\Features\GhidraServer\lib\GhidraServer.jar;%GHIDRA_DIR%\Framework\FileSystem\lib\FileSystem.jar;%GHIDRA_DIR%\Framework\DB\lib\DB.jar;%GHIDRA_DIR%\Framework\Generic\lib\Generic.jar;%GHIDRA_DIR%\Framework\Utility\lib\Utility.jar;%GHIDRA_DIR%\Framework\Generic\lib\log4j-core-2.8.1.jar;%GHIDRA_DIR%\Framework\Generic\lib\log4j-api-2.8.1.jar
|
||||
set LS_CPATH=%GHIDRA_DIR%\..\support\LaunchSupport.jar
|
||||
|
||||
if exist "%GHIDRA_DIR%" goto continue
|
||||
|
||||
:: Development Environment - assumes suitable java in command path
|
||||
:: Development Environment
|
||||
set CONFIG=%SCRIPT_DIR%..\..\Common\server\server.conf
|
||||
set GHIDRA_DIR=%SCRIPT_DIR%..\..\..
|
||||
set GHIDRA_BIN_HOME=%GHIDRA_DIR%\..\..\ghidra.bin
|
||||
set CPATH=%GHIDRA_DIR%\Features\GhidraServer\bin\main;%GHIDRA_DIR%\Framework\FileSystem\bin\main;%GHIDRA_DIR%\Framework\DB\bin\main;%GHIDRA_DIR%\Framework\Generic\bin\main;%GHIDRA_DIR%\Framework\Utility\bin\main;%GHIDRA_BIN_HOME%\ExternalLibraries\libsForRuntime\log4j-core-2.8.1.jar;%GHIDRA_BIN_HOME%\ExternalLibraries\libsForRuntime\log4j-api-2.8.1.jar
|
||||
set LS_CPATH=%GHIDRA_DIR%\..\GhidraBuild\LaunchSupport\bin\main
|
||||
|
||||
:continue
|
||||
|
||||
:: Make sure some kind of java is on the path. It's required to run the LaunchSupport program.
|
||||
java -version >nul 2>nul
|
||||
if not %ERRORLEVEL% == 0 (
|
||||
echo Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section.
|
||||
exit /B 1
|
||||
)
|
||||
set VMARGS=-DUserAdmin.invocation="%0" -DUserAdmin.config="%CONFIG%"
|
||||
|
||||
:: Get the java that will be used to launch GhidraServer
|
||||
set JAVA_HOME=
|
||||
for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%GHIDRA_DIR%\.." -java_home') do set JAVA_HOME=%%i
|
||||
if "%JAVA_HOME%" == "" (
|
||||
echo Failed to find a supported Java runtime. Please refer to the Ghidra Installation Guide's Troubleshooting section.
|
||||
exit /B 1
|
||||
)
|
||||
set JAVA=%JAVA_HOME%\bin\java.exe
|
||||
|
||||
set VMARGS=-DUserAdmin.invocation="%0" -DUserAdmin.config="%CONFIG%" -Djava.net.preferIPv4Stack=true
|
||||
|
||||
"%JAVA%" %VMARGS% -cp "%CPATH%" ghidra.server.UserAdmin %*
|
||||
call "%~dp0\..\support\launch.bat" fg svrAdmin "%MAXMEM%" "%VMARGS%" ghidra.server.ServerAdmin %*
|
||||
|
||||
@@ -10,31 +10,45 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
if "%~1" == "" (
|
||||
echo "Usage: createPdbXmlFiles.bat <path to .pdb file|path to directory of .pdb files>"
|
||||
Exit /B 0
|
||||
)
|
||||
|
||||
REM Get parent of current folder
|
||||
for %%A in (%~dp0\.) do set ghidraPath=%%~dpA
|
||||
set SCRIPT_DIR=%~dp0
|
||||
|
||||
set GHIDRA_DIR=%SCRIPT_DIR%Ghidra
|
||||
set OS_DIR=os
|
||||
|
||||
REM Production Environment
|
||||
if exist "%ghidraPath%Ghidra" goto continue
|
||||
if exist "%GHIDRA_DIR%" goto continue
|
||||
|
||||
REM Development Environment
|
||||
set ghidraPath="%ghidraPath%..\..\..\..\ghidra.bin\"
|
||||
set GHIDRA_DIR=%SCRIPT_DIR%..\..\..
|
||||
set OS_DIR=build\os
|
||||
|
||||
:continue
|
||||
|
||||
set arg1="%~1"
|
||||
REM create absolute path
|
||||
for /f %%i in ("%GHIDRA_DIR%") do set GHIDRA_DIR=%%~fi
|
||||
|
||||
REM Determine if 64-bit or 32-bit
|
||||
if exist "%PROGRAMFILES(X86)%" (
|
||||
set osType=win64
|
||||
set OS_TYPE=win64
|
||||
) else (
|
||||
set osType=win32
|
||||
set OS_TYPE=win32
|
||||
)
|
||||
|
||||
set PDB_EXE=%GHIDRA_DIR%\Features\PDB\%OS_DIR%\%OS_TYPE%\pdb.exe
|
||||
|
||||
if not exist "%PDB_EXE%" (
|
||||
echo "%PDB_EXE% not found"
|
||||
Exit /B 1
|
||||
)
|
||||
|
||||
if "%~1" == "" (
|
||||
echo "Usage: createPdbXmlFiles.bat <path to .pdb file|path to directory of .pdb files>"
|
||||
Exit /B 1
|
||||
)
|
||||
|
||||
set arg1="%~1"
|
||||
|
||||
set /a count=0
|
||||
|
||||
REM Recursively traverse through the given directory
|
||||
@@ -50,7 +64,7 @@ for /f "tokens=* delims=" %%a in ('dir %arg1% /s /b') do (
|
||||
setlocal enableDelayedExpansion
|
||||
(
|
||||
echo "Processing file: %%a"
|
||||
START /B /WAIT "" "%ghidraPath%Ghidra\Features\PDB\os\%ostype%\pdb.exe" %%a > "%%a.xml"
|
||||
START /B /WAIT "" "%PDB_EXE%" %%a > "%%a.xml"
|
||||
|
||||
REM Exit if executable returned non-zero error code (signifies that there is a problem).
|
||||
if !errorlevel! neq 0 (
|
||||
@@ -63,7 +77,7 @@ for /f "tokens=* delims=" %%a in ('dir %arg1% /s /b') do (
|
||||
echo Error detected. Exiting...
|
||||
)
|
||||
|
||||
Exit /B 0
|
||||
Exit /B 1
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user