|
| 1 | +/* |
| 2 | +* pibs - Create lists of isn having the same value than ip address |
| 3 | +* |
| 4 | +* Copyright (C) 2020 Gerard Wagener |
| 5 | +* Copyright (C) 2020 CIRCL Computer Incident Response Center Luxembourg |
| 6 | +* (SMILE gie). |
| 7 | +* |
| 8 | +* This program is free software: you can redistribute it and/or modify |
| 9 | +* it under the terms of the GNU Affero General Public License as published by |
| 10 | +* the Free Software Foundation, either version 3 of the License, or |
| 11 | +* (at your option) any later version. |
| 12 | +* |
| 13 | +* This program is distributed in the hope that it will be useful, |
| 14 | +* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +* GNU Affero General Public License for more details. |
| 17 | +* |
| 18 | +* You should have received a copy of the GNU Affero General Public License |
| 19 | +* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | +*/ |
| 21 | +#include <stdio.h> |
| 22 | +#define __USE_XOPEN |
| 23 | +#include <time.h> |
| 24 | +#include "pibs.h" |
| 25 | + |
| 26 | +void usage(void) |
| 27 | +{ |
| 28 | + printf("Create lists of targets under SYN floods for BGP Ranking\n"); |
| 29 | + printf("\n"); |
| 30 | + printf("OPTIONS\n"); |
| 31 | + printf(" -h Shows this screen\n"); |
| 32 | + printf(" -r inputfile\n"); |
| 33 | + printf(" Read pcap file from inputfile\n"); |
| 34 | + printf("\n"); |
| 35 | + printf("DIRECTORY STRUCTURE\n"); |
| 36 | + printf("<directory>/port/year/month/year-month-day.txt\n"); |
| 37 | +} |
| 38 | + |
| 39 | +void process(pibs_t* pibs, wtap *wth, uint8_t* eth, |
| 40 | +struct ip* ipv4, struct tcphdr* tcp) |
| 41 | +{ |
| 42 | + if (ipv4->ip_dst.s_addr == tcp->seq) { |
| 43 | + printf("%x\n",ntohl(tcp->seq)); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +int main(int argc, char* argv[]) |
| 48 | +{ |
| 49 | + pibs_t* pibs; |
| 50 | + int opt; |
| 51 | + pibs = init(); |
| 52 | + |
| 53 | + while ((opt = getopt(argc, argv, "hr:d:")) != -1) { |
| 54 | + printf("%d\n", opt); |
| 55 | + switch (opt) { |
| 56 | + case 'h': |
| 57 | + usage(); |
| 58 | + break; |
| 59 | + case 'r': |
| 60 | + strncpy(pibs->filename, optarg, FILENAME_MAX); |
| 61 | + pibs->filename[FILENAME_MAX-1] = '\0'; |
| 62 | + break; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + //Set call back function |
| 67 | + pibs->synseen_callback = &process; |
| 68 | + |
| 69 | + if (pibs->filename[0]) { |
| 70 | + process_file(pibs); |
| 71 | + } |
| 72 | + |
| 73 | + return EXIT_SUCCESS; |
| 74 | +} |
0 commit comments