mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Revert r35895: unrelated changes were committed
This commit is contained in:
2
main.cc
2
main.cc
@@ -165,7 +165,7 @@ extern void set_program_name(const char *name);
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
/* The "real" main is nmap_main(). This function hijacks control at the
|
/* The "real" main is nmap_main(). This function hijacks control at the
|
||||||
beginning to do the following:
|
beginning to do the following:
|
||||||
1) Check the environment variable NMAP_ARGS.
|
3) Check the environment variable NMAP_ARGS.
|
||||||
2) Check if Nmap was called with --resume.
|
2) Check if Nmap was called with --resume.
|
||||||
3) Resume a previous scan or just call nmap_main.
|
3) Resume a previous scan or just call nmap_main.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3317,7 +3317,7 @@ match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) \.\n| p/OpenSSH/ v/$2/ i/protocol $
|
|||||||
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) PKIX\r\n| p/OpenSSH/ v/$2/ i/protocol $1; X.509 v3 certificate support/ cpe:/a:openbsd:openssh:$2/
|
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) PKIX\r\n| p/OpenSSH/ v/$2/ i/protocol $1; X.509 v3 certificate support/ cpe:/a:openbsd:openssh:$2/
|
||||||
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+)-FIPS\(capable\)\r\n| p/OpenSSH/ v/$2/ i/protocol $1; FIPS capable/ cpe:/a:openbsd:openssh:$2/
|
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+)-FIPS\(capable\)\r\n| p/OpenSSH/ v/$2/ i/protocol $1; FIPS capable/ cpe:/a:openbsd:openssh:$2/
|
||||||
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+)-sshjail\n| p/OpenSSH/ v/$2/ i/protocol $1; sshjail patch/ cpe:/a:openbsd:openssh:$2/
|
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+)-sshjail\n| p/OpenSSH/ v/$2/ i/protocol $1; sshjail patch/ cpe:/a:openbsd:openssh:$2/
|
||||||
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) Raspbian-(\d+)\r\n| p/OpenSSH/ v/$2 Raspbian $3/ i/protocol $1/ o/Linux/ cpe:/a:openbsd:openssh:$2/ cpe:/o:linux:linux_kernel/a
|
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) Raspbian-([^\r\n]+)\r\n| p/OpenSSH/ v/$2 Raspbian $3/ i/protocol $1/ o/Linux/ cpe:/a:openbsd:openssh:$2/ cpe:/o:linux:linux_kernel/a
|
||||||
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) OVH-rescue\r\n| p/OpenSSH/ v/$2/ i/protocol $1; OVH hosting rescue/ cpe:/a:openbsd:openssh:$2/a
|
match ssh m|^SSH-([\d.]+)-OpenSSH_([\w._-]+) OVH-rescue\r\n| p/OpenSSH/ v/$2/ i/protocol $1; OVH hosting rescue/ cpe:/a:openbsd:openssh:$2/a
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,10 +143,6 @@
|
|||||||
#define DLI_ERROR VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND)
|
#define DLI_ERROR VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PCAP_DRIVER_NONE 0
|
|
||||||
#define PCAP_DRIVER_WINPCAP 1
|
|
||||||
#define PCAP_DRIVER_NPCAP 2
|
|
||||||
|
|
||||||
extern NpingOps o;
|
extern NpingOps o;
|
||||||
|
|
||||||
/* internal functions */
|
/* internal functions */
|
||||||
@@ -167,15 +163,14 @@ void win_pre_init() {
|
|||||||
fatal("failed to start winsock.\n");
|
fatal("failed to start winsock.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the NPCAP service is running on Windows, and try to start it if it's
|
/* Check if the NPF service is running on Windows, and try to start it if it's
|
||||||
not. Return true if it was running or we were able to start it, false
|
not. Return true if it was running or we were able to start it, false
|
||||||
otherwise. */
|
otherwise. */
|
||||||
static bool start_service(const char *svcname) {
|
static bool start_npf() {
|
||||||
SC_HANDLE scm, npf;
|
SC_HANDLE scm, npf;
|
||||||
SERVICE_STATUS service;
|
SERVICE_STATUS service;
|
||||||
bool npf_running;
|
bool npf_running;
|
||||||
int ret;
|
int ret;
|
||||||
char startsvc[32];
|
|
||||||
|
|
||||||
scm = NULL;
|
scm = NULL;
|
||||||
npf = NULL;
|
npf = NULL;
|
||||||
@@ -185,7 +180,7 @@ static bool start_service(const char *svcname) {
|
|||||||
error("Error in OpenSCManager");
|
error("Error in OpenSCManager");
|
||||||
goto quit_error;
|
goto quit_error;
|
||||||
}
|
}
|
||||||
npf = OpenService(scm, svcname, SC_MANAGER_CONNECT | SERVICE_QUERY_STATUS);
|
npf = OpenService(scm, "npf", SC_MANAGER_CONNECT | SERVICE_QUERY_STATUS);
|
||||||
if (npf == NULL) {
|
if (npf == NULL) {
|
||||||
error("Error in OpenService");
|
error("Error in OpenService");
|
||||||
goto quit_error;
|
goto quit_error;
|
||||||
@@ -200,20 +195,19 @@ static bool start_service(const char *svcname) {
|
|||||||
|
|
||||||
if (npf_running) {
|
if (npf_running) {
|
||||||
if (o.getDebugging() > DBG_1)
|
if (o.getDebugging() > DBG_1)
|
||||||
printf("%s service is already running.\n", svcname);
|
printf("NPF service is already running.\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Service is not running. Try to start it. */
|
/* NPF is not running. Try to start it. */
|
||||||
|
|
||||||
if (o.getDebugging() > DBG_1)
|
if (o.getDebugging() > DBG_1)
|
||||||
printf("%s service is already running.\n", svcname);
|
printf("NPF service is not running.\n");
|
||||||
|
|
||||||
Snprintf(startsvc, 32, "start %s", svcname);
|
ret = (int) ShellExecute(0, "runas", "net.exe", "start npf", 0, SW_HIDE);
|
||||||
ret = (int) ShellExecute(0, "runas", "net.exe", startsvc, 0, SW_HIDE);
|
|
||||||
if (ret <= 32) {
|
if (ret <= 32) {
|
||||||
error("Unable to start %s service: ShellExecute returned %d.\n\
|
error("Unable to start NPF service: ShellExecute returned %d.\n\
|
||||||
Resorting to unprivileged (non-administrator) mode.", svcname, ret);
|
Resorting to unprivileged (non-administrator) mode.", ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,27 +246,6 @@ static void init_dll_path()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we find the Npcap driver, allow Nmap to load Npcap DLLs from the "\System32\Npcap" directory. */
|
|
||||||
static void init_npcap_dll_path()
|
|
||||||
{
|
|
||||||
BOOL(WINAPI *SetDllDirectory)(LPCTSTR);
|
|
||||||
char sysdir_name[512];
|
|
||||||
int len;
|
|
||||||
|
|
||||||
SetDllDirectory = (BOOL(WINAPI *)(LPCTSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA");
|
|
||||||
if (SetDllDirectory == NULL) {
|
|
||||||
pfatal("Error in SetDllDirectory");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
len = GetSystemDirectory(sysdir_name, 480); // be safe
|
|
||||||
if (!len)
|
|
||||||
pfatal("Error in GetSystemDirectory (%d)", GetLastError());
|
|
||||||
strcat(sysdir_name, "\\Npcap");
|
|
||||||
if (SetDllDirectory(sysdir_name) == 0)
|
|
||||||
pfatal("Error in SetDllDirectory(\"System32\\Npcap\")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Requires that win_pre_init() has already been called, also that
|
/* Requires that win_pre_init() has already been called, also that
|
||||||
options processing has been done so that o.debugging is
|
options processing has been done so that o.debugging is
|
||||||
available */
|
available */
|
||||||
@@ -285,7 +258,6 @@ void win_init()
|
|||||||
PMIB_IPADDRTABLE pIp = 0;
|
PMIB_IPADDRTABLE pIp = 0;
|
||||||
int i;
|
int i;
|
||||||
int numipsleft;
|
int numipsleft;
|
||||||
int pcap_driver;
|
|
||||||
|
|
||||||
init_dll_path();
|
init_dll_path();
|
||||||
|
|
||||||
@@ -311,17 +283,6 @@ void win_init()
|
|||||||
ULONG len = sizeof(pcaplist);
|
ULONG len = sizeof(pcaplist);
|
||||||
|
|
||||||
if(o.getDebugging() >= DBG_2) printf("Trying to initialize WinPcap\n");
|
if(o.getDebugging() >= DBG_2) printf("Trying to initialize WinPcap\n");
|
||||||
|
|
||||||
if (start_service("npcap"))
|
|
||||||
pcap_driver = PCAP_DRIVER_NPCAP;
|
|
||||||
else if (start_service("npf"))
|
|
||||||
pcap_driver = PCAP_DRIVER_WINPCAP;
|
|
||||||
else
|
|
||||||
pcap_driver = PCAP_DRIVER_NONE;
|
|
||||||
|
|
||||||
if (pcap_driver == PCAP_DRIVER_NPCAP)
|
|
||||||
init_npcap_dll_path();
|
|
||||||
|
|
||||||
pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
pcapMutex = CreateMutex(NULL, 0, "Global\\DnetPcapHangAvoidanceMutex");
|
||||||
wait = WaitForSingleObject(pcapMutex, INFINITE);
|
wait = WaitForSingleObject(pcapMutex, INFINITE);
|
||||||
PacketGetAdapterNames(pcaplist, &len);
|
PacketGetAdapterNames(pcaplist, &len);
|
||||||
@@ -344,7 +305,7 @@ void win_init()
|
|||||||
--unprivileged. In that case don't bother them with a
|
--unprivileged. In that case don't bother them with a
|
||||||
potential UAC dialog when starting NPF. */
|
potential UAC dialog when starting NPF. */
|
||||||
if (o.isRoot())
|
if (o.isRoot())
|
||||||
o.setHavePcap(o.havePcap() && ((bool) pcap_driver));
|
o.setHavePcap(o.havePcap() && start_npf());
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
__except (1) {
|
__except (1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user