| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | ''' |
|---|
| 4 | global_structures - Implements different data structures used by Nmap |
|---|
| 5 | ''' |
|---|
| 6 | |
|---|
| 7 | from time import time |
|---|
| 8 | |
|---|
| 9 | class portinfo: |
|---|
| 10 | '''Stores "port info" which is TCP/UDP ports or RPC program ids.''' |
|---|
| 11 | |
|---|
| 12 | portno = None # TCP/UDP port or RPC program id or IP protocol. |
|---|
| 13 | trynum = None |
|---|
| 14 | sd = [3 * None] # This list must be filled with socket objects. |
|---|
| 15 | timeval = {"tv_sec" : 0, "tv_usec" : 0} |
|---|
| 16 | state = None |
|---|
| 17 | |
|---|
| 18 | # Don't forget to use portinfo objects as lists' values. |
|---|
| 19 | protinfolist = {"opened" : [], "firewalled" : [], "testing" : []} |
|---|
| 20 | |
|---|
| 21 | class udprobeinfo: |
|---|
| 22 | '''Stores information about UDP ports probes.''' |
|---|
| 23 | |
|---|
| 24 | iptl = None |
|---|
| 25 | ipid = None |
|---|
| 26 | ipck = None |
|---|
| 27 | sport = None # Source port |
|---|
| 28 | dport = None # Destination port |
|---|
| 29 | udpck = None |
|---|
| 30 | udplen = None |
|---|
| 31 | |
|---|
| 32 | # There was struct in_addr in the native code. Here we'll use |
|---|
| 33 | # sockets. |
|---|
| 34 | target = None |
|---|
| 35 | |
|---|
| 36 | class scanstats: |
|---|
| 37 | ''' The runtime statistics used to how fast to proceed and how many |
|---|
| 38 | ports we can try at once. |
|---|
| 39 | ''' |
|---|
| 40 | |
|---|
| 41 | packet_incr = None |
|---|
| 42 | initial_packet_width = None |
|---|
| 43 | fallback_percent = None |
|---|
| 44 | numqueries_outstanding = None |
|---|
| 45 | numqueries_ideal = None |
|---|
| 46 | max_width = None |
|---|
| 47 | min_width = None |
|---|
| 48 | ports_left = None |
|---|
| 49 | changed = None |
|---|
| 50 | alreadydecreasedqueries = None |
|---|
| 51 | |
|---|
| 52 | class seq_info: |
|---|
| 53 | responses = None |
|---|
| 54 | seqclass = None |
|---|
| 55 | ts_seqclass = None |
|---|
| 56 | |
|---|
| 57 | # Time of last system boot. None, is unknown |
|---|
| 58 | # Use time() here. |
|---|
| 59 | uptime = None |
|---|
| 60 | |
|---|
| 61 | ipid_seqclass = None |
|---|
| 62 | seqs = [6 * None] |
|---|
| 63 | timestamps = [6 * None] |
|---|
| 64 | index = None |
|---|
| 65 | ipids = [6 * None] |
|---|
| 66 | lastboot = None # use time() |
|---|
| 67 | |
|---|
| 68 | class OS_Classification: |
|---|
| 69 | OS_vendor = '' |
|---|
| 70 | OS_Family = '' |
|---|
| 71 | OS_Generation = '' |
|---|
| 72 | Device_type = '' |
|---|
| 73 | |
|---|
| 74 | class AVal: |
|---|
| 75 | attribute = '' |
|---|
| 76 | value = '' # len(value) < 128 characters |
|---|
| 77 | |
|---|
| 78 | AVal_list = [] # List of AVal objects |
|---|
| 79 | |
|---|
| 80 | class FingerTest: |
|---|
| 81 | OS_name = '' |
|---|
| 82 | OS_class = [8 * OS_Classification()] |
|---|
| 83 | num_OS_Classifications = None |
|---|
| 84 | line = None # Line number is nmap-os-fingerprints |
|---|
| 85 | name = '' |
|---|
| 86 | results = AVal_list |
|---|
| 87 | |
|---|
| 88 | FingerTest_list = [] # List of FingerTest objects |
|---|