Merge remote-tracking branch 'origin/patch'

This commit is contained in:
ghidra1 2021-06-23 17:13:23 -04:00
commit ecef7844fd
14 changed files with 99 additions and 56 deletions

View file

@ -57,15 +57,13 @@ public class Ext4FileSystem implements GFileSystem {
this.uuid = NumericUtilities.convertBytesToString(superBlock.getS_uuid());
long blockCount = superBlock.getS_blocks_count();
int s_log_block_size = superBlock.getS_log_block_size();
blockSize = (int) Math.pow(2, (10 + s_log_block_size));
int groupSize = blockSize * superBlock.getS_blocks_per_group();
if (groupSize <= 0) {
throw new IOException("Invalid groupSize: " + groupSize);
}
int numGroups = (int) (provider.length() / groupSize);
if (provider.length() % groupSize != 0) {
int numGroups = (int) (blockCount / superBlock.getS_blocks_per_group());
if (blockCount % superBlock.getS_blocks_per_group() != 0) {
numGroups++;
}
@ -81,7 +79,7 @@ public class Ext4FileSystem implements GFileSystem {
monitor.incrementProgress(1);
}
Ext4Inode[] inodes = getInodes(reader, superBlock, groupDescriptors, is64Bit, monitor);
Ext4Inode[] inodes = getInodes(reader, superBlock, groupDescriptors, monitor);
int s_inodes_count = superBlock.getS_inodes_count();
for (int i = 0; i < s_inodes_count; i++) {
@ -400,23 +398,19 @@ public class Ext4FileSystem implements GFileSystem {
}
private Ext4Inode[] getInodes(BinaryReader reader, Ext4SuperBlock superBlock,
Ext4GroupDescriptor[] groupDescriptors, boolean is64Bit, TaskMonitor monitor)
Ext4GroupDescriptor[] groupDescriptors, TaskMonitor monitor)
throws IOException, CancelledException {
int inodeCount = superBlock.getS_inodes_count();
int inodesPerGroup = superBlock.getS_inodes_per_group();
Ext4Inode[] inodes = new Ext4Inode[inodeCount + 1];
int inodeIndex = 1;
for (int i = 0; i < groupDescriptors.length; i++) {
monitor.checkCanceled();
long inodeTableBlockOffset = groupDescriptors[i].getBg_inode_table_lo() & 0xffffffffL;
if (is64Bit) {
inodeTableBlockOffset =
(groupDescriptors[i].getBg_inode_table_hi() << 32) | inodeTableBlockOffset;
}
long inodeTableBlockOffset = groupDescriptors[i].getBg_inode_table();
long offset = inodeTableBlockOffset * blockSize;
reader.setPointerIndex(offset);
int inodesPerGroup = superBlock.getS_inodes_per_group();
monitor.setMessage(
"Reading inode table " + i + " of " + (groupDescriptors.length - 1) + "...");
monitor.setMaximum(inodesPerGroup);

View file

@ -149,6 +149,14 @@ public class Ext4GroupDescriptor implements StructConverter {
return bg_inode_table_hi;
}
/**
* Return the calculated inode table value by combining bg_inode_table_lo and bg_inode_table_hi
* @return the calculated inode table value by combining bg_inode_table_lo and bg_inode_table_hi
*/
public long getBg_inode_table() {
return ((long) bg_inode_table_hi << 32) | Integer.toUnsignedLong(bg_inode_table_lo);
}
public short getBg_free_blocks_count_hi() {
return bg_free_blocks_count_hi;
}

View file

@ -226,6 +226,14 @@ public class Ext4SuperBlock implements StructConverter {
return s_blocks_count_lo;
}
/**
* Return the calculated block count by combining the s_blocks_count_lo and s_blocks_count_hi
* @return the calculated block count by combining the s_blocks_count_lo and s_blocks_count_hi
*/
public long getS_blocks_count() {
return ((long) s_blocks_count_hi << 32) | Integer.toUnsignedLong(s_blocks_count_lo);
}
public int getS_r_blocks_count_lo() {
return s_r_blocks_count_lo;
}

View file

@ -55,7 +55,6 @@ import ghidra.server.stream.RemoteBlockStreamHandle;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.DuplicateNameException;
import resources.ResourceManager;
import utilities.util.FileUtilities;
import utility.application.ApplicationLayout;
@ -73,7 +72,7 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
private static Logger log;
private static String HELP_FILE = "/ghidra/server/remote/ServerHelp.txt";
private static String HELP_FILE = "ServerHelp.txt";
private static String USAGE_ARGS =
"[-ip <hostname>] [-i #.#.#.#] [-p#] [-n] [-a#] [-d<ad_domain>] [-e<days>] [-jaas <config_file>] [-u] [-autoProvision] [-anonymous] [-ssh] <repository_path>";
@ -411,7 +410,7 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
private static void displayHelp() {
try (InputStream in = ResourceManager.getResourceAsStream(HELP_FILE)) {
try (InputStream in = GhidraServer.class.getResourceAsStream(HELP_FILE)) {
List<String> lines = FileUtilities.getLines(in);
lines.stream().forEach(s -> System.out.println(s));
}

View file

@ -64,6 +64,12 @@ SERVICE_NAME=org.rzo.yajsw.$APP_NAME
SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Ensure Ghidra path doesn't contain illegal characters
if [[ "$SCRIPT_DIR" = *"!"* ]]; then
echo "Ghidra path cannot contain a \"!\" character."
exit 1
fi
# YAJSW likes absolute paths
cd "${SCRIPT_DIR}"
SCRIPT_DIR="$(pwd)"

View file

@ -86,7 +86,15 @@ if [[ ${INDEX} -lt 5 ]]; then
exit 1
fi
# Sets SUPPORT_DIR to the directory that contains this file (launch.sh)
SUPPORT_DIR="${0%/*}"
# Ensure Ghidra path doesn't contain illegal characters
if [[ "$SUPPORT_DIR" = *"!"* ]]; then
echo "Ghidra path cannot contain a \"!\" character."
exit 1
fi
if [ -f "${SUPPORT_DIR}/launch.properties" ]; then
# Production Environment

View file

@ -13,6 +13,22 @@ rem below:
rem set "JAVA_HOME="
:: Sets SERVER_DIR to the directory that contains this file (ghidraSvr.bat).
:: SERVER_DIR will not contain a trailing slash.
::
:: '% ~' dereferences the value in param 0
:: 'd' - drive
:: 'p' - path (without filename)
:: '~0,-1' - removes trailing \
set "SERVER_DIR=%~dp0"
set "SERVER_DIR=%SERVER_DIR:~0,-1%"
rem Ensure Ghidra path doesn't contain illegal characters
if not %SERVER_DIR:!=%==%SERVER_DIR% (
echo Ghidra path cannot contain a "!" character.
exit /B 1
)
setlocal enabledelayedexpansion
set OPTION=%1
@ -48,10 +64,6 @@ if "%IS_ADMIN%"=="NO" (
if "%OPTION%"=="restart" goto adminFail
)
rem Find the script directory
rem %~dsp0 is location of current script under NT
set "_REALPATH=%~dp0"
set APP_NAME=ghidraSvr
set APP_LONG_NAME=Ghidra Server
@ -59,13 +71,13 @@ set MODULE_DIR=Ghidra\Features\GhidraServer
set WRAPPER_NAME_PREFIX=yajsw
if exist "%_REALPATH%..\Ghidra\" goto normal
if exist "%SERVER_DIR%\..\Ghidra\" goto normal
rem NOTE: If adjusting JAVA command assignment - do not attempt to add parameters (e.g., -d64, -version:1.7, etc.)
rem Development Environment
set "GHIDRA_HOME=%_REALPATH%..\..\..\.."
set "WRAPPER_CONF=%_REALPATH%..\..\Common\server\server.conf"
set "GHIDRA_HOME=%SERVER_DIR%\..\..\..\.."
set "WRAPPER_CONF=%SERVER_DIR%\..\..\Common\server\server.conf"
set "DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\build\data"
set "CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\build\dev-meta\classpath.frag"
set "LS_CPATH=%GHIDRA_HOME%\GhidraBuild\LaunchSupport\bin\main"
@ -73,8 +85,8 @@ set "LS_CPATH=%GHIDRA_HOME%\GhidraBuild\LaunchSupport\bin\main"
goto lab1
:normal
set "GHIDRA_HOME=%_REALPATH%.."
set "WRAPPER_CONF=%_REALPATH%server.conf"
set "GHIDRA_HOME=%SERVER_DIR%\.."
set "WRAPPER_CONF=%SERVER_DIR%\server.conf"
set "DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\data"
set "CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\data\classpath.frag"
set "LS_CPATH=%GHIDRA_HOME%\support\LaunchSupport.jar"

View file

@ -1,10 +1,6 @@
@echo off
setlocal
rem Find the script directory
rem %~dsp0 is location of current script under NT
set "_REALPATH=%~dp0"
call "%_REALPATH%\ghidraSvr" install
call "%~dp0ghidraSvr" install
pause

View file

@ -1,11 +1,7 @@
@echo off
setlocal
rem Find the script directory
rem %~dsp0 is location of current script under NT
set "_REALPATH=%~dp0"
call "%_REALPATH%\ghidraSvr" uninstall
call "%~dp0ghidraSvr" uninstall
pause

View file

@ -1,8 +1,7 @@
:: Ghidra Headless Analyzer launch (see analyzeHeadlessREADME.html)
@echo off
setlocal EnableDelayedExpansion
setlocal
:: Maximum heap memory size. For headless, it is recommended to not use the default value
:: because garbage collection could take too long on systems with a large amount of physical
@ -23,9 +22,6 @@ set DEBUG_ADDRESS=127.0.0.1:13002
set VMARG_LIST=-XX:ParallelGCThreads=2
set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2
:: store current path
set "filepath=%~dp0"
:: Loop through parameters (if there aren't any, just continue) and store
:: in params variable.
@ -36,6 +32,7 @@ if "%~1" == "" goto cont
:: If -import is found and Windows has not done proper wildcard expansion, force
:: this to happen and save expansion to params variable.
setlocal EnableDelayedExpansion
if "%~1" == "-import" (
set params=!params! -import
for %%f in ("%~2") DO (
@ -45,10 +42,11 @@ if "%~1" == "-import" (
) else (
set params=!params! "%~1"
)
setlocal DisableDelayedExpansion
shift
goto Loop
:cont
call "%filepath%launch.bat" %LAUNCH_MODE% Ghidra-Headless "%MAXMEM%" "%VMARG_LIST%" ghidra.app.util.headless.AnalyzeHeadless %params%
call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra-Headless "%MAXMEM%" "%VMARG_LIST%" ghidra.app.util.headless.AnalyzeHeadless %params%

View file

@ -7,10 +7,17 @@ setlocal
:: fg, debug, debug-suspend
set LAUNCH_MODE=fg
:: Sets SCRIPT_DIR to the directory that contains this file (ends with '\')
set "SCRIPT_DIR=%~dp0"
:: Sets SUPPORT_DIR to the directory that contains this file (buildGhidraJar.bat).
:: SUPPORT_DIR will not contain a trailing slash.
::
:: '% ~' dereferences the value in param 0
:: 'd' - drive
:: 'p' - path (without filename)
:: '~0,-1' - removes trailing \
set "SUPPORT_DIR=%~dp0"
set "SUPPORT_DIR=%SUPPORT_DIR:~0,-1%"
set "GHIDRA_ROOT_DIR=%SCRIPT_DIR%..\Ghidra"
set "GHIDRA_ROOT_DIR=%SUPPORT_DIR%\..\Ghidra"
if exist "%GHIDRA_ROOT_DIR%" goto continue
echo This script does not support development mode use
@ -20,4 +27,4 @@ exit /B 1
set APP_VMARGS=-DGhidraJarBuilder.Name=%~n0
call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %*
call "%SUPPORT_DIR%\launch.bat" %LAUNCH_MODE% Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %*

View file

@ -24,9 +24,6 @@ exit /B 1
:continue
:: Delay the expansion of our loop items below since the value is being updated as the loop works
setlocal enabledelayedexpansion
:: See if we were doubled clicked or run from a command prompt
set DOUBLE_CLICKED=n
for /f "tokens=2" %%# in ("%cmdcmdline%") do if /i "%%#" equ "/c" set DOUBLE_CLICKED=y
@ -40,6 +37,17 @@ for /f "tokens=2" %%# in ("%cmdcmdline%") do if /i "%%#" equ "/c" set DOUBLE_CLI
:: '~0,-1' - removes trailing \
set "SUPPORT_DIR=%~dp0"
set "SUPPORT_DIR=%SUPPORT_DIR:~0,-1%"
:: Ensure Ghidra path doesn't contain illegal characters
if not %SUPPORT_DIR:!=%==%SUPPORT_DIR% (
echo Ghidra path cannot contain a "!" character.
set ERRORLEVEL=1
goto exit1
)
:: Delay the expansion of our loop items below since the value is being updated as the loop works
setlocal enabledelayedexpansion
::
:: Parse arguments
::

View file

@ -1,8 +1,7 @@
:: Ghidra python launch
@echo off
setlocal EnableDelayedExpansion
setlocal
:: Maximum heap memory size
:: Default for Windows 32-bit is 768M and 64-bit is 1024M
@ -25,7 +24,4 @@ set DEBUG_ADDRESS=127.0.0.1:13002
set VMARG_LIST=-XX:ParallelGCThreads=2
set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2
:: store current path
set "filepath=%~dp0"
call "%filepath%launch.bat" %LAUNCH_MODE% Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%
call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%

View file

@ -18,7 +18,7 @@
<h1>Ghidra Installation Guide</h1>
<p>
The installation information provided is effective as of Ghidra 9.2 and is subject to change with
The installation information provided is effective as of Ghidra 10.0.1 and is subject to change with
future releases.
</p>
@ -537,6 +537,10 @@ be installed in a pre-existing Eclipse installation.</p>
new files. Future versions of Ghidra will address this in order to ensure compatibility with
the newest versions of Java.
</li>
<li>
Ghidra will not launch when its path contains a "!" character. This is to avoid issues that
Java's internal libraries have parsing these paths ("!" is used as a jar-separator by Java).
</li>
</ul>
<h3><a name="WindowsIssues"></a>Windows</h3>
<ul>
@ -544,6 +548,9 @@ be installed in a pre-existing Eclipse installation.</p>
Older versions of 7-Zip may not be able to unpack the Ghidra distribution file if it contains
any files with a 0-byte length. Upgrade to a newer version of 7-Zip to fix this problem.
</li>
<li>
Ghidra will fail to launch when its path contains a "^" character.
</li>
</ul>
<h3><a name="LinuxIssues"></a>Linux</h3>
<ul>