home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / nmap254b.zip / osscan.h < prev    next >
C/C++ Source or Header  |  2001-08-10  |  7KB  |  125 lines

  1.  
  2. /***********************************************************************/
  3. /* osscan.h -- Routines used for OS detection via TCP/IP               */
  4. /* fingerprinting.  For more information on how this works in Nmap,    */
  5. /* see my paper at                                                     */
  6. /* http://www.insecure.org/nmap/nmap-fingerprinting-article.html       */
  7. /*                                                                     */
  8. /***********************************************************************/
  9. /*  The Nmap Security Scanner is (C) 1995-2001 Insecure.Com LLC. This  */
  10. /*  program is free software; you can redistribute it and/or modify    */
  11. /*  it under the terms of the GNU General Public License as published  */
  12. /*  by the Free Software Foundation; Version 2.  This guarantees your  */
  13. /*  right to use, modify, and redistribute this software under certain */
  14. /*  conditions.  If this license is unacceptable to you, we may be     */
  15. /*  willing to sell alternative licenses (contact sales@insecure.com). */
  16. /*                                                                     */
  17. /*  If you received these files with a written license agreement       */
  18. /*  stating terms other than the (GPL) terms above, then that          */
  19. /*  alternative license agreement takes precendence over this comment. */
  20. /*                                                                     */
  21. /*  Source is provided to this software because we believe users have  */
  22. /*  a right to know exactly what a program is going to do before they  */
  23. /*  run it.  This also allows you to audit the software for security   */
  24. /*  holes (none have been found so far).                               */
  25. /*                                                                     */
  26. /*  Source code also allows you to port Nmap to new platforms, fix     */
  27. /*  bugs, and add new features.  You are highly encouraged to send     */
  28. /*  your changes to fyodor@insecure.org for possible incorporation     */
  29. /*  into the main distribution.  By sending these changes to Fyodor or */
  30. /*  one the insecure.org development mailing lists, it is assumed that */
  31. /*  you are offering Fyodor the unlimited, non-exclusive right to      */
  32. /*  reuse, modify, and relicense the code.  This is important because  */
  33. /*  the inability to relicense code has caused devastating problems    */
  34. /*  for other Free Software projects (such as KDE and NASM).  Nmap     */
  35. /*  will always be available Open Source.  If you wish to specify      */
  36. /*  special license conditions of your contributions, just say so      */
  37. /*  when you send them.                                                */
  38. /*                                                                     */
  39. /*  This program is distributed in the hope that it will be useful,    */
  40. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of     */
  41. /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  */
  42. /*  General Public License for more details (                          */
  43. /*  http://www.gnu.org/copyleft/gpl.html ).                            */
  44. /*                                                                     */
  45. /***********************************************************************/
  46.  
  47. /* $Id: osscan.h,v 1.17 2001/08/10 05:53:08 fyodor Exp $ */
  48.  
  49. #ifndef OSSCAN_H
  50. #define OSSCAN_H
  51.  
  52. #include "nmap.h"
  53. #include "tcpip.h"
  54. #include "global_structures.h"
  55.  
  56. #define OSSCAN_SUCCESS 0
  57. #define OSSCAN_NOMATCHES -1
  58. #define OSSCAN_TOOMANYMATCHES -2
  59.  
  60. /* We won't even consider matches with a lower accuracy than this */
  61. #define OSSCAN_GUESS_THRESHOLD 0.85
  62. /**********************  STRUCTURES  ***********************************/
  63.  
  64. /* moved to global_structures.h */
  65.  
  66. /**********************  PROTOTYPES  ***********************************/
  67. int os_scan(struct hoststruct *target);
  68. FingerPrint *get_fingerprint(struct hoststruct *target, struct seq_info *si);
  69. struct AVal *fingerprint_iptcppacket(struct ip *ip, int mss, unsigned int syn);
  70. struct AVal *fingerprint_portunreach(struct ip *ip, struct udpprobeinfo *upi);
  71. struct udpprobeinfo *send_closedudp_probe(int rawsd, struct in_addr *dest,
  72.                       u16 sport, u16 dport);
  73.  
  74. unsigned int get_gcd_n_ulong(int numvalues, unsigned int *values);
  75. unsigned int euclid_gcd(unsigned int a, unsigned int b);
  76. char *fp2ascii(FingerPrint *FP);
  77. FingerPrint **parse_fingerprint_reference_file();
  78. /* Takes a fingerprint and returns the matches in FPR (which must
  79.    point to an allocated FingerPrintResults structure) -- results will
  80.    be reverse-sorted by accuracy.  No results below
  81.    accuracy_threshhold will be included.  The max matches returned is
  82.    the maximum that fits in a FingerPrintResults structure.  The
  83.    allocated FingerPrintResults does not have to be initialized --
  84.    that will be done in this function.  */
  85.  
  86. void match_fingerprint(FingerPrint *FP, struct FingerPrintResults *FPR, 
  87.                double accuracy_threshold);
  88. struct AVal *str2AVal(char *p);
  89. struct AVal *gettestbyname(FingerPrint *FP, const char *name);
  90.  
  91. /* Returns true if perfect match -- if num_subtests & num_subtests_succeeded are non_null it updates them.  if shortcircuit is zero, it does all the tests, otherwise it returns when the first one fails */
  92.  
  93. /* Returns true if perfect match -- if num_subtests &
  94.    num_subtests_succeeded are non_null it ADDS THE NEW VALUES to what
  95.    is already there.  So initialize them to zero first if you only
  96.    want to see the results from this match.  if shortcircuit is zero,
  97.    it does all the tests, otherwise it returns when the first one
  98.    fails */
  99. int AVal_match(struct AVal *reference, struct AVal *fprint, unsigned long *num_subtests, unsigned long *num_subtests_succeeded, int shortcut);
  100.  
  101. void freeFingerPrint(FingerPrint *FP);
  102. char *mergeFPs(FingerPrint *FPs[], int numFPs, int openport, int closedport);
  103.  
  104. /* Writes an informational "Test" result suitable for including at the
  105.    top of a fingerprint.  Gives info which might be useful when the
  106.    FPrint is submitted (eg Nmap version, etc).  Result is written (up
  107.    to ostrlen) to the ostr var passed in */
  108. void WriteSInfo(char *ostr, int ostrlen, int openport, int closedport);
  109.  
  110. /* This function takes an array of "numSamples" IP IDs and analyzes
  111.  them to determine their sequenceability classification.  It returns
  112.  one of the IPID_SEQ_* classifications defined in nmap.h .  If the
  113.  function cannot determine the sequence, IPID_SEQ_UNKNOWN is returned.
  114.  This islocalhost argument is a boolean specifying whether these
  115.  numbers were generated by scanning localhost.  NOTE: the "ipids" argument
  116.  may be modified if localhost is set to true. */
  117. int ipid_sequence(int numSamples, u16 *ipids, int islocalhost);
  118.  
  119. #endif /*OSSCAN_H*/
  120.  
  121.  
  122.  
  123.  
  124.  
  125.