merging in master

This commit is contained in:
Zakir Durumeric 2013-08-29 15:03:23 -04:00
commit 161ba170d9
18 changed files with 64 additions and 55 deletions

View File

@ -1,7 +1,7 @@
#include <stdint.h> #include <stdint.h>
#ifndef _BLACKLIST_H #ifndef BLACKLIST_H
#define _BLACKLIST_H #define BLACKLIST_H
int blacklist_is_allowed(uint32_t s_addr); int blacklist_is_allowed(uint32_t s_addr);
void blacklist_prefix(char *ip, int prefix_len); void blacklist_prefix(char *ip, int prefix_len);

View File

@ -1,5 +1,5 @@
#ifndef _CONSTRAINT_H #ifndef CONSTRAINT_H
#define _CONSTRAINT_H #define CONSTRAINT_H
typedef struct _constraint constraint_t; typedef struct _constraint constraint_t;
typedef int value_t; typedef int value_t;

View File

@ -1,8 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#ifndef _LOGGER_H #ifndef LOGGER_H
#define _LOGGER_H #define LOGGER_H
enum LogLevel { LOG_FATAL, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE, enum LogLevel { LOG_FATAL, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE,
NUM_LOGLEVELS }; NUM_LOGLEVELS };

View File

@ -1,8 +1,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#ifndef _RANDOM_H #ifndef RANDOM_H
#define _RANDOM_H #define RANDOM_H
int random_bytes(void *dst, size_t n); int random_bytes(void *dst, size_t n);

View File

@ -2,8 +2,8 @@
#include <unistd.h> #include <unistd.h>
#include <hiredis/hiredis.h> #include <hiredis/hiredis.h>
#ifndef _REDIS_ZHELPERS_H #ifndef REDIS_ZHELPERS_H
#define _REDIS_ZHELPERS_H #define REDIS_ZHELPERS_H
int redis_init(void); int redis_init(void);

View File

@ -23,8 +23,8 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __RIJNDAEL_ALG_FST_H #ifndef RIJNDAEL_ALG_FST_H
#define __RIJNDAEL_ALG_FST_H #define RIJNDAEL_ALG_FST_H
#define MAXKC (256/32) #define MAXKC (256/32)
#define MAXKB (256/8) #define MAXKB (256/8)
@ -44,4 +44,4 @@ void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], in
void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds);
#endif /* INTERMEDIATE_VALUE_KAT */ #endif /* INTERMEDIATE_VALUE_KAT */
#endif /* __RIJNDAEL_ALG_FST_H */ #endif /* RIJNDAEL_ALG_FST_H */

View File

