PDA

View Full Version : Zmap installation error



Gi0
2013-08-16, 20:20
Any idea how to install zmap (https://zmap.io/)?
I am getting this error while trying to install it


gcc -Wall -pedantic -Wextra -std=gnu99 -I../lib -I./ -Ioutput_modules -O2 -g -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1 -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wredundant-decls -Wno-unused-but-set-variable -Wnested-externs -Wbad-function-cast -Winit-self -Wmissing-field-initializers -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wno-format-nonliteral -Wno-format-y2k -Werror -c -o constraint.o ../lib/constraint.c
gcc -Wall -pedantic -Wextra -std=gnu99 -I../lib -I./ -Ioutput_modules -O2 -g -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1 -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wredundant-decls -Wno-unused-but-set-variable -Wnested-externs -Wbad-function-cast -Winit-self -Wmissing-field-initializers -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wno-format-nonliteral -Wno-format-y2k -Werror -c -o blacklist.o ../lib/blacklist.c
../lib/blacklist.c: In function 'blacklist_init_from_files':
../lib/blacklist.c:127:6: error: left shift count >= width of type [-Werror]
../lib/blacklist.c:127:27: error: division by zero [-Werror=div-by-zero]
cc1: all warnings being treated as errors
make: *** [blacklist.o] Error 1

I have installed all the prerequisites (libgmp3-dev libpcap-dev gengetopt) and i have tried the stable version (1.0.0) and the one from the github repository with the same results.
Any ideas?

Here's blacklist.c in case someone can figure it out


root@kali:~/Apps/zmap/lib# cat blacklist.c
/*
* Blacklist Copyright 2013 Regents of the University of Michigan
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

#include "blacklist.h"

#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "constraint.h"
#include "logger.h"

#define ADDR_DISALLOWED 0
#define ADDR_ALLOWED 1

static constraint_t *constraint = NULL;

// check whether a single IP address is allowed to be scanned.
// 1 => is allowed
// 0 => is not allowed
int blacklist_is_allowed(uint32_t s_addr) {
return constraint_lookup_ip(constraint, ntohl(s_addr)) == ADDR_ALLOWED;
}

// blacklist a CIDR network allocation
// e.g. blacklist_add("128.255.134.0", 24)
void blacklist_prefix(char *ip, int prefix_len)
{
assert(constraint);
constraint_set(constraint, ntohl(inet_addr(ip)), prefix_len, ADDR_DISALLOWED);
}

// whitelist a CIDR network allocation
void whitelist_prefix(char *ip, int prefix_len)
{
assert(constraint);
constraint_set(constraint, ntohl(inet_addr(ip)), prefix_len, ADDR_ALLOWED);
}

static int init(char *file, const char *name, int value)
{
FILE *fp;
char line[1000];

fp = fopen(file, "r");
if (fp == NULL) {
log_fatal(name, "Unable to open %s file: %s: %s", name, file, strerror(errno));
}

while (fgets(line, sizeof(line), fp) != NULL) {
char *comment = strchr(line, '#');
if (comment) {
*comment = '\0';
}
char ip[33];
if ((sscanf(line, "%32s", ip)) == EOF) {
continue;
}
int prefix_len = 32;
char *slash = strchr(ip, '/');
if (slash) { // split apart network and prefix length
*slash = '\0';
char *end;
char *len = slash+1;
errno = 0;
prefix_len = strtol(len, &end, 10);
if (end == len || errno != 0 || prefix_len < 0 || prefix_len > 32) {
log_fatal(name, "Unable to parse %s file: %s ('%s' is not a valid prefix length)", name, file, len);
}
}
struct in_addr addr;
if (inet_aton(ip, &addr) == 0) {
log_fatal(name, "Unable to parse %s file: %s ('%s' is not a valid IP address)", name, file, ip);
}
constraint_set(constraint, ntohl(addr.s_addr), prefix_len, value);
log_trace(name, "%sing %s/%i",
name, ip, prefix_len);
}
fclose(fp);

return 0;
}

uint64_t blacklist_count_allowed()
{
assert(constraint);
return constraint_count_ips(constraint, ADDR_ALLOWED);
}

uint64_t blacklist_count_not_allowed()
{
assert(constraint);
return constraint_count_ips(constraint, ADDR_DISALLOWED);
}


// Initialize address constraints from whitelist and blacklist files.
// Either can be set to NULL to omit.
int blacklist_init_from_files(char *whitelist_filename, char *blacklist_filename)
{
assert(!constraint);
if (whitelist_filename) {
// using a whitelist, so default to allowing nothing
constraint = constraint_init(ADDR_DISALLOWED);
log_trace("whitelist", "blacklisting 0.0.0.0/0");
init(whitelist_filename, "whitelist", ADDR_ALLOWED);
} else {
// no whitelist, so default to allowing everything
constraint = constraint_init(ADDR_ALLOWED);
}
if (blacklist_filename) {
init(blacklist_filename, "blacklist", ADDR_DISALLOWED);
}
constraint_optimize(constraint);
uint64_t allowed = blacklist_count_allowed();
log_debug("blacklist", "%lu addresses allowed to be scanned (%0.0f%% of address space)",
allowed, allowed*100./(1L << 32));
return 0;
}

Gi0
2013-08-17, 08:51
There was a push on its repository yesterday, a couple of hours after the previous post:
"ZMap only supports 64-bit systems" (https://github.com/zmap/zmap/commit/cad968212a4a07b4c684b814c6c9091db038c24a)
Problem solved i guess, since i was trying to install it on a 32bit system.

Gi0
2013-08-20, 07:46
Just an update: 32bit support (https://github.com/zmap/zmap/commit/779424fe2c7bd6bee525a1705fa878b965fb242c) and HD Moore participating in its development.