Merge pull request #19023 from lazka/port-scanner-reloc
port-scanner: port to single_path_relocation
This commit is contained in:
@@ -4,7 +4,7 @@ _realname=port-scanner
|
||||
pkgbase=mingw-w64-${_realname}
|
||||
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
|
||||
pkgver=1.3
|
||||
pkgrel=7
|
||||
pkgrel=8
|
||||
pkgdesc="A multi threaded TCP port scanner from SecPoint.com (mingw-w64)"
|
||||
arch=('any')
|
||||
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
|
||||
@@ -19,7 +19,7 @@ source=("https://www.secpoint.com/freetools/threaded-port-scanner-${pkgver}.zip"
|
||||
sha256sums=('768c595fba7ba7e81da35e1bba1118bf08a1d689c6e419804d2109fc64177436'
|
||||
'ebf471173f5ee9c4416c10a78760cea8afaf1a4a6e653977321e8547ce7bf3c0'
|
||||
'1585ef1b61cf53a2ca27049c11d49e0834683dfda798f03547761375df482a90'
|
||||
'e27fad5161752247259e271c30aa49ea7eb18fd9f9b4f92553332c5cbb031db8'
|
||||
'7984cc958e87a519e3aa18a5bdd3e53f91e36f3b2aaed2e44acc6192272528e7'
|
||||
'66c18874119a4c36116f579f13b97aab538db399be61001f105a56ea1daeb03b')
|
||||
|
||||
# Helper macros to help make tasks easier #
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
diff -Naur orig/main.c threaded-port-scanner-1.3/main.c
|
||||
--- orig/main.c 2011-03-21 16:22:38.000000000 +0100
|
||||
+++ threaded-port-scanner-1.3/main.c 2015-03-15 21:38:18.996312400 +0100
|
||||
--- threaded-port-scanner-1.3/main.c.orig 2011-03-21 16:22:38.000000000 +0100
|
||||
+++ threaded-port-scanner-1.3/main.c 2023-11-05 23:34:08.561231500 +0100
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
@@ -10,39 +9,37 @@ diff -Naur orig/main.c threaded-port-scanner-1.3/main.c
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/times.h>
|
||||
@@ -29,11 +31,19 @@
|
||||
@@ -29,11 +31,15 @@
|
||||
|
||||
extern long int bestPortsArray[];
|
||||
|
||||
+#define BINDIR "/mingw$$/bin"
|
||||
+#define DATADIR "/mingw$$/share/port-scanner"
|
||||
+static char exe_path[PATH_MAX],
|
||||
+ data_path[PATH_MAX],
|
||||
+ arp_path[PATH_MAX],
|
||||
+ oui_path[PATH_MAX],
|
||||
+ ports_path[PATH_MAX];
|
||||
+#define OUI_FILENAME "/mingw$$/share/port-scanner/oui.txt"
|
||||
+#define PORT_RES_FILENAME "/mingw$$/share/port-scanner/port-numbers.txt"
|
||||
+
|
||||
+static char arp_path[PATH_MAX];
|
||||
+
|
||||
#define SLEEP_TIME_MSEC 5
|
||||
#define MAX_PORT_STANDARD 1024
|
||||
-#define ARP_TABLE_FILENAME "./arp_table.txt"
|
||||
-#define OUI_FILENAME "./oui.txt"
|
||||
-#define PORT_RES_FILENAME "./port-numbers.txt"
|
||||
+#define ARP_TABLE_FILENAME "arpdump"
|
||||
+#define OUI_FILENAME "oui.txt"
|
||||
+#define PORT_RES_FILENAME "port-numbers.txt"
|
||||
+#define ARP_TABLE_FILENAME "arp_table.txt"
|
||||
|
||||
#define OPTIONS_ALL_PORTS 0x00000001
|
||||
#define OPTIONS_RESOLVE_PORTS 0x00000002
|
||||
@@ -505,7 +515,7 @@
|
||||
@@ -505,7 +511,9 @@
|
||||
void resolve_MAC(char *mac)
|
||||
{
|
||||
int i;
|
||||
- char *p, *b = read_file(OUI_FILENAME);
|
||||
+ char *oui_path = single_path_relocation(BINDIR, OUI_FILENAME);
|
||||
+ char *p, *b = read_file(oui_path);
|
||||
+ free(oui_path);
|
||||
mac[8] = 0;
|
||||
for (i = 0; i < 8; i++) if (mac[i] >= 'a' && mac[i] <= 'f') mac[i] &= 0xDF;
|
||||
p = strstr(b, mac);
|
||||
@@ -530,13 +540,13 @@
|
||||
@@ -530,13 +538,13 @@
|
||||
strcpy(ips, net_get_aip(IP));
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -58,7 +55,7 @@ diff -Naur orig/main.c threaded-port-scanner-1.3/main.c
|
||||
#ifdef WIN32
|
||||
p = strstr(b, ips);
|
||||
#else
|
||||
@@ -564,11 +574,7 @@
|
||||
@@ -564,11 +572,7 @@
|
||||
}
|
||||
free(b);
|
||||
|
||||
@@ -71,27 +68,11 @@ diff -Naur orig/main.c threaded-port-scanner-1.3/main.c
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -583,9 +589,31 @@
|
||||
@@ -583,9 +587,17 @@
|
||||
|
||||
parse_arguments(argc, argv);
|
||||
|
||||
+ { // paths
|
||||
+ get_executable_path(argv[0], exe_path, sizeof(exe_path) / sizeof(exe_path[0]));
|
||||
+ if (strrchr(exe_path, '/') != NULL)
|
||||
+ strrchr(exe_path, '/')[1] = '\0';
|
||||
+
|
||||
+ strcpy(data_path, exe_path);
|
||||
+ strcat(data_path, get_relative_path(BINDIR, DATADIR));
|
||||
+ simplify_path(data_path);
|
||||
+
|
||||
+ strcpy(ports_path, data_path);
|
||||
+ strcat(ports_path, "/");
|
||||
+ strcat(ports_path, PORT_RES_FILENAME);
|
||||
+
|
||||
+ strcpy(oui_path, data_path);
|
||||
+ strcat(oui_path, "/");
|
||||
+ strcat(oui_path, OUI_FILENAME);
|
||||
+
|
||||
+ {
|
||||
+ GetTempPath(PATH_MAX, arp_path);
|
||||
+ strcat(arp_path, ARP_TABLE_FILENAME);
|
||||
+ _itoa(_getpid(), &arp_path[strlen(arp_path)], 10);
|
||||
@@ -100,7 +81,9 @@ diff -Naur orig/main.c threaded-port-scanner-1.3/main.c
|
||||
print_config();
|
||||
|
||||
- if (options & OPTIONS_RESOLVE_PORTS) port_res_file = read_file(PORT_RES_FILENAME);
|
||||
+ char *ports_path = single_path_relocation(BINDIR, PORT_RES_FILENAME);
|
||||
+ if (options & OPTIONS_RESOLVE_PORTS) port_res_file = read_file(ports_path);
|
||||
+ free(ports_path);
|
||||
scanner();
|
||||
if (options & OPTIONS_RESOLVE_PORTS) free(port_res_file);
|
||||
if (options & OPTIONS_RESOLVE_MAC) print_MAC();
|
||||
|
||||
Reference in New Issue
Block a user