mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2681] $JOHN pathsearch broken when --prefix option is used with configure #1735
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1735
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rofl0r on GitHub (Aug 17, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2681
using latest git, installing john's run dir into a custom location, and trying to run john from there without cd'ing there is quite broken.
scenario without john.conf in $HOME/.john
it fails with the message that fopen $JOHN/john.ini failed which is pretty misleading, since there's not even a john.ini in john's source dir. so first i wasted like 5 minutes trying to find john.ini.
since the error message suggests "$JOHN", i intuitively tried setting JOHN env variable.
setting JOHN environment variable to the right directory
didn't have any result, and solar explains in http://www.openwall.com/lists/john-users/2008/06/16/2 that john doesn't use any env vars.
then i copied john.conf to $HOME/.john
john.conf in $HOME/.john
so now it failed because best64.conf was not found, so i copied *.conf into $HOME/.john.
didn't help either, because the search for best64.conf doesn't even look there
so imo, there are several issues here:
dirname $(readlink -f $0)is never triedso i would suggest john doing the following instead
dirname $(readlink -f $0)(i.e. the directory where the john binary is in).so it works when started from inside the john run dir@solardiz commented on GitHub (Aug 17, 2017):
I didn't look into this yet - I'd like someone else to look into the jumbo-specific breakage. My guess is it's fairly recent and might have to do with changing the order of initialization function calls in
john.c, e.g. what magnum did on May 16.Regarding "v. . so it works when started from inside the john run dir": NAK, we must not access any non-user-specified files from the current directory, for security reasons. The "so it works when started from inside the john run dir" objective should be achieved through using the basename, which becomes
.or empty in a./johninvocation. This is how it used to work.Regarding other proposed changes, we may discuss those once the jumbo-specific breakage is fixed, so that any adjustments would be relative to the behavior intended so far.
@magnumripper commented on GitHub (Aug 17, 2017):
@rofl0r this is a system-wide build, right? And if so, exactly how did you configure/build it?
Also, please show the output of
john --list=build-info.@magnumripper commented on GitHub (Aug 17, 2017):
I'm marking this as invalid/PEBCAK until proven otherwise. So sue me 😉
@solardiz commented on GitHub (Aug 17, 2017):
magnum, you're right - most of this looks like PEBCAK to me. A system-wide build isn't supposed to look for the config file where the
johnbinary is located. I missed that at first. @rofl0r, why are you even making a system-wide build if you have such expectations from it? You should probably continue with default (non-system-wide) builds if you want them to read the config file wherejohnis.However, some of the behavior reported here does in fact look wrong to me: we shouldn't be literally accessing paths starting with
~/and$JOHN/. So labeling this entire issue PEBCAK feels wrong to me.@magnumripper commented on GitHub (Aug 17, 2017):
Jumbo, and nine years later, use environment variables for various things but the only thing that should affect this issue at all is it allows
$HOMEto override users' home directory (closing #1901).@magnumripper commented on GitHub (Aug 17, 2017):
It may be a bug, but I'm not calling it that until I know how it was configured and built. And what the
$HOMEenvironment was defined as, if defined at all.@rofl0r commented on GitHub (Aug 17, 2017):
this is not a system-wide build. i just ran ./configure and make
EDIT: actually i ran ./configure --prefix=/usr, but i doubt that should make a difference, and if it does that's a bug imo
@rofl0r commented on GitHub (Aug 17, 2017):
@rofl0r commented on GitHub (Aug 17, 2017):
i was using revision
d1daf24a41earlier and it exposed the same problem@ghost commented on GitHub (Aug 17, 2017):
You are using a system-wide build. The
--prefix=/usris the one to blame.@magnumripper commented on GitHub (Aug 17, 2017):
Oh, @claudioandre is right. IIRC there are certain properties of autoconf that we simply can't disable or turn off. The "best thing I could do" with
--prefix(well it seemed like a good idea at the time) was having it imply systemwide. Sorry for the inconvenience.Not quite sure how to handle this other than to warn about it and/or document better.
@magnumripper commented on GitHub (Aug 17, 2017):
--prefixis completely irrelevant for a normal (not systemwide) build, due to how legacy JtR is designed.@rofl0r commented on GitHub (Aug 17, 2017):
well tbh i don't really see a point in having this systemwide distinction anyway.
maybe it's time to get rid of it ?
it could just as well always behave as i outlined above, so it would work for anyone.
@magnumripper commented on GitHub (Aug 23, 2017):
I think you miss a few problems with your suggested scheme (such as how to implement it IRL in a portable way).
@rofl0r commented on GitHub (Aug 23, 2017):
how so ? i don't see anything unportable in my scheme.
i don't think you should close this issue without further discussion.
the distinction between systemwide and non-systemwide install seems completely arbitrary to me.
also there are several related issues i mentioned, that will just be forgotten when this stays closed (such as that $HOME/.john is only being seeked for john.conf, but not for best64.conf)
@magnumripper commented on GitHub (Aug 23, 2017):
Nothing stops us from discussing further.
What do you mean "compiled in $JOHN var"? I can't make any sense of that.
You suggest using
dirname $(readlink -f $0). Can you elaborate on that? JtR is written in C and must be portable. What you wrote looks more like shell code and isn't even portable at that.Specifically, if we drop the notion of SYSTEMWIDE, place
johnsomewhere in the path and run it from some arbitrary CWD, argv[0] is justjohnand the running process has no idea where that binary was actually located (so can't define $JOHN). Sure, you can find out under various OS's. But as far as I know there is no portable way to do it.@magnumripper commented on GitHub (Aug 24, 2017):
The reason.include <best64.conf>doesn't search$HOME/.johnis intended. (...)@magnumripper commented on GitHub (Aug 24, 2017):
Scrap what I just wrote. Here's the deal:
.include <best64.h>will only search$JOHNwhile.include "best64.h"would have also tried current directory.I agree that (given SYSTEMWIDE)
~/.johnshould have been searched though. I will look into that.@rofl0r commented on GitHub (Aug 24, 2017):
hi, with "compiled-in $JOHN var" i mean the value of $JOHN, which is hardcoded into the binary at compile-time. it corresponds to
JOHN_SYSTEMWIDE_HOMEin params.h.you are right,
dirname $(readlink -f $0)is a shell command. i used it to illustrate the intent, not the exact code, since it's a bit more elaborate in C.what it boils down to is that one uses the standard POSIX function
readlink()(man 3p readlink) on argv[0] and then extracts the parts before the last slash to retrieve the directory name where the john binary resides. even if there are exotic systems that don't have readlink(), now that you have a configure script it's trivial to make a compile check to see if it can be used. if not, its usage can just be omitted.@rofl0r commented on GitHub (Aug 24, 2017):
interesting, i didn't realize that there are 2 different ways to use
.include. since the default john.conf assumes the files it includes to be in the same directory, would it make sense to use.include "xxx"instead of.include <xxx>directly in john.conf ?@magnumripper commented on GitHub (Aug 24, 2017):
This is how a "systemwide" build works. You wanted us to ditch that idea.
This is how a "non-systemwide" build works. This is hard to combine with the above. Again, the problem is that if you go by
$PATHyou just typedjohnwith no path at all. Soargv[0]will be just that, there's no information to gain from**argvat all. There's no slash to look for.SYSTEMWIDE exists precisely because it's hard or "impossible" to combine the two approaches.
@magnumripper commented on GitHub (Aug 24, 2017):
It gets better, or worse. There's a third syntax
.include 'xxx'that works just like.include "xxx"except the former doesn't treat a missing file as an error. I had no idea until today when I looked at the code.I see no reason to do that change in this repo, but nothing stops you from doing so at your end.
@frank-dittrich commented on GitHub (Aug 24, 2017):
I think that code has been added when the mandatory john.local.conf has been dropped.
@magnumripper commented on GitHub (Aug 24, 2017):
As far as I can see, everything works as intended: After john.conf was found, the others (sourced with
.include <...>) are assumed to be located in the same place. We can discuss changing intentions but that'd be an aother issue.@rofl0r commented on GitHub (Aug 24, 2017):
not exactly. i wanted to ditch the gratuitous distinction between system-wide and non-system-wide.
it makes sense to always fall back to a system-wide dir (the current default for it is good), if the files cannot be found in either the users homedir or the current dir derived with my
readlink -femulation:it's neither impossible nor hard, it's just a matter of defining the search directory order.
@secf00tprint commented on GitHub (Jul 20, 2020):
Just some little help for those who have downloaded John the Ripper Jumbo (https://www.openwall.com/john/k/john-1.9.0-jumbo-1.tar.gz, 20.07.2020) from the homepage) as tar.gz.
There I had the same effect that it can't find john even if you build it with:
./configure; make -s clean && make -sj4.So my solution was (running Ubuntu 20.04):
Clone this repo here:
git clone https://github.com/magnumripper/JohnTheRipper.gitBuild it:
cd JohnTheRipper/src; ./configure; make -s clean && make -sj4Set a Path Variable (put this in your
~/.bashrcor~/.zshrcfile to make it permanent) with:absolute_path_to_john_the_ripper_jumbo_github_repoeg.
~/.bashrcor~/.zshrcfile) with:eg.
After that it should work in other directories too.
Further information to my environment:
@solardiz commented on GitHub (Jul 20, 2020):
Hi @secf00tprint. I appreciate you trying to help others, but your advice is partially wrong. We explicitly do not support invocation of non-systemwide builds via the
PATHenvironment variable, and we strongly recommend that it not be set. So step 3 in your instructions should be skipped.Step 4 is what helps (if the user insists on running
johnwhen not in therundirectory and not specifying a path to it), but it misses the finaljohnprogram name in the example, should be:Normally, people simply
cdto therundirectory and run./johnor alternatively they type a full or a relative path to there (e.g.~/john/run/john). I understand that it may be handy to also be able to use justjohnfrom anywhere, for whichaliashelps, butPATHdoes not.@secf00tprint commented on GitHub (Jul 21, 2020):
Yes, you're right I missed john at the end and corrected it.
Then you cannot use all the other binaries in the
runfolder (e.g.zip2john).For me to be enforced to go to the run folder was really confusing.
@solardiz commented on GitHub (Jul 21, 2020):
The problem is
johnand some of its other programs need to somehow find the rest of the files that they use, such asjohn.conf. Currently, for non-systemwide builds they extract the right directory pathname (maybe relative) from the invocation program name. When you use analias, that directory pathname is right in there. When you usePATH, it is not. So some programs fail when invoked viaPATH.For systemwide builds, the installation location gets hard-coded into the binaries, so they may be invoked via
PATHfine. However, this is currently only meant for use by distros' packages, not by end-users doing their own builds.@secf00tprint commented on GitHub (Jul 21, 2020):
Interesting. Thanks for the information. Is there a possibility to add free distro packages to https://www.openwall.com/john/ so it works out of the box?
@ghost commented on GitHub (Jul 21, 2020):
I also found the information interesting. I don't like using systemwyde builds, but (since) they are required, I can live with that.
@solardiz commented on GitHub (Jul 21, 2020):
Many distros include packages of
john, e.g. some are listed in https://linuxconfig.org/password-cracking-with-john-the-ripper-on-linux (maybe need to add this URL to the tutorials list on the wiki).I think we need to look into what exactly our
--prefixoption toconfiguredoes in jumbo. Ideally, it'd work the same it works with other typical software, where it can be used to install into e.g./home/user/appand setPATHto inside there, and things will work. That will also mean we'd finally need to addmake install.@solardiz commented on GitHub (Jul 21, 2020):
Claudio, I don't understand what you mean by systemwide builds being "required". Personally, I am comfortable using non-systemwide builds - I just don't expect them to work along with
PATH.Edit: created #4281 for adding proper "make install".