-
Notifications
You must be signed in to change notification settings - Fork 24
Fix recovery data finding on *nix #14
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
base: master
Are you sure you want to change the base?
Conversation
I think I'm running into this issue. |
@Tobiaqs any hints on how to build Nkit on nix with mono installed? |
@bcomnes https://gist.github.com/Tobiaqs/34420144ade5f20609bb628779b3430f |
public static string GetUpdatePartition(Settings settings, uint crc) | ||
{ | ||
Regex m = new Regex(@"\\([A-Z0-9]{40})_([A-Z]+)_" + crc.ToString("X8") + "$", RegexOptions.IgnoreCase); | ||
Regex m = new Regex(@"[/|\\]([A-Z0-9]{40})_([A-Z]+)_" + crc.ToString("X8") + "$", RegexOptions.IgnoreCase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be wiser to use the Path.DirectorySeparatorChar character provided by the IO library. This will make sure that the regex is platform agnostic. I do not have visual studio installed at the moment but I think the code would look something like this
Regex m = new Regex(@"[/|\\]([A-Z0-9]{40})_([A-Z]+)_" + crc.ToString("X8") + "$", RegexOptions.IgnoreCase); | |
Regex m = new Regex(Path.DirectorySeparatorChar+@"([A-Z0-9]{40})_([A-Z]+)_" + crc.ToString("X8") + "$", RegexOptions.IgnoreCase); |
Nonetheless, I am a bit skeptical on whether the Path.DirectorySeparatorChar would be properly parsed by the Regex builder if the Path.DirectorySeparatorChar is ""
We could propose a switch statement that properly builds the regexp.
The reason I want to avoid using [/|\] is because in extreme cases it could match wrongly
Ran in to this issue. I would like to see this added as well! |
Does this fix the crc always being 00000000? Might help #5 if so. |
I've been hitting a wall for the last hour while trying to use this tool, I had a feeling there was something wrong with the detection. This fix would be appreciated! |
FWIW, I was able to exploit the naive regex by renaming all the recovery files to include a backslash as the first character of their filename. After doing that, everything worked as expected. |
NKit does not properly find recovery data on *nix systems due to a Regex that only accepts Windows paths. This fixes that by accepting both types of slashes.
See #13 for more info.