-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aircrack-ng: backport patch and move package to pcre2
Backport patch merged upstream for PCRE2 support and move package to pcre2. Also add an additional patch pending to fix linking both pcre and pcre2 if autotools detect both library. (aircrack-ng prefer pcre2 in presence of both) Signed-off-by: Christian Marangi <[email protected]> (cherry picked from commit cb1f7c7)
- Loading branch information
1 parent
ddac502
commit ceee87b
Showing
13 changed files
with
1,095 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
net/aircrack-ng/patches/100-01-autotools-add-PCRE2-detection.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
From 6b05dc10cdcf45d50bc8f9dd74667a3ff399a059 Mon Sep 17 00:00:00 2001 | ||
From: Andras Gemes <[email protected]> | ||
Date: Fri, 20 Jan 2023 14:52:12 +0100 | ||
Subject: [PATCH 1/9] autotools: add PCRE2 detection | ||
|
||
--- | ||
build/m4/aircrack_ng_pcre2.m4 | 61 +++++++++++++++++++++++++++++++++++ | ||
configure.ac | 2 ++ | ||
2 files changed, 63 insertions(+) | ||
create mode 100644 build/m4/aircrack_ng_pcre2.m4 | ||
|
||
--- /dev/null | ||
+++ b/build/m4/aircrack_ng_pcre2.m4 | ||
@@ -0,0 +1,61 @@ | ||
+dnl Aircrack-ng | ||
+dnl | ||
+dnl Copyright (C) 2023 Andras Gemes <[email protected]> | ||
+dnl | ||
+dnl Autotool support was written by: Joseph Benden <[email protected]> | ||
+dnl | ||
+dnl This program is free software; you can redistribute it and/or modify | ||
+dnl it under the terms of the GNU General Public License as published by | ||
+dnl the Free Software Foundation; either version 2 of the License, or | ||
+dnl (at your option) any later version. | ||
+dnl | ||
+dnl This program is distributed in the hope that it will be useful, | ||
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+dnl GNU General Public License for more details. | ||
+dnl | ||
+dnl You should have received a copy of the GNU General Public License | ||
+dnl along with this program; if not, write to the Free Software | ||
+dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA | ||
+dnl | ||
+dnl In addition, as a special exception, the copyright holders give | ||
+dnl permission to link the code of portions of this program with the | ||
+dnl OpenSSL library under certain conditions as described in each | ||
+dnl individual source file, and distribute linked combinations | ||
+dnl including the two. | ||
+dnl | ||
+dnl You must obey the GNU General Public License in all respects | ||
+dnl for all of the code used other than OpenSSL. | ||
+dnl | ||
+dnl If you modify file(s) with this exception, you may extend this | ||
+dnl exception to your dnl version of the file(s), but you are not obligated | ||
+dnl to do so. | ||
+dnl | ||
+dnl If you dnl do not wish to do so, delete this exception statement from your | ||
+dnl version. | ||
+dnl | ||
+dnl If you delete this exception statement from all source files in the | ||
+dnl program, then also delete it here. | ||
+ | ||
+AC_DEFUN([AIRCRACK_NG_PCRE2], [ | ||
+AC_ARG_ENABLE(static-pcre2, | ||
+ AS_HELP_STRING([--enable-static-pcre2], | ||
+ [Enable statically linked PCRE2 libpcre2-8.]), | ||
+ [static_pcre2=$enableval], [static_pcre2=no]) | ||
+ | ||
+if test "x$static_pcre2" != "xno"; then | ||
+ AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) | ||
+ AX_EXT_HAVE_STATIC_LIB(PCRE2, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcre2 libpcre2-8, pcre2_version) | ||
+ if test "x$PCRE2_FOUND" = xyes; then | ||
+ HAVE_PCRE2=yes | ||
+ else | ||
+ HAVE_PCRE2=no | ||
+ fi | ||
+else | ||
+ PKG_CHECK_MODULES(PCRE2, libpcre2-8, HAVE_PCRE2=yes, HAVE_PCRE2=no) | ||
+fi | ||
+ | ||
+AS_IF([test "x$HAVE_PCRE2" = "xyes"], [ | ||
+ AC_DEFINE([HAVE_PCRE2], [1], [Define this if you have libpcre2-8 on your system]) | ||
+]) | ||
+]) | ||
\ No newline at end of file | ||
--- a/configure.ac | ||
+++ b/configure.ac | ||
@@ -144,6 +144,7 @@ AIRCRACK_NG_EXT_SCRIPTS | ||
AIRCRACK_NG_HWLOC | ||
AIRCRACK_NG_PCAP | ||
AIRCRACK_NG_PCRE | ||
+AIRCRACK_NG_PCRE2 | ||
AIRCRACK_NG_RFKILL | ||
AIRCRACK_NG_SQLITE | ||
AIRCRACK_NG_ZLIB | ||
@@ -320,6 +321,7 @@ ${PACKAGE} ${VERSION} | ||
Jemalloc: ${JEMALLOC} | ||
Pcap: ${PCAP_FOUND} | ||
Pcre: ${HAVE_PCRE} | ||
+ Pcre2: ${HAVE_PCRE2} | ||
Sqlite: ${HAVE_SQLITE3} | ||
Tcmalloc: ${TCMALLOC} | ||
Zlib: ${HAVE_ZLIB} |
142 changes: 142 additions & 0 deletions
142
net/aircrack-ng/patches/100-02-airodump-ng-add-PCRE2-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
From 37bc38a1749f61f3e54dbebca7b33df844b6de82 Mon Sep 17 00:00:00 2001 | ||
From: Andras Gemes <[email protected]> | ||
Date: Fri, 20 Jan 2023 14:53:59 +0100 | ||
Subject: [PATCH 2/9] airodump-ng: add PCRE2 support | ||
|
||
--- | ||
src/airodump-ng/airodump-ng.c | 75 +++++++++++++++++++++++++++++++---- | ||
1 file changed, 67 insertions(+), 8 deletions(-) | ||
|
||
--- a/src/airodump-ng/airodump-ng.c | ||
+++ b/src/airodump-ng/airodump-ng.c | ||
@@ -68,7 +68,10 @@ | ||
|
||
#include <sys/wait.h> | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+#define PCRE2_CODE_UNIT_WIDTH 8 | ||
+#include <pcre2.h> | ||
+#elif defined HAVE_PCRE | ||
#include <pcre.h> | ||
#endif | ||
|
||
@@ -150,7 +153,10 @@ static struct local_options | ||
unsigned char prev_bssid[6]; | ||
char ** f_essid; | ||
int f_essid_count; | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ pcre2_code * f_essid_regex; | ||
+ pcre2_match_data * f_essid_match_data; | ||
+#elif defined HAVE_PCRE | ||
pcre * f_essid_regex; | ||
#endif | ||
char * dump_prefix; | ||
@@ -784,7 +790,7 @@ static const char usage[] = | ||
" --netmask <netmask> : Filter APs by mask\n" | ||
" --bssid <bssid> : Filter APs by BSSID\n" | ||
" --essid <essid> : Filter APs by ESSID\n" | ||
-#ifdef HAVE_PCRE | ||
+#if defined HAVE_PCRE2 || defined HAVE_PCRE | ||
" --essid-regex <regex> : Filter APs by ESSID using a regular\n" | ||
" expression\n" | ||
#endif | ||
@@ -857,7 +863,22 @@ int is_filtered_essid(const uint8_t * es | ||
ret = 1; | ||
} | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (lopt.f_essid_regex) | ||
+ { | ||
+ lopt.f_essid_match_data | ||
+ = pcre2_match_data_create_from_pattern(lopt.f_essid_regex, NULL); | ||
+ | ||
+ return pcre2_match(lopt.f_essid_regex, | ||
+ (PCRE2_SPTR) essid, | ||
+ (int) strnlen((char *) essid, ESSID_LENGTH), | ||
+ 0, | ||
+ 0, | ||
+ lopt.f_essid_match_data, | ||
+ 0) | ||
+ < 0; | ||
+ } | ||
+#elif defined HAVE_PCRE | ||
if (lopt.f_essid_regex) | ||
{ | ||
return pcre_exec(lopt.f_essid_regex, | ||
@@ -5782,7 +5803,10 @@ int main(int argc, char * argv[]) | ||
int wi_read_failed = 0; | ||
int n = 0; | ||
int output_format_first_time = 1; | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ int pcreerror; | ||
+ PCRE2_SIZE pcreerroffset; | ||
+#elif defined HAVE_PCRE | ||
const char * pcreerror; | ||
int pcreerroffset; | ||
#endif | ||
@@ -5938,7 +5962,9 @@ int main(int argc, char * argv[]) | ||
#ifdef CONFIG_LIBNL | ||
lopt.htval = CHANNEL_NO_HT; | ||
#endif | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ lopt.f_essid_regex = NULL; | ||
+#elif defined HAVE_PCRE | ||
lopt.f_essid_regex = NULL; | ||
#endif | ||
|
||
@@ -6359,7 +6385,34 @@ int main(int argc, char * argv[]) | ||
|
||
case 'R': | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (lopt.f_essid_regex != NULL) | ||
+ { | ||
+ printf("Error: ESSID regular expression already given. " | ||
+ "Aborting\n"); | ||
+ exit(EXIT_FAILURE); | ||
+ } | ||
+ | ||
+ lopt.f_essid_regex = pcre2_compile((PCRE2_SPTR) optarg, | ||
+ PCRE2_ZERO_TERMINATED, | ||
+ 0, | ||
+ &pcreerror, | ||
+ &pcreerroffset, | ||
+ NULL); | ||
+ | ||
+ if (lopt.f_essid_regex == NULL) | ||
+ { | ||
+ PCRE2_UCHAR pcreerrbuffer[256]; | ||
+ pcre2_get_error_message( | ||
+ pcreerror, pcreerrbuffer, sizeof(pcreerrbuffer)); | ||
+ | ||
+ printf("Error: regular expression compilation failed at " | ||
+ "offset %lu: %s; aborting\n", | ||
+ pcreerroffset, | ||
+ pcreerrbuffer); | ||
+ exit(EXIT_FAILURE); | ||
+ } | ||
+#elif defined HAVE_PCRE | ||
if (lopt.f_essid_regex != NULL) | ||
{ | ||
printf("Error: ESSID regular expression already given. " | ||
@@ -7297,7 +7350,13 @@ int main(int argc, char * argv[]) | ||
|
||
if (lopt.keyout) free(lopt.keyout); | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (lopt.f_essid_regex) | ||
+ { | ||
+ pcre2_match_data_free(lopt.f_essid_match_data); | ||
+ pcre2_code_free(lopt.f_essid_regex); | ||
+ } | ||
+#elif defined HAVE_PCRE | ||
if (lopt.f_essid_regex) pcre_free(lopt.f_essid_regex); | ||
#endif | ||
|
146 changes: 146 additions & 0 deletions
146
net/aircrack-ng/patches/100-03-besside-ng-add-PCRE2-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
From dbc80d96cfba2dab959ab20bf76f8dd4f517bd29 Mon Sep 17 00:00:00 2001 | ||
From: Andras Gemes <[email protected]> | ||
Date: Fri, 20 Jan 2023 14:55:18 +0100 | ||
Subject: [PATCH 3/9] besside-ng: add PCRE2 support | ||
|
||
--- | ||
src/besside-ng/besside-ng.c | 86 ++++++++++++++++++++++++++++++++++--- | ||
1 file changed, 79 insertions(+), 7 deletions(-) | ||
|
||
--- a/src/besside-ng/besside-ng.c | ||
+++ b/src/besside-ng/besside-ng.c | ||
@@ -57,7 +57,10 @@ | ||
#include <unistd.h> | ||
#include <limits.h> | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+#define PCRE2_CODE_UNIT_WIDTH 8 | ||
+#include <pcre2.h> | ||
+#elif defined HAVE_PCRE | ||
#include <pcre.h> | ||
#endif | ||
|
||
@@ -155,7 +158,10 @@ static struct conf | ||
int cf_do_wep; | ||
int cf_do_wpa; | ||
char * cf_wpa_server; | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ pcre2_code * cf_essid_regex; | ||
+ pcre2_match_data * cf_essid_match_data; | ||
+#elif defined HAVE_PCRE | ||
pcre * cf_essid_regex; | ||
#endif | ||
} _conf; | ||
@@ -1116,7 +1122,31 @@ static void attack_ping(void * a) | ||
timer_in(100 * 1000, attack_ping, n); | ||
} | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+static int is_filtered_essid(char * essid) | ||
+{ | ||
+ REQUIRE(essid != NULL); | ||
+ | ||
+ int ret = 0; | ||
+ | ||
+ if (_conf.cf_essid_regex) | ||
+ { | ||
+ _conf.cf_essid_match_data | ||
+ = pcre2_match_data_create_from_pattern(_conf.cf_essid_regex, NULL); | ||
+ | ||
+ return pcre2_match(_conf.cf_essid_regex, | ||
+ (PCRE2_SPTR) essid, | ||
+ (int) strnlen((char *) essid, MAX_IE_ELEMENT_SIZE), | ||
+ 0, | ||
+ 0, | ||
+ _conf.cf_essid_match_data, | ||
+ 0) | ||
+ < 0; | ||
+ } | ||
+ | ||
+ return (ret); | ||
+} | ||
+#elif defined HAVE_PCRE | ||
static int is_filtered_essid(char * essid) | ||
{ | ||
REQUIRE(essid != NULL); | ||
@@ -1148,7 +1178,12 @@ static int should_attack(struct network | ||
if (_conf.cf_bssid && memcmp(_conf.cf_bssid, n->n_bssid, 6) != 0) | ||
return (0); | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (is_filtered_essid(n->n_ssid)) | ||
+ { | ||
+ return (0); | ||
+ } | ||
+#elif defined HAVE_PCRE | ||
if (is_filtered_essid(n->n_ssid)) | ||
{ | ||
return (0); | ||
@@ -3007,7 +3042,13 @@ static void cleanup(int UNUSED(x)) | ||
|
||
print_work(); | ||
|
||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (_conf.cf_essid_regex) | ||
+ { | ||
+ pcre2_match_data_free(_conf.cf_essid_match_data); | ||
+ pcre2_code_free(_conf.cf_essid_regex); | ||
+ } | ||
+#elif defined HAVE_PCRE | ||
if (_conf.cf_essid_regex) pcre_free(_conf.cf_essid_regex); | ||
#endif | ||
|
||
@@ -3295,7 +3336,10 @@ static void usage(char * prog) | ||
int main(int argc, char * argv[]) | ||
{ | ||
int ch, temp; | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ int pcreerror; | ||
+ PCRE2_SIZE pcreerroffset; | ||
+#elif defined HAVE_PCRE | ||
const char * pcreerror; | ||
int pcreerroffset; | ||
#endif | ||
@@ -3349,7 +3393,35 @@ int main(int argc, char * argv[]) | ||
break; | ||
|
||
case 'R': | ||
-#ifdef HAVE_PCRE | ||
+#ifdef HAVE_PCRE2 | ||
+ if (_conf.cf_essid_regex != NULL) | ||
+ { | ||
+ printf("Error: ESSID regular expression already given. " | ||
+ "Aborting\n"); | ||
+ exit(EXIT_FAILURE); | ||
+ } | ||
+ | ||
+ _conf.cf_essid_regex = pcre2_compile((PCRE2_SPTR) optarg, | ||
+ PCRE2_ZERO_TERMINATED, | ||
+ 0, | ||
+ &pcreerror, | ||
+ &pcreerroffset, | ||
+ NULL); | ||
+ | ||
+ if (_conf.cf_essid_regex == NULL) | ||
+ { | ||
+ PCRE2_UCHAR pcreerrbuffer[256]; | ||
+ pcre2_get_error_message( | ||
+ pcreerror, pcreerrbuffer, sizeof(pcreerrbuffer)); | ||
+ | ||
+ printf("Error: regular expression compilation failed at " | ||
+ "offset %lu: %s; aborting\n", | ||
+ pcreerroffset, | ||
+ pcreerrbuffer); | ||
+ exit(EXIT_FAILURE); | ||
+ } | ||
+ break; | ||
+#elif defined HAVE_PCRE | ||
if (_conf.cf_essid_regex != NULL) | ||
{ | ||
printf("Error: ESSID regular expression already given. " |
Oops, something went wrong.