home *** CD-ROM | disk | FTP | other *** search
/ Steganos Hacker Tools / SHT151.iso / programme / scanner / nmapNTsp1 / Win_2000.exe / nmapNT-src / global_structures.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-25  |  7.0 KB  |  260 lines

  1. #ifndef GLOBAL_STRUCTURES_H
  2. #define GLOBAL_STRUCTURES_H
  3.  
  4. #ifdef WIN32
  5. #ifndef INTERFACEDEF
  6. #define INTERFACEDEF 1
  7. struct interface_info {
  8.     struct in_addr addr;
  9. #ifdef WIN32
  10.     char name[512];
  11. //    char Wname[1024];
  12.     LPADAPTER adapter;
  13.     BYTE MAC[6];
  14. //    char chopname[512];
  15.     long ifid;
  16.     struct in_addr Gateway;
  17. #else
  18.     char name[64];
  19. #endif
  20. #endif
  21. };
  22. #endif
  23. /* Stores "port info" which is TCP/UDP ports or RPC program ids */
  24.  struct portinfo {
  25. #ifdef WIN32
  26.    unsigned short portno; /* TCP/UDP port or RPC program id */
  27. #else
  28.    unsigned long portno; /* TCP/UDP port or RPC program id */
  29. #endif
  30.    short trynum;
  31.    int sd[3]; /* Socket descriptors for connect_scan */
  32.    struct timeval sent[3]; 
  33.    int state;
  34.    int next; /* not struct portinfo * for historical reasons */
  35.    int prev;
  36.   };
  37.  
  38. struct portinfolist {
  39.    struct portinfo *openlist;
  40.    struct portinfo *firewalled;
  41.    struct portinfo *testinglist;
  42. };
  43.  
  44. struct udpprobeinfo {
  45.   unsigned short iptl;
  46.   unsigned short ipid;
  47.   unsigned short ipck;
  48.   unsigned short sport;
  49.   unsigned short dport;
  50.   unsigned short udpck;
  51.   unsigned short udplen;
  52.   unsigned char patternbyte;
  53.   struct in_addr target;
  54. };
  55.  
  56. struct connectsockinfo {
  57.   fd_set fds_read;
  58.   fd_set fds_write;
  59.   fd_set fds_except;
  60.   struct portinfo *socklookup[2048]; /* index socket descriptor -> scan[] 
  61.                     index.  No OS better give us
  62.                     an SD > 2047!@#$ */
  63.   int maxsd;
  64. };
  65.  
  66. struct firewallmodeinfo {
  67.   int active; /* is firewall mode currently active for the host? */
  68.   int nonresponsive_ports; /* # Of ports we haven't received any response from */
  69.   int responsive_ports; /* # of ports that told us whether they were open/closed/filtered/unfiltered */
  70. };
  71.  
  72. /* The runtime statistics used to decide how fast to proced and how
  73.    many ports we can try at once */
  74. struct scanstats {
  75.   int packet_incr;
  76.   double fallback_percent;
  77.   int numqueries_outstanding; /* How many unexpired queries are on the 'net
  78.                  right now? */
  79.   double numqueries_ideal; /* How many do we WANT to be on the 'net right now? */
  80.   int max_width; /* What is the MOST we will tolerate at once */
  81.   int ports_left;
  82.   int changed; /* Has anything changed since last round? */
  83.   int alreadydecreasedqueries;
  84. };
  85.  
  86. struct ftpinfo {
  87.   char user[64];
  88.   char pass[256]; /* methinks you're paranoid if you need this much space */
  89.   char server_name[MAXHOSTNAMELEN + 1];
  90.   struct in_addr server;
  91.   unsigned short port;
  92.   int sd; /* socket descriptor */
  93. };
  94.  
  95. struct AVal {
  96.   char *attribute;
  97.   char value[128];
  98.   struct AVal *next;
  99. };
  100.  
  101. typedef struct FingerTest {
  102.   char OS_name[256];
  103.   char *name;
  104.   struct AVal *results;
  105.   struct FingerTest *next;
  106.  } FingerPrint;
  107.  
  108. struct timeout_info {
  109.   int srtt; /* Smoothed rtt estimate (microseconds) */
  110.   int rttvar; /* Rout trip time variance */
  111.   int timeout; /* Current timeout threshold (microseconds) */
  112. };
  113.  
  114. struct seq_info {
  115.     int class;
  116.     int responses;
  117.     unsigned int seqs[NUM_SEQ_SAMPLES];
  118.     int index;
  119. };
  120.  
  121. struct targets {
  122.   /* These 4 are used for the '/mask' style of specifying target net*/
  123.   unsigned int netmask;
  124.   unsigned int maskformat;
  125.   struct in_addr start;
  126.   struct in_addr currentaddr;
  127.   struct in_addr end;
  128.   /* These two are for the '138.[1-7,16,91-95,200-].12.1 style */
  129.   unsigned char addresses[4][256];
  130.   unsigned int current[4];
  131.   unsigned char last[4];  
  132.   int nleft; /* Number of IPs left in this structure -- set to 0 if 
  133.         the fields are not valid */
  134. };
  135.  
  136.  
  137. struct hoststruct {
  138.   struct in_addr host;
  139.   struct in_addr source_ip;
  140.   char *name;
  141.   struct seq_info seq;
  142.   FingerPrint **FP_matches;
  143.   FingerPrint *FPs[10];
  144.   int numFPs;
  145.   int goodFP;
  146.   portlist ports;
  147.  
  148.   /*
  149.   unsigned int up;
  150.   unsigned int down; */
  151.   int wierd_responses; /* echo responses from other addresses, Ie a network broadcast address */
  152.   unsigned int flags; /* HOST_UP, HOST_DOWN, HOST_FIREWALLED, HOST_BROADCAST (instead of HOST_BROADCAST use wierd_responses */
  153.   struct timeout_info to;
  154.   struct timeval host_timeout;
  155.   struct firewallmodeinfo firewallmode; /* For supporting "firewall mode" speed optimisations */
  156.   int timedout; /* Nonzero if continued scanning should be aborted due to
  157.            timeout  */
  158. #ifdef WIN32
  159.   struct interface_info device; /* The device we transmit on */
  160. #else 
  161.     char device[64]; /* The device we transmit on */
  162. #endif
  163. };
  164.  
  165. struct hostgroup_state {
  166.   struct hoststruct *hostbatch;
  167.   int max_batch_sz; /* The size of the hostbatch[] array */
  168.   int current_batch_sz; /* The number of VALID members of hostbatch[] */
  169.   int next_batch_no; /* The index of the next hostbatch[] member to be given 
  170.             back to the user */
  171.   int randomize; /* Whether each bach should be "shuffled" prior to the ping 
  172.             scan (they will also be out of order when given back one
  173.             at a time to the client program */
  174.   char **target_expressions; /* An array of target expression strings, passed
  175.                 to us by the client (client is also in charge
  176.                 of deleting it AFTER it is done with the 
  177.                 hostgroup_state */
  178.   int num_expressions;       /* The number of valid expressions in 
  179.                 target_expressions member above */
  180.   int next_expression;   /* The index of the next expression we have
  181.                 to handle */
  182.   struct targets current_expression; /* For batch chunking */
  183. };
  184.  
  185. struct ops /* someone took struct options, <grrr> */ {
  186.   int debugging;
  187.   int verbose;
  188.   int randomize_hosts;
  189.   int spoofsource; /* -S used */
  190.   struct in_addr *source;
  191. #ifdef WIN32
  192.   struct interface_info device;
  193. #else
  194.   char device[64];
  195. #endif
  196.   int interactivemode;
  197.   int host_group_sz;
  198.   int generate_random_ips; /* -iR option */
  199.   FingerPrint **reference_FPs;
  200.   unsigned short magic_port;
  201.   unsigned short magic_port_set; /* Was this set by user? */
  202.   unsigned short tcp_probe_port;
  203.  
  204.   /* Scan timing/politeness issues */
  205.   int max_parallelism;
  206.   int max_rtt_timeout;
  207.   int min_rtt_timeout;
  208.   unsigned long host_timeout;
  209.   int scan_delay;
  210.   int initial_rtt_timeout;
  211.   struct in_addr resume_ip; /* The last IP in the log file if user 
  212.                    requested --restore .  Otherwise 
  213.                    restore_ip.s_addr == 0.  Also 
  214.                    target_struct_get will eventually set it 
  215.                    to 0. */
  216.   int isr00t;
  217.   struct in_addr decoys[MAX_DECOYS];
  218.   int numdecoys;
  219.   int decoyturn;
  220.   int identscan;
  221.   int osscan;
  222.   int pingtype;
  223.   int listscan;
  224.   int pingscan;
  225.   int allowall;
  226.   int numports;
  227.   int ackscan;
  228.   int connectscan;
  229.   int bouncescan;
  230.   int rpcscan;
  231.   int nullscan;
  232.   int xmasscan;
  233.   int fragscan;
  234.   int synscan;
  235.   int windowscan;
  236.   int maimonscan;
  237.   int finscan;
  238.   int udpscan;
  239.   int noresolve;
  240.   int force; /* force nmap to continue on even when the outcome seems somewhat certain */
  241.   int append_output; /* Append to any output files rather than overwrite */
  242.   FILE *logfd[LOG_TYPES];
  243.   FILE *nmap_stdout; /* Nmap standard output */
  244. };
  245.   
  246. typedef enum { ACK_SCAN, SYN_SCAN, FIN_SCAN, XMAS_SCAN, UDP_SCAN, CONNECT_SCAN, NULL_SCAN, WINDOW_SCAN, RPC_SCAN, MAIMON_SCAN } stype;
  247.  
  248. #endif /*GLOBAL_STRUCTURES_H */
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.