Skip to content

Instantly share code, notes, and snippets.

@fenugrec
Last active December 19, 2025 12:48
Show Gist options
  • Select an option

  • Save fenugrec/49091f26ae3ee944087c47777b67023e to your computer and use it in GitHub Desktop.

Select an option

Save fenugrec/49091f26ae3ee944087c47777b67023e to your computer and use it in GitHub Desktop.
change owner of ghidra project
#!/bin/bash
#
# grab ownership of ghidra project specified in arg1 or current dir if absent
#
# - looks for the first <projectname>.gpr file
# - modifies owner name <projectname>/project.prp
#
# example : ./ghrab.sh ~/RE/coolstuff
# Discussed in https://github.com/NationalSecurityAgency/ghidra/issues/5507
# " if you create a project under your current username then try to give it to someone else,
# or otherwise just copy it to another machine or VM with a different user name you will get an error:
# "..Failure to open project ... NoOwnerException: Project is not owned by xxx.."
#
# obvious caveat : this is a bad idea if permissions are not appropriate on some of the project files.
u=$(whoami)
# use arg1 if defined, else pwd
base_dir="${1:-$(pwd)}"
gpr_file=$(find "$base_dir" -name "*.gpr" -printf %f -quit)
if [ -z "$gpr_file" ]; then
echo "no .gpr file found !"
exit 1
fi
prj_name=${gpr_file%.gpr}
prp_file="$base_dir/${prj_name}.rep/project.prp"
if ! [ -f "$prp_file" ]; then
echo "$prp_file" not found !
exit 1
fi
echo Found ghidra project: "$prj_name"
sed "$prp_file" -i -e "/OWNER/s/VALUE=\"[^\"]\+/VALUE=\"$u/"
@fenugrec
Copy link
Author

I had an assortment of projects in a directory and the script only appeared to work on one at a time,

Interesting, that's something I haven't encountered here (if I'm looking at different fw / sw versions I'll typically load them all in the same ghidra project, makes it easier to share data between them).

for file in *.gpr; do
....

So your version is hardcoded to look in current dir ? why not for file in "$base_dir/*.gpr" (untested) ?

@hogsy
Copy link

hogsy commented Nov 24, 2025

So your version is hardcoded to look in current dir ?

That wasn't actually intentional, I just threw it together very quickly and missed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment