Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify a custom ghidrathon.save path via an environment variable #99

Merged
merged 18 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ Use the following steps to install Ghidrathon to your Ghidra environment:
$ python -m pip install -r requirements.txt
$ python ghidrathon_configure.py <absolute_path_to_ghidra_install_dir>
```
**Note**: If you want to use a custom directory path for the ghidrathon.save file location, set the `GHIDRATHON_SAVE_PATH` environment variable before running ghidrathon_configure.py:
fariss marked this conversation as resolved.
Show resolved Hide resolved
```
$ export GHIDRATHON_SAVE_PATH="/path/to/custom/dir" # Linux/MacOS
$ set GHIDRATHON_SAVE_PATH="C:\path\to\custom\dir" # Windows
```
**Note**: you may be prompted to set an environment variable named `JAVA_HOME`. This should reference the absolute path of the JDK that you have configured for your Ghidra install.

3. Install the Ghidrathon extension (`.zip`) into Ghidra:
Expand Down
5 changes: 4 additions & 1 deletion util/ghidrathon_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.

import os
import sys
import json
import logging
Expand All @@ -17,6 +18,7 @@
SUPPORTED_JEP_VERSION = "4.2.0"
PYTHON_HOME_DIR_KEY = "home"
PYTHON_EXECUTABLE_FILE_KEY = "executable"
GHIDRATHON_SAVE_PATH = "GHIDRATHON_SAVE_PATH"

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -91,7 +93,8 @@ def main(args):
logger.debug('Using Python home located at "%s".', home_path)

json_: str = json.dumps(ghidrathon_save)
save_path: pathlib.Path = install_path / "ghidrathon.save"
save_path: pathlib.Path = pathlib.Path(os.environ.get(GHIDRATHON_SAVE_PATH, install_path)) / "ghidrathon.save"
fariss marked this conversation as resolved.
Show resolved Hide resolved
fariss marked this conversation as resolved.
Show resolved Hide resolved
logger.debug('Using ghidrathon.save path: "%s"' % save_path)
try:
save_path.write_text(json_, encoding="utf-8")
except Exception as e:
Expand Down
Loading