@ -1,5 +1,5 @@
CFLAGS+=-Wall -pedantic -Wextra -std=gnu99 -I../lib -I./ -Ioutput_modules -O2 -g INCLUDE+=-I../lib -I./ -Ioutput_modules
LDFLAGS+=-g -pthread LDFLAGS+=-pthread
LDLIBS+=-lpcap -lgmp -lm LDLIBS+=-lpcap -lgmp -lm
TARGETS=zmap TARGETS=zmap
VPATH=../lib:output_modules:probe_modules VPATH=../lib:output_modules:probe_modules
@ -7,38 +7,37 @@ PREFIX=/usr/local
INSTALL=install INSTALL=install
INSTALLDATA=install -m 644 INSTALLDATA=install -m 644
mandir=/usr/share/man/man1/ mandir=$(PREFIX)/man/man1/
bindir=$(PREFIX)/sbin bindir=$(PREFIX)/sbin
# Hardening and warnings for building with gcc # Hardening and warnings for building with gcc
# Maybe add -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations # Maybe add -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
#-Wold-style-definition -Wswitch-enum GCCWARNINGS = -Wall -Wformat=2 -Wno-format-nonliteral\
GCCWARNINGS = -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \ -pedantic -fno-strict-aliasing \
-Wpointer-arith \ -Wextra \
-Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \ -Wfloat-equal -Wundef -Wwrite-strings -Wredundant-decls \
-Wformat=2 -Wwrite-strings -Wredundant-decls -Wno-unused-but-set-variable \
-Wnested-externs -Wbad-function-cast -Winit-self \ -Wnested-externs -Wbad-function-cast -Winit-self \
-Wmissing-field-initializers \ -Wmissing-noreturn -Wnormalized=id \
-Waddress -Wmissing-noreturn -Wnormalized=id \ -Wstack-protector
-Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds \
-Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wno-format-nonliteral -Wno-format-y2k GCCHARDENING=-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1
GCCHARDENING=-D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1
LDHARDENING=-z relro -z now LDHARDENING=-z relro -z now
EXTRACFLAGS=-g -O2 $(EXTRA_CFLAGS) $(GCCHARDENING) $(GCCWARNINGS) -Werror EXTRACFLAGS=-std=gnu99 -g -O2 $(GCCHARDENING) $(GCCWARNINGS) $(EXTRA_CFLAGS) -Werror
EXTRALDFLAGS= $(LDHARDENING) EXTRALDFLAGS= $(LDHARDENING)
CFLAGS+=-Wall $(INCLUDE) $(EXTRACFLAGS) CFLAGS+=$(INCLUDE) $(EXTRACFLAGS)
LDFLAGS+=$(EXTRALDFLAGS) LDFLAGS+=$(EXTRALDFLAGS)
probemodules=module_tcp_synscan.o module_icmp_echo.o #module_udp.o #ADD YOUR PROBE MODULE HERE probemodules=module_tcp_synscan.o module_icmp_echo.o #module_udp.o #ADD YOUR PROBE MODULE HERE
outputmodules= module_csv.o #module_simple_file.o module_extended_file.o module_csv.o #ADD YOUR OUTPUT MODULE HERE outputmodules= module_csv.o #ADD YOUR OUTPUT MODULE HERE
objects=constraint.o blacklist.o cyclic.o logger.o send.o recv.o state.o monitor.o zopt.o zmap.o random.o output_modules.o packet.o probe_modules.o ${probemodules} ${outputmodules} validate.o rijndael-alg-fst.o get_gateway.o aesrand.o fieldset.o objects=constraint.o blacklist.o cyclic.o logger.o send.o recv.o state.o monitor.o zopt_compat.o zmap.o random.o output_modules.o packet.o probe_modules.o ${probemodules} ${outputmodules} validate.o rijndael-alg-fst.o get_gateway.o aesrand.o fieldset.o
redis_objects=module_redis.o redis.o
ifeq ($(REDIS), true) ifeq ($(REDIS), true)
LDLIBS+=-lhiredis LDLIBS+=-lhiredis
objects+=module_redis.o redis.o objects+=$(redis_objects)
CFLAGS+=-DREDIS CFLAGS+=-DREDIS
endif endif
@ -49,17 +48,20 @@ $(TARGETS):
zmap: $(objects) zmap: $(objects)
zopt_compat.o: zopt.c
zopt.c zopt.h: zopt.ggo zopt.c zopt.h: zopt.ggo
gengetopt -C --no-help --no-version -i $^ -F $* gengetopt -C --no-help --no-version -i $^ -F $*
install: zmap install: zmap
$(INSTALL) zmap $(bindir)/zmap $(INSTALL) zmap $(bindir)/zmap
test -d /etc/zmap || (mkdir /etc/zmap && $(INSTALLDATA) ../conf/* /etc/zmap/) test -d /etc/zmap || (mkdir /etc/zmap && $(INSTALLDATA) ../conf/* /etc/zmap/)
test -d $(mandir) || mkdir -p $(mandir)
$(INSTALLDATA) ./zmap.1 $(mandir) $(INSTALLDATA) ./zmap.1 $(mandir)
echo "\n\n\n\n**************\nSuccess! ZMap is installed. Try running (as root):\nzmap -p 80 -N 10 -B 1M -o -\n**************" @echo "\n**************\nSuccess! ZMap is installed. Try running (as root):\nzmap -p 80 -N 10 -B 1M -o -\n**************"
clean: clean:
-rm -f $(objects) $(TARGETS) -rm -f $(objects) $(redis_objects) $(TARGETS)
.PHONY: install clean .PHONY: install clean

View File

@ -8,8 +8,8 @@
#include <stdint.h> #include <stdint.h>
#ifndef _AESRAND_H #ifndef AESRAND_H
#define _AESRAND_H #define AESRAND_H
void aesrand_init(uint32_t seed); void aesrand_init(uint32_t seed);

View File

@ -8,8 +8,8 @@
#include <stdint.h> #include <stdint.h>
#ifndef _CYCLIC_H #ifndef CYCLIC_H
#define _CYCLIC_H #define CYCLIC_H
int cyclic_init(uint32_t, uint32_t); int cyclic_init(uint32_t, uint32_t);

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef _GET_GATEWAY_H #ifndef GET_GATEWAY_H
#define _GET_GATEWAY_H #define GET_GATEWAY_H
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef _MONITOR_H #ifndef MONITOR_H
#define _MONITOR_H #define MONITOR_H
void monitor_run(); void monitor_run();

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef HEADER_OUTPUT_MODULES_H #ifndef OUTPUT_MODULES_H
#define HEADER_OUTPUT_MODULES_H #define OUTPUT_MODULES_H
#include "../state.h" #include "../state.h"
#include "../fieldset.h" #include "../fieldset.h"

View File

@ -6,8 +6,8 @@
#include <netinet/ip_icmp.h> #include <netinet/ip_icmp.h>
#include <netinet/udp.h> #include <netinet/udp.h>
#ifndef HEADER_ZMAP_PACKET_H #ifndef PACKET_H
#define HEADER_ZMAP_PACKET_H #define PACKET_H
#define MAX_PACKET_SIZE 4096 #define MAX_PACKET_SIZE 4096

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef _RECV_H #ifndef RECV_H
#define _RECV_H #define RECV_H
int recv_update_pcap_stats(void); int recv_update_pcap_stats(void);
int recv_run(pthread_mutex_t *recv_ready_mutex); int recv_run(pthread_mutex_t *recv_ready_mutex);

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef _SEND_H #ifndef SEND_H
#define _SEND_H #define SEND_H
int send_init(void); int send_init(void);
int send_run(void); int send_run(void);

View File

@ -16,8 +16,8 @@
#include "types.h" #include "types.h"
#include "fieldset.h" #include "fieldset.h"
#ifndef _STATE_H #ifndef STATE_H
#define _STATE_H #define STATE_H
#define MAX_PACKET_SIZE 4096 #define MAX_PACKET_SIZE 4096

View File

@ -6,8 +6,8 @@
* of the License at http://www.apache.org/licenses/LICENSE-2.0 * of the License at http://www.apache.org/licenses/LICENSE-2.0
*/ */
#ifndef _VALIDATE_H #ifndef VALIDATE_H
#define _VALIDATE_H #define VALIDATE_H
#define VALIDATE_BYTES 16 #define VALIDATE_BYTES 16

7
src/zopt_compat.c Normal file
View File

@ -0,0 +1,7 @@
#if __GNUC__ < 4
#error "gcc version >= 4 is required"
#elif __GNUC_MINOR__ >= 6
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#include "zopt.c"