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

getJavaData results in "InvalidPathException: Illegal char <:> at index 2" #6742

Closed
NancyAurum opened this issue Jul 21, 2024 · 3 comments
Closed
Labels
Reason: Out of scope This is outside the scope of the Ghidra project

Comments

@NancyAurum
Copy link

Describe the bug

Error running script: Cantordust.java
java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/nangl/d/code/test/sdlstasy.exe
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at resources.GhidraSrc.getJavaData(GhidraSrc.java:121)
at resources.GhidraSrc.getData(GhidraSrc.java:78)
at Cantordust.run(Cantordust.java:36)
at ghidra.app.script.GhidraScript.executeNormal(GhidraScript.java:405)
at ghidra.app.script.GhidraScript.doExecute(GhidraScript.java:260)
at ghidra.app.script.GhidraScript.execute(GhidraScript.java:238)
at ghidra.app.plugin.core.script.RunScriptTask.run(RunScriptTask.java:47)
at ghidra.util.task.Task.monitoredRun(Task.java:134)
at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

To Reproduce
Steps to reproduce the behavior:

  1. Analyze the attached exe with the default settings
  2. Open Script Manager, click Manage Script Directories button.
  3. Add the folder containing Cantordust.java, in the repository checked out from https://github.com/Battelle/cantordust
  4. Run Cantordust.java from the Script Manager

Expected behavior
Ghidra handles Windows pathes properly

Attachments
sdlstasy.zip

Environment (please complete the following information):

Additional context
The exception doesn't appear to be related to Cantordust, but to the Ghidra prefixing the Windows path with '/'.

@mumbel
Copy link
Contributor

mumbel commented Jul 21, 2024

did you file this with cantordust first?

nvmd,. Battelle/cantordust#14

"windows 11" != "windows 10" is probably the issue

@dev747368
Copy link
Collaborator

dev747368 commented Jul 22, 2024

As a general java programming issue, I've found that creating Path objects from random strings is something that needs to be done carefully, because of the exception you are running into.

Rather than checking the OS name, doing something like new File(randomstring).toPath() is a bit safer and File gives you some automatic fixing of those java-fied strings with the leading '/'.

The location that is causing the problem seems to be resources.GhidraSrc, which is a Cantordust file, not a Ghidra file.

@NancyAurum
Copy link
Author

As a general java programming issue, I've found that creating Path objects from random strings is something that needs to be done carefully, because of the exception you are running into.

Rather than checking the OS name, doing something like new File(randomstring).toPath() is a bit safer and File gives you some automatic fixing of those java-fied strings with the leading '/'.

The location that is causing the problem seems to be resources.GhidraSrc, which is a Cantordust file, not a Ghidra file.

Yeah. System.getProperty("os.name").equals("Windows 10") looks really crufty. Wonder what happens on Windows 7.

@ryanmkurtz ryanmkurtz added the Reason: Out of scope This is outside the scope of the Ghidra project label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason: Out of scope This is outside the scope of the Ghidra project
Projects
None yet
Development

No branches or pull requests

4 participants