Trying to build with rexgen enabled
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.6k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Latest rexgen doesn't even compile anymore (on Fedora 32), and it looks like https://github.com/janstarke/rexgen hasn't been maintained for almost 2 years.
To be able to compile latest rexgen, I applied this change:
diff --git a/src/librexgen/iterator/iterator.h b/src/librexgen/iterator/iterator.h
index 5b99c77..79925f2 100644
--- a/src/librexgen/iterator/iterator.h
+++ b/src/librexgen/iterator/iterator.h
@@ -29,6 +29,7 @@
#include <memory>
#ifdef __cplusplus
+#include <stdexcept>
namespace rexgen {
class IteratorState;
Apparently, applying https://github.com/janstarke/rexgen/pull/64 on top of https://github.com/janstarke/rexgen/commit/585e86da6a07a63ec7a871320b307457661d557c also helps.
$ rexgen -v
rexgen-2.1.3
The c_regex_cb_mb interface has been changed, and I had to make 2 warnings disappear.
diff --git a/src/regex.c b/src/regex.c
index cd7642a5d..bd9486167 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -44,8 +44,8 @@ char *stpcpy(char *dst, const char *src) {
#endif
char *rexgen_alphabets[256];
-static c_iterator_ptr iter = NULL;
-static c_regex_ptr regex_ptr = NULL;
+static c_iterator_ptr iter = 0;
+static c_regex_ptr regex_ptr = 0;
static char *save_str;
static const char *cur_regex, *save_regex;
static char *restore_str, *restore_regex;
@@ -184,6 +184,10 @@ void SetupAlpha(const char *regex_alpha)
}
}
+void parser_error(const char* msg) {
+ fprintf(stderr, "%s\n", msg);
+}
+
int do_regex_hybrid_crack(struct db_main *db, const char *regex,
const char *base_word, int regex_case,
const char *regex_alpha)
@@ -218,7 +222,7 @@ int do_regex_hybrid_crack(struct db_main *db, const char *regex,
rec_init_hybrid(save_state_hybrid);
crk_set_hybrid_fix_state_func_ptr(rex_hybrid_fix_state);
- regex_ptr = c_regex_cb_mb(regex, callback);
+ regex_ptr = c_regex_cb_mb(regex, callback, parser_error);
if (!regex_ptr) {
c_simplestring_delete(buffer);
fprintf(stderr,
@@ -333,7 +337,7 @@ void do_regex_crack(struct db_main *db, const char *regex)
crk_init(db, fix_state, NULL);
rec_init_hybrid(save_state_hybrid);
- regex_ptr = c_regex_cb_mb(regex, callback);
+ regex_ptr = c_regex_cb_mb(regex, callback, parser_error);
if (!regex_ptr) {
fprintf(stderr,
"Error, invalid regex expression. John exiting now\n");
The c_regex_cb_mb interface has been changed somewhere in the middle of either the 2.0.8 or 2.0.9 release. So we also might need to adjust these 2 lines, changing 0x020006 to 0x020103 (or may be 0x020009):
src/configure:13066:int main() { return ! (rexgen_version_int() >= 0x020006); }
src/configure.ac:662: [AC_MSG_CHECKING([librexgen minimum version])] && [AC_TRY_RUN([int main() { return ! (rexgen_version_int() >= 0x020006); }],
and doc/README.librexgen also still mentions
As of this writing the last known good version is 2.0.8 so you may want
to check that out.
Unfortunately, due to these /usr/local/include/librexgen/c/ApiContext.h lines
const c_regex_ptr c_regex_none = 0;
const c_iterator_ptr c_iterator_none = 0;
build fails like this:
/usr/bin/ld: inc.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: inc.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: john.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: john.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: options.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: options.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: recovery.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: recovery.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: wordlist.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: wordlist.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: mkv.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: mkv.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: listconf.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: listconf.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: regex.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: regex.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: pp.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: pp.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1450: ../run/john] Error 1
make[1]: Leaving directory '/home/fd/git/john/src'
make: *** [Makefile:190: default] Error 2
I have to give up now, did already spend more time on this than I intended to, and I don't know when I'll have time to continue.
Too bad that rexgen isn't maintained any longer. For certain tasks I loved to use john's --regex mode.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the rexgen-enabled build failure on Fedora 32, then inspect src/librexgen/iterator/iterator.h, src/regex.c, src/configure, src/configure.ac, doc/README.librexgen, and the installed c/ApiContext.h. Compare the rexgen 2.1.3 interface and duplicate symbol errors; done means John builds with rexgen enabled and its --regex mode works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100