mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
If you have trouble updating after this revision you need to follow these instructions. You have probably just seen an error like this: svn: URL 'svn://svn.insecure.org/nping' of existing directory 'nping' does not match expected URL 'svn://svn.insecure.org/nmap/nping' This is caused by the replacement of SVN externals. Here's what you need to do. First, save any local changes you might have in the nping, nsock, nbase, ncat, and zenmap directories. (For example by running "cd nping; svn diff > ../nping.diff".) If you don't have any local changes you can skip this step. Then run these commands: rm -rf nping/ nsock/ nbase/ ncat/ zenmap/ svn update svn cleanup If all else fails, you can just delete your whole working directory and check out anew: svn co --username guest --password "" svn://svn.insecure.org/nmap There may be further discussion in the mailing list thread at http://seclists.org/nmap-dev/2011/q4/303.
83 lines
2.0 KiB
C
83 lines
2.0 KiB
C
/*
|
|
Usage: ./addrset [<specification> ...]
|
|
|
|
This program tests the addrset functions in ncat_hostmatch.c, the
|
|
ones that maintain the lists of addresses for --allow and --deny. It
|
|
takes as arguments specifications that are added to an addrset. It
|
|
then reads whitespace-separated host names or IP addresses from
|
|
standard input and echoes only those that are in the addrset.
|
|
|
|
David Fifield
|
|
|
|
Example:
|
|
$ echo "1.2.3.4 1.0.0.5 1.2.3.8" | ./addrset "1.2.3.10/24"
|
|
1.2.3.4
|
|
1.2.3.8
|
|
*/
|
|
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "ncat_core.h"
|
|
|
|
static int resolve_name(const char *name, struct addrinfo **result)
|
|
{
|
|
struct addrinfo hints = { 0 };
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
*result = NULL;
|
|
|
|
return getaddrinfo(name, NULL, &hints, result);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct addrset set;
|
|
char line[1024];
|
|
int i;
|
|
|
|
addrset_init(&set);
|
|
|
|
options_init();
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
if (!addrset_add_spec(&set, argv[i], o.af, !o.nodns)) {
|
|
fprintf(stderr, "Error adding spec \"%s\".\n", argv[i]);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
while (fgets(line, sizeof(line), stdin) != NULL) {
|
|
char *s, *hostname;
|
|
struct addrinfo *addrs;
|
|
|
|
s = line;
|
|
while ((hostname = strtok(s, " \t\n")) != NULL) {
|
|
int rc;
|
|
|
|
s = NULL;
|
|
|
|
rc = resolve_name(hostname, &addrs);
|
|
if (rc != 0) {
|
|
fprintf(stderr, "Error resolving \"%s\": %s.\n", hostname, gai_strerror(rc));
|
|
continue;
|
|
}
|
|
if (addrs == NULL) {
|
|
fprintf(stderr, "No addresses found for \"%s\".\n", hostname);
|
|
continue;
|
|
}
|
|
|
|
/* Check just the first address returned. */
|
|
if (addrset_contains(&set, addrs->ai_addr))
|
|
printf("%s\n", hostname);
|
|
|
|
freeaddrinfo(addrs);
|
|
}
|
|
}
|
|
|
|
addrset_free(&set);
|
|
|
|
return 0;
|
|
}
|