From bc3e724a8142d8e5565013c653617b4ea569972a Mon Sep 17 00:00:00 2001 From: Gerard Wagener Date: Mon, 15 Jul 2019 15:05:04 +0200 Subject: [PATCH] add: [pibs] skeleton for creating bgp ranking lists --- bin/Makefile | 10 ++++++- bin/pibs-BGP-Ranking.c | 63 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 bin/pibs-BGP-Ranking.c diff --git a/bin/Makefile b/bin/Makefile index 24e00b7..5d40df7 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,4 +1,4 @@ -all: pibs pibs-stat +all: pibs pibs-stat pibs-BGP-Ranking pibs-stat: pibs-stat.o libpibs.o memutils.o synseen.o gcc -Wall -o pibs-stat pibs-stat.o libpibs.o memutils.o synseen.o -lwiretap `pkg-config --libs glib-2.0` -lpcap -lhiredis -ggdb @@ -7,6 +7,12 @@ pibs-stat: pibs-stat.o libpibs.o memutils.o synseen.o pibs-stat.o: pibs-stat.c gcc -D HASHDEBUG=0 -Wall -c pibs-stat.c `pkg-config --cflags glib-2.0` -I /usr/include/wireshark/wiretap -I /usr/include/wireshark/wsutil -I /usr/include/wireshark `pkg-config --libs glib-2.0` -I /usr/local/include/hiredis -ggdb +pibs-BGP-Ranking: pibs pibs-BGP-Ranking.o libpibs.o memutils.o synseen.o + gcc -Wall -o pibs-BGP-Ranking pibs-BGP-Ranking.o libpibs.o memutils.o synseen.o -lwiretap `pkg-config --libs glib-2.0` -lpcap -lhiredis -ggdb + +pibs-BGP-Ranking.o: pibs-BGP-Ranking.c + gcc -D HASHDEBUG=0 -Wall -c pibs-BGP-Ranking.c `pkg-config --cflags glib-2.0` -I /usr/include/wireshark/wiretap -I /usr/include/wireshark/wsutil -I /usr/include/wireshark `pkg-config --libs glib-2.0` -I /usr/local/include/hiredis -ggdb + pibs: pibs.o memutils.o synseen.o libpibs.o gcc -Wall -o pibs pibs.o memutils.o synseen.o libpibs.o -lwiretap `pkg-config --libs glib-2.0` -lpcap -lhiredis -ggdb @@ -25,4 +31,6 @@ pibs.o: pibs.c clean: -rm pibs + -rm pibs-stat + -rm pibs-BGP-Ranking -rm *.o diff --git a/bin/pibs-BGP-Ranking.c b/bin/pibs-BGP-Ranking.c new file mode 100644 index 0000000..4303c89 --- /dev/null +++ b/bin/pibs-BGP-Ranking.c @@ -0,0 +1,63 @@ +/* +* pibs - Create lists of targets under SYN floods for bgp ranking +* +* Copyright (C) 2019 Gerard Wagener +* Copyright (C) 2019 CIRCL Computer Incident Response Center Luxembourg +* (SMILE gie). +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +*/ +#include +#include "pibs.h" + +void usage(void) +{ + printf("Create lists of targets under SYN floods for BGP Ranking\n"); + printf("\n"); + printf("OPTIONS\n"); + printf(" -h Shows this screen\n"); + printf(" -r inputfile\n"); + printf(" Read pcap file from inputfile\n"); + printf(" -d directory\n"); + printf(" Root directory where the list should be stored\n"); + printf("\n"); + printf("DIRECTORY STRUCTURE\n"); + printf("/port/year/month/year-month-day.txt\n"); +} + +int main(int argc, char* argv[]) +{ + pibs_t* pibs; + int opt; + + + pibs = init(); + while ((opt = getopt(argc, argv, "hr:d:")) != -1) { + printf("%d\n", opt); + switch (opt) { + case 'h': + usage(); + break; + case 'r': + strncpy(pibs->filename, optarg, FILENAME_MAX); + break; + } + } + + if (pibs->filename[0]) { + process_file(pibs); + } + + return EXIT_SUCCESS; +}