summaryrefslogtreecommitdiff
path: root/other/b-scan/tmp/include/bscan/bscan.h
blob: c1ad9bb71df260a75e9213028e1afd22dd1dd7f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * bscan, lame (and hopefully fast) banner scanner [port 21,25,110,...]
 *
 * "<es> skyper its a cool idea"
 * "<es> i'd like to see the k0ad when ur finished"
 * HI ES :) 
 * greetings to all my !el8 brothers :))
 */

#include <stdio.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <pthread.h>
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#ifndef __USE_BSD
#define __USE_BSD
#endif
#ifndef __BSD_SOURCE
#define __BSD_SOURCE
#endif
#include "arpg.h"
#include "network_raw.h"


#define SPF_SMAC	"\x00\x20\xAF\xA3\x13\x37"

#define OPT_VERB	0x1
#define OPT_RESERV1	0x2
#define OPT_SETARP	0x4
#define OPT_SPREADSCAN	0x8
#define OPT_OUTONLY	0x10

#define OPT_ABRT	0x20
#define OPT_REST	0x40
#define OPT_HOSTFILE	0x80
#define OPT_W8SEMA	0x100


struct _opt
{
    int (*getnextip) ();
    int sox;
    u_char *packet;
    int pkg_maxlen;
    int pkg_len;		/* actual length of contructed packet */
    char *hostfile;
    char **argvlist;
    FILE *ffd;			/* e.g. input file */
    char *target;
    unsigned long netmask;	/* depricated */
    unsigned long network;	/* depricated */
    unsigned int limit;
    unsigned short flags;
    unsigned long random_maxcount;
    u_int delay;		/* w8 for outstanding packets */
    u_int pscanstat;		/* scan stats every x pkts, default NEVER */
    u_long start_ip;		/* in HBO */
    u_long end_ip;		/* in HBO */
    u_long ipscan_count;	/* scanned ip's of a SPECIFIC range [temp!] */
    u_long iptotscan_count;	/* total scan_count over all ranges */
				/* used for flood protection */
    u_long bsent_count;		/* byte-sent counter. TMP (!) variable */
    u_long ip_offset;		/* spread scan offset */
    u_long ip_blklen;		/* block-length for spread-scan */
    u_long ip_pos;		/* position for SPREAD scan, non-linear */
    struct timeval scan_start;	/* scan start for ALL  ranges */
				/* the real beginning */
    struct timeval tv2;		/* flood protection timer 2 + restore */
			 	/* must be the last gettimeofday() from scan */
    float sec;			/* flood protection distance time */
    struct _libnet lnet;
    u_char spf_smac[6];		/* spoofed ethernet sender mac */
    pthread_t bscantid;		/* 'parent' thread id */
    pthread_t snarftid;		/* snarf thread id */
    struct _snarf
    {
	u_long icmp_c;
	u_long close_c;
	u_long open_c;
	u_long refused_c;
    }
    snarf;
    struct net_tuple nt;
};


void make_iprange (u_long *, u_long *, u_long *, u_long *, char *);
void init_spreadscan (u_long diff);
void sigdriver (int);
void print_scanstat (FILE *);
void die (int);