Changeset 5446

Show
Ignore:
Timestamp:
03/16/08 23:46:42 (7 months ago)
Author:
hdm
Message:

Merged all of the scruby patches, fixed Dot11 support with regards to RadioTap? headers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/lib/msf/core/exploit/capture.rb

    r5352 r5446  
    100100                raw = pkt.raw_data 
    101101                off = 0 
    102  
     102                 
    103103                case pkt.datalink 
    104104                when 119 
     
    129129        def each_packet 
    130130                return if not self.capture 
     131         
     132                # print_status("Link type is #{capture.datalink}") 
     133                                                         
    131134                capture.each do |packet| 
    132  
    133135                        dec = Scruby.linklayer_dissector(capture.datalink, packet) 
    134136 
  • framework3/trunk/lib/scruby.rb

    r5349 r5446  
    5353        end 
    5454         
    55         def method_missing(method, *args) 
    56                 Scruby.method_missing(method, *args) 
    57         end 
    58  
    5955        # Same as above, for fields 
    6056        def self.field(method, *args) 
  • framework3/trunk/lib/scruby/const.rb

    r5440 r5446  
    1414 
    1515        # Scruby version 
    16         SCRUBY_VERSION = '0.2.1-hdm-2
     16        SCRUBY_VERSION = '0.3-hdm
    1717 
    1818        # Completion for functions 
    1919        FUNCTIONS_LIST = %w[sendp sniff ls lsc] 
     20 
     21        # Link types that are not implented in Pcap 
     22        DLT_OPENBSD = 12 
     23 
     24        # Pcap::DLT_IEEE802 is 6 but on my system, sniffing on ath0 return 105 as link type 
     25        DLT_IEEE80211 = 105 
    2026 
    2127        # History 
     
    3238        LOOPBACK_DEVICE_PREFIX = 'lo' 
    3339 
     40        # If two layers are to be bound every time 
     41        BIND_ALWAYS = '' 
     42 
    3443        # Constants for Ethernet 
    3544        ETHERTYPE_IPv4 = 0x800 
    36         ETHERTYPE_ARP = 0x806  
    37         ETHERTYPE_ALL = { ETHERTYPE_IPv4 => "IPv4", 
    38                           ETHERTYPE_ARP => "ARP"} 
     45        ETHERTYPE_ARP = 0x806 
     46        ETHERTYPE_ALL = { ETHERTYPE_IPv4 => 'IPv4', 
     47                          ETHERTYPE_ARP => 'ARP' } 
     48        ETHERADDR_ANY = '00:00:00:00:00:00' 
     49 
     50        # Constants for ARP 
     51        ARPTYPE_WHOAS = 1 
     52        ARPTYPE_ISAT = 2 
     53        ARPTYPE_RARP_REQ = 3 
     54        ARPTYPE_RARP_RES = 4 
     55        ARPTYPE_DYN_RARP_REQ = 5 
     56        ARPTYPE_DYN_RARP_REP = 6 
     57        ARPTYPE_DYN_RARP_ERR = 7 
     58        ARPTYPE_IN_ARP_REQ = 8 
     59        ARPTYPE_IN_ARP_REP = 9 
     60 
     61        ARPTYPE_ALL = { ARPTYPE_WHOAS => 'who-as', 
     62                        ARPTYPE_ISAT => 'is-at', 
     63                        ARPTYPE_RARP_REQ => 'RARP-req', 
     64                        ARPTYPE_RARP_RES => 'RARP-rep', 
     65                        ARPTYPE_DYN_RARP_REQ => 'DynRARP-req', 
     66                        ARPTYPE_DYN_RARP_REP => 'DynRARP-rep', 
     67                        ARPTYPE_DYN_RARP_ERR => 'DynRARP-err', 
     68                        ARPTYPE_IN_ARP_REQ => 'InARP-req', 
     69                        ARPTYPE_IN_ARP_REP => 'InARP-rep' } 
     70 
     71        ARPHWTYPE_ETHER = 1 
     72        ARPHWTYPE_FRAME_RELAY = 15 
     73        ARPHWTYPE_ALL = { ARPHWTYPE_ETHER => 'Ethernet', 
     74                          ARPHWTYPE_FRAME_RELAY => 'FrameRelay' } 
     75 
     76        ARPHWLEN_TOKEN_RING = 1 
     77        ARPHWLEN_ETHER = 6 
     78        ARPHWLEN_ALL = { ARPHWLEN_TOKEN_RING => 'TokenRing', 
     79                         ARPHWLEN_ETHER => 'Ethernet' } 
     80 
     81        ARPPROTOLEN_IPv4 = 4 
     82        ARPPROTOLEN_IPv6 = 16 
     83        ARPPROTOLEN_ALL = { ARPPROTOLEN_IPv4 => 'IPv4', 
     84                            ARPPROTOLEN_IPv6 => 'IPv6' } 
    3985 
    4086        # Constants for BSD loopback interfaces 
     
    4288 
    4389        # Constants for IP 
     90        IPFLAGS = %w[MF DF evil] 
     91 
    4492        IPPROTO_ICMP = 1 
    4593        IPPROTO_TCP = 6 
    4694        IPPROTO_UDP = 17 
    47         IPPROTO_ALL = { IPPROTO_ICMP => "ICMP", 
    48                         IPPROTO_TCP => "TCP", 
    49                         IPPROTO_UDP => "UDP" } 
     95        IPPROTO_ALL = { IPPROTO_ICMP => 'ICMP', 
     96                        IPPROTO_TCP => 'TCP', 
     97                        IPPROTO_UDP => 'UDP' } 
     98 
     99        # Constants for TCP 
     100        TCPFLAGS = %w[FIN SYN RST PSH ACK URG ECN RES] 
    50101 
    51102        # Constants for ICMP 
    52         ICMPTYPE_ECHO = 8 
     103        ICMPTYPE_ECHO_REQ = 8 
     104        ICMPTYPE_ALL = { ICMPTYPE_ECHO_REQ => 'echo request' } 
     105 
     106        # Constants for 802.11 
     107        DOT11TYPE_MANAGEMENT = 0 
     108        DOT11TYPE_CONTROL = 1 
     109        DOT11TYPE_DATA = 2 
     110        DOT11TYPE_RESERVED = 3 
     111 
     112        DOT11TYPE_ALL = { DOT11TYPE_MANAGEMENT => 'Management', 
     113                          DOT11TYPE_CONTROL => 'Control', 
     114                          DOT11TYPE_DATA => 'Data', 
     115                          DOT11TYPE_RESERVED => 'Reserved' } 
     116 
     117        DOT11SUBTYPE_PS_POLL = 0b1010 
     118        DOT11SUBTYPE_RTS = 0b1011 
     119        DOT11SUBTYPE_CF_END = 0b1110 
     120        DOT11SUBTYPE_CF_END_CF_ACK = 0b1111 
     121 
     122        DOT11_FC_FLAGS = %w[to-DS from-DS MF retry pw-mgt MD wep order] 
     123 
     124        DOT11_CAPABILITIES = %w[res8 res9 short-slot res11 res12 DSSS-OFDM res14 res15 ESS IBSS CFP CFP-req privacy short-preamble PBCC agility] 
     125 
     126        DOT11_ID = {0 => 'SSID', 1 => 'Rates', 2 =>  'FHset', 3 => 'DSset', 4 => 'CFset', 5 => 'TIM', 6 => 'IBSSset', 16 => 'challenge', 42 => 'ERPinfo', 46 => 'QoS Capability', 47 => 'ERPinfo', 48 => 'RSNinfo', 50 => 'ESRates',221 => 'vendor',68 => 'reserved'} 
     127 
     128        DOT11_REASON = {0 => 'reserved',1 => 'unspec', 2 => 'auth-expired', 
     129                       3 => 'deauth-ST-leaving', 
     130                       4 => 'inactivity', 5 => 'AP-full', 6 => 'class2-from-nonauth', 
     131                       7 => 'class3-from-nonass', 8 => 'disas-ST-leaving', 
     132                       9 => 'ST-not-auth'} 
     133 
     134        DOT11_AUTH_ALGO = {0 => 'open', 1 => 'sharedkey'} 
     135 
     136        DOT11_STATUS = {0 => 'success', 1 => 'failure', 10 => 'cannot-support-all-cap', 
     137                       11 => 'inexist-asso', 12 => 'asso-denied', 13 => 'algo-unsupported', 
     138                       14 => 'bad-seq-num', 15 => 'challenge-failure', 
     139                       16 => 'timeout', 17 => 'AP-full', 18 => 'rate-unsupported'} 
     140 
     141        RADIOTAP_PRESENT = %w[TSFT Flags Rate Channel FHSS dBm_AntSignal dBm_AntNoise Lock_Quality TX_Attenuation dB_TX_Attenuation 
     142                      dBm_TX_Power Antenna dB_AntSignal dB_AntNoise 
     143                      b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 
     144                      b24 b25 b26 b27 b28 b29 b30 Ext] 
    53145 
    54146        def self.aware_proto 
  • framework3/trunk/lib/scruby/dissector.rb

    r5440 r5446  
    3838        class Ether<Layer 
    3939                Scruby.register_dissector(self) 
    40                 def method_missing(method, *args) 
    41                         return Scruby.field(method, *args) 
    42                 end 
    4340 
    4441                attr_accessor :dst, :src, :type 
     
    4643                def init 
    4744                        @protocol = 'Ethernet' 
    48                         @fields_desc =  [ MACField('dst', '00:00:00:00:00:00'), 
    49                                                                 MACField('src', '00:00:00:00:00:00'), 
    50                                                                 XShortField('type', ETHERTYPE_IPv4) ] 
    51                 end 
    52                  
    53         end 
    54          
     45                        @fields_desc =  [ MACField('dst', ETHERADDR_ANY), 
     46                                                                MACField('src', ETHERADDR_ANY), 
     47                                                                XShortEnumField('type', ETHERTYPE_IPv4, ETHERTYPE_ALL) ] 
     48                end 
     49                 
     50        end 
     51 
    5552        # Dissector for ARP  
    5653        class ARP<Layer 
     
    8481                        end 
    8582                end 
    86         end      
    87      
    88    
     83        end 
     84 
    8985        # Dissector for IPv4 
    9086        class IP<Layer 
    9187                Scruby.register_dissector(self) 
    92                 def method_missing(method, *args) 
    93                         return Scruby.field(method, *args) 
    94                 end 
    95  
     88                 
    9689                attr_accessor :version, :ihl, :tos, :len, :id, :flags, :frag 
    9790                attr_accessor :ttl, :proto, :chksum, :src, :dst 
     
    9992                def init 
    10093                        @protocol = 'IPv4' 
    101                         @fields_desc = [ BitField("version", 4, 4), 
    102                                                         BitField("ihl", 5, 4), 
     94                        @fields_desc = [ BitField('version', 4, 4), 
     95                                                        BitField('ihl', 5, 4), 
    10396                                                        XByteField('tos', 0), 
    10497                                                        ShortField('len', 20), 
    10598                                                        XShortField('id', 0), 
    106                                                         BitField('flags', 0, 3), 
     99                                                        FlagsField('flags', 0, 3, IPFLAGS), 
    107100                                                        BitField('frag', 0, 13), 
    108101                                                        ByteField('ttl', 64), 
     
    127120        class ICMP<Layer 
    128121                Scruby.register_dissector(self) 
    129                 def method_missing(method, *args) 
    130                         return Scruby.field(method, *args) 
    131                 end 
    132  
     122                 
    133123                attr_accessor :type, :code, :chksum, :id, :seq 
    134124 
    135125                def init 
    136126                        @protocol = 'ICMP' 
    137                         @fields_desc = [ ByteField('type', ICMPTYPE_ECHO), 
     127                        @fields_desc = [ ByteEnumField('type', ICMPTYPE_ECHO_REQ, ICMPTYPE_ALL), 
    138128                                                        ByteField('code', 0), 
    139129                                                        XShortField('chksum', 0), 
     
    153143        class Raw<Layer 
    154144                Scruby.register_dissector(self) 
    155                 def method_missing(method, *args) 
    156                         return Scruby.field(method, *args) 
    157                 end 
    158  
     145                 
    159146                attr_accessor :load 
    160147 
     
    169156        class TCP<Layer 
    170157                Scruby.register_dissector(self) 
    171                 def method_missing(method, *args) 
    172                         return Scruby.field(method, *args) 
    173                 end 
    174158 
    175159                attr_accessor :sport, :dport, :seq, :ack, :dataofs, :reserved 
     
    182166                                                        IntField('seq', 0), 
    183167                                                        IntField('ack', 0), 
    184                                                         BitField("dataofs", 5, 4), 
    185                                                         BitField("reserved", 0, 4), 
    186                                                         XByteField('flags', 0x2), 
     168                                                        BitField('dataofs', 5, 4), 
     169                                                        BitField('reserved', 0, 4), 
     170                                                        FlagsField('flags', 0x2, 8, TCPFLAGS), 
    187171                                                        ShortField('window', 8192), 
    188172                                                        XShortField('chksum', 0), 
     
    218202        class UDP<Layer 
    219203                Scruby.register_dissector(self) 
    220                 def method_missing(method, *args) 
    221                         return Scruby.field(method, *args) 
    222                 end 
    223  
     204                 
    224205                attr_accessor :sport, :dport, :len, :chksum 
    225206 
     
    264245        class ClassicBSDLoopback<Layer 
    265246                Scruby.register_dissector(self) 
    266                 def method_missing(method, *args) 
    267                         return Scruby.field(method, *args) 
    268                 end 
    269  
     247                 
    270248                attr_accessor :header 
    271249 
     
    280258        class OpenBSDLoopback<Layer 
    281259                Scruby.register_dissector(self) 
    282                 def method_missing(method, *args) 
    283                         return Scruby.field(method, *args) 
    284                 end 
    285  
     260                 
    286261                attr_accessor :header 
    287262 
     
    297272        class Prism<Layer 
    298273                Scruby.register_dissector(self) 
    299                 def method_missing(method, *args) 
    300                         return Scruby.field(method, *args) 
    301                 end 
    302  
     274                 
    303275                attr_accessor :header 
    304276 
     
    353325 
    354326        end 
    355  
    356 =begin 
    357         class Dot11<Layer 
    358                 Scruby.register_dissector(self) 
    359                 def method_missing(method, *args) 
    360                         return Scruby.field(method, *args) 
    361                 end 
    362  
    363                 attr_accessor :header 
    364  
    365                 def init 
    366                         @protocol = '802.11' 
    367                         @fields_desc = [ 
    368                                 BitField("subtype", 0, 4), 
    369                                 BitEnumField("type", 0, 2, ["Management", "Control", "Data", "Reserved"]), 
    370                                 BitField("proto", 0, 2), 
    371                                 FlagsField("FCfield", 0, 8, ["to-DS", "from-DS", "MF", "retry", "pw-mgt", "MD", "wep", "order"]), 
    372                                 ShortField("ID",0), 
    373                                 MACField("addr1", ETHER_ANY), 
    374                                 Dot11Addr2MACField("addr2", ETHER_ANY), 
    375                                 Dot11Addr3MACField("addr3", ETHER_ANY), 
    376                                 Dot11SCField("SC", 0), 
    377                                 Dot11Addr4MACField("addr4", ETHER_ANY)  
    378                         ] 
    379                 end 
    380  
    381         end 
    382 =end 
    383327                 
    384328        # Dissector for RIFF file format header 
    385329        class RIFF<Layer 
    386330                Scruby.register_dissector(self) 
    387                 def method_missing(method, *args) 
    388                         return Scruby.field(method, *args) 
    389                 end 
    390  
    391                 attr_accessor :id, :size 
     331 
     332                attr_accessor :id, :size, :headerid 
    392333 
    393334                def init 
     
    403344        class ANI<Layer 
    404345                Scruby.register_dissector(self) 
    405                 def method_missing(method, *args) 
    406                         return Scruby.field(method, *args) 
    407                 end 
    408  
    409                 attr_accessor :headersize, :frames, :steps, :width, :height, :bitcount, :planes 
     346                 
     347                attr_accessor :id, :size, :headersize, :frames, :steps, :width, :height, :bitcount, :planes 
    410348                attr_accessor :displayrate, :reserved, :sequence, :icon 
    411349 
     
    429367        end 
    430368 
     369 
     370 
     371        # Dot11 dissectors 
     372        class RadioTap<Layer 
     373                Scruby.register_dissector(self) 
     374 
     375                attr_accessor :version, :pad, :len, :notdecoded, :present 
     376 
     377                def init 
     378                        @protocol = 'RadioTap' 
     379                        @fields_desc = [ ByteField('version', 0), 
     380                                                        ByteField('pad', 0), 
     381                                                        FieldLenField('len', 0, 'radiotap', 's', { :adjust => -8 } ), 
     382                                                        FlagsField('present', 0, 32, RADIOTAP_PRESENT), 
     383                                                        StrLenField('radiotap', '', 'len') 
     384                                       ] 
     385                end 
     386 
     387        end 
     388         
     389         
     390        # Dot11 dissectors 
     391        class Dot11<Layer 
     392                Scruby.register_dissector(self) 
     393 
     394                attr_accessor :subtype, :type, :proto, :FCfield, :ID, :addr1, :addr2, :addr3, :SC, :addr4 
     395 
     396                def init 
     397                        @protocol = '802.11' 
     398                        @fields_desc = [ BitField('subtype', 0, 4), 
     399                                                        BitEnumField('type', DOT11TYPE_DATA, 2, DOT11TYPE_ALL), 
     400                                                        BitField('proto', 0, 2), 
     401                                                        FlagsField('FCfield', 0, 8, DOT11_FC_FLAGS), 
     402                                                        ShortField('ID', 0), 
     403                                                        MACField('addr1', ETHERADDR_ANY), 
     404                                                        Dot11Addr2MACField('addr2', ETHERADDR_ANY), 
     405                                                        Dot11Addr3MACField('addr3', ETHERADDR_ANY), 
     406                                                        Dot11SCField('SC', 0), 
     407                                                        Dot11Addr4MACField('addr4', ETHERADDR_ANY) ] 
     408                end 
     409 
     410        end 
     411 
     412        class Dot11QoS<Layer 
     413                Scruby.register_dissector(self) 
     414 
     415                attr_accessor :TID, :EOSP, :AckPolicy, :Reserved, :TXOP 
     416 
     417                def init 
     418                        @protocol = '802.11 QoS' 
     419                        @fields_desc = [ BitField('TID',0,4), 
     420                                                        BitField('EOSP',0,1), 
     421                                                        BitField('AckPolicy',0,2), 
     422                                                        BitField('Reserved',0,1), 
     423                                                        ByteField('TXOP',0) ] 
     424                end 
     425 
     426        end 
     427 
     428        class Dot11Beacon<Layer 
     429                Scruby.register_dissector(self) 
     430 
     431                attr_accessor :timestamp, :beacon_interval, :cap 
     432 
     433                def init 
     434                        @protocol = '802.11 Beacon' 
     435                        @fields_desc = [ LongField('timestamp', 0), # Bug: should be little endian 
     436                                                        LEShortField('beacon_interval', 0x64), 
     437                                                        FlagsField('cap', 0, 16, DOT11_CAPABILITIES) ] 
     438                end 
     439 
     440        end 
     441 
     442        class Dot11Elt<Layer 
     443                Scruby.register_dissector(self) 
     444 
     445                attr_accessor :ID, :len, :info 
     446 
     447                def init 
     448                        @protocol = '802.11 Information Element' 
     449                        @fields_desc = [ ByteEnumField('ID', 0, DOT11_ID), 
     450                                                        FieldLenField('len', 0, 'info', 'C'), 
     451                                                        StrLenField('info', '', 'len') ] 
     452                end 
     453 
     454        end 
     455 
     456        class Dot11ATIM<Layer 
     457                Scruby.register_dissector(self) 
     458 
     459                def init 
     460                        @protocol = '802.11 ATIM' 
     461                end 
     462        end 
     463 
     464        class Dot11Disas<Layer 
     465                Scruby.register_dissector(self) 
     466 
     467                attr_accessor :reason 
     468 
     469                def init 
     470                        @protocol = '802.11 Disassociation' 
     471                        @fields_desc = [ LEShortEnumField('reason', 1, DOT11_REASON) ] 
     472                end 
     473 
     474        end 
     475 
     476        class Dot11AssoReq<Layer 
     477                Scruby.register_dissector(self) 
     478 
     479                attr_accessor :cap, :listen_interval 
     480 
     481                def init 
     482                        @protocol = '802.11 Association Request' 
     483                        @fields_desc = [ FlagsField('cap', 0, 16, DOT11_CAPABILITIES), 
     484                                                        LEShortField('listen_interval', 0xc8) ] 
     485                end 
     486 
     487        end 
     488 
     489        class Dot11AssoResp<Layer 
     490                Scruby.register_dissector(self) 
     491 
     492                attr_accessor :cap, :status, :AID 
     493 
     494                def init 
     495                        @protocol = '802.11 Association Response' 
     496                        @fields_desc = [ FlagsField('cap', 0, 16, DOT11_CAPABILITIES), 
     497                                                        LEShortField('status', 0), 
     498                                                        LEShortField('AID', 0) ] 
     499                end 
     500 
     501        end 
     502 
     503        class Dot11ReassoReq<Layer 
     504                Scruby.register_dissector(self) 
     505 
     506                attr_accessor :cap, :current_AP, :listen_interval 
     507 
     508                def init 
     509                        @protocol = '802.11 Reassociation Request' 
     510                        @fields_desc = [ FlagsField('cap', 0, 16, DOT11_CAPABILITIES), 
     511                                                        MACField('current_AP', ETHERADDR_ANY), 
     512                                                        LEShortField('listen_interval', 0xc8) ] 
     513                end 
     514 
     515        end 
     516 
     517        class Dot11ReassoResp<Dot11AssoResp 
     518                Scruby.register_dissector(self) 
     519 
     520                def init 
     521                        @protocol = '802.11 Reassociation Response' 
     522                end 
     523        end 
     524 
     525        class Dot11ProbeReq<Layer 
     526                Scruby.register_dissector(self) 
     527 
     528                def init 
     529                        @protocol = '802.11 Probe Request' 
     530                end 
     531        end 
     532 
     533        class Dot11ProbeResp<Layer 
     534                Scruby.register_dissector(self) 
     535 
     536                attr_accessor :timestamp, :beacon_interval, :cap 
     537 
     538                def init 
     539                        @protocol = '802.11 Probe Response' 
     540                        @fields_desc = [ LongField('timestamp', 0), # Bug: should be little endian 
     541                                                        LEShortField('beacon_interval', 0x64), 
     542                                                        FlagsField('cap', 0, 16, DOT11_CAPABILITIES) ] 
     543                end 
     544 
     545        end 
     546 
     547        class Dot11Auth<Layer 
     548                Scruby.register_dissector(self) 
     549 
     550                attr_accessor :algo, :seqnum, :status 
     551 
     552                def init 
     553                        @protocol = '802.11 Authentication' 
     554                        @fields_desc = [ LEShortEnumField('algo', 0, DOT11_AUTH_ALGO), 
     555                                                        LEShortField('seqnum', 0), 
     556                                                        LEShortEnumField('status', 0, DOT11_STATUS) ] 
     557                end 
     558 
     559        end 
     560 
     561        class Dot11Deauth<Layer 
     562                Scruby.register_dissector(self) 
     563 
     564                attr_accessor :reason 
     565 
     566                def init 
     567                        @protocol = '802.11 Deauthentication' 
     568                        @fields_desc = [ LEShortEnumField('reason', 1, DOT11_REASON) ] 
     569                end 
     570 
     571        end 
     572 
     573        class Dot11WEP<Layer 
     574                Scruby.register_dissector(self) 
     575 
     576                attr_accessor :iv, :keyid, :wepdata, :icv 
     577 
     578                def init 
     579                        @protocol = '802.11 WEP packet' 
     580                        @fields_desc = [ StrFixedLenField('iv', "\0\0\0", 3), 
     581                                                        ByteField('keyid', 0), 
     582                                                        StrField('wepdata', ''), # Bug: 4 bytes remains 
     583                                                        IntField('icv', 0) ] 
     584                end 
     585 
     586        end 
     587 
     588        class LLC<Layer 
     589                Scruby.register_dissector(self) 
     590 
     591                attr_accessor :dsap, :ssap, :ctrl 
     592 
     593                def init 
     594                        @protocol = 'LLC' 
     595                        @fields_desc = [ XByteField('dsap', 0), 
     596                                                        XByteField('ssap', 0), 
     597                                                        ByteField('ctrl', 0) ] 
     598                end 
     599 
     600        end 
     601 
    431602        # Layer bounds 
    432603        @@layer_bounds = 
     
    437608                        ['type', ETHERTYPE_ARP, ARP] 
    438609                ], 
    439  
     610                 
     611                'RadioTap' => 
     612                [ 
     613                        [BIND_ALWAYS, BIND_ALWAYS, Dot11] 
     614                ], 
     615                 
     616                'Prism' => 
     617                [ 
     618                        [BIND_ALWAYS, BIND_ALWAYS, Dot11] 
     619                ], 
     620 
     621                'Dot11' => [ 
     622                        ['type', 2, LLC], 
     623                        ['subtype', 0, Dot11AssoReq], 
     624                        ['subtype', 1, Dot11AssoResp], 
     625                        ['subtype', 2, Dot11ReassoReq], 
     626                        ['subtype', 3, Dot11ReassoResp], 
     627                        ['subtype', 4, Dot11ProbeReq], 
     628                        ['subtype', 5, Dot11ProbeResp], 
     629                        ['subtype', 8, Dot11Beacon], 
     630                        ['subtype', 9, Dot11ATIM], 
     631                        ['subtype', 10, Dot11Disas], 
     632                        ['subtype', 11, Dot11Auth], 
     633                        ['subtype', 12, Dot11Deauth], 
     634                ], 
     635 
     636                'Dot11QoS' => [ 
     637                        [BIND_ALWAYS, BIND_ALWAYS, LLC] 
     638                ], 
     639                'Dot11Beacon' => [ 
     640                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     641                ], 
     642                'Dot11AssoReq' => [ 
     643                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     644                ], 
     645                'Dot11AssoResp' => [ 
     646                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     647                ], 
     648                'Dot11ReassoReq' => [ 
     649                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     650                ], 
     651                'Dot11ReassoResp' => [ 
     652                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     653                ], 
     654                'Dot11ProbeReq' => [ 
     655                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     656                ], 
     657                'Dot11ProbeResp' => [ 
     658                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     659                ], 
     660                'Dot11Auth' => [ 
     661                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     662                ], 
     663                'Dot11Elt' => [ 
     664                        [BIND_ALWAYS, BIND_ALWAYS, Dot11Elt] 
     665                ], 
     666                 
    440667                'ClassicBSDLoopback' =>  
    441668                [ 
     
    467694                when Pcap::DLT_NULL 
    468695                        ClassicBSDLoopback(pkt) 
    469                 when Pcap::DLT_RAW 
     696                when DLT_OPENBSD 
    470697                        OpenBSDLoopback(pkt) 
    471698                when Pcap::DLT_PRISM_HEADER 
    472699                        Prism(pkt) 
     700                when Pcap::DLT_IEEE802 
     701                when Pcap::DLT_IEEE802_11 
     702                        Dot11(pkt) 
     703                when Pcap::DLT_IEEE802_11_RADIO 
     704                        RadioTap(pkt) 
     705                when Pcap::DLT_IEEE802_11_RADIO_AVS 
     706                        RadioTap(pkt)    
    473707                when 101, 
    474708                        IP(pkt)                  
     
    495729        TCP 
    496730        UDP 
     731        LLC 
     732        ARP 
     733        Prism 
     734        Dot11 
     735        Dot11Beacon 
     736        Dot11Elt 
     737        Dot11ATIM 
     738        Dot11Disas 
     739        Dot11AssoReq 
     740        Dot11AssoResp 
     741        Dot11ReassoReq 
     742        Dot11ReassoResp 
     743        Dot11ProbeReq 
     744        Dot11ProbeResp 
     745        Dot11Auth 
     746        Dot11Deauth 
     747        Dot11WEP 
    497748 
    498749Scapy (1.2.0.1) packet dissectors/types: 
  • framework3/trunk/lib/scruby/field.rb

    r5349 r5446  
    4646                def dissect(layer, string) 
    4747 
     48                        # Preparing the packet for building 
     49                        self.pre_build() 
     50 
    4851                        part = string.unpack(self.format + 'a*') 
    4952 
     
    7477 
    7578                # Converts from human to internal encoding 
    76                 # e.g. allows TCP(:sport=>'http') 
     79                # e.g. allows TCP(:proto=>'ICMP') 
    7780                def from_human(value) 
    7881                        return value 
     
    8588                end 
    8689 
    87                 # Same as tuhuman() but displays more information 
     90                # Same as to_human() but displays more information 
    8891                # e.g. "6 (TCP)" instead of "6" for IP protocol 
    8992                def to_human_complete(value) 
    9093                        return value.to_s 
     94                end 
     95 
     96                # Returns yes if the field is to be added to the dissectors, e.g. depending 
     97                # on the value of another field of the layer (see Dot11*) 
     98                def is_applicable?(layer) 
     99                        return true 
     100                end 
     101 
     102                # Prepares the packet for building 
     103                # e.g. for StrLenField, retrieves the right format size from the associated FieldLenField 
     104                def pre_build 
    91105                end 
    92106 
     
    101115                def to_human_complete(value) 
    102116                        return sprintf('0x%x', value) 
     117                end      
     118        end 
     119 
     120        # Shortcut mixins for reducing code size 
     121        module FieldHumanHexEnum 
     122                def to_human(value) 
     123                        return sprintf('0x%x', value) 
     124                end 
     125 
     126                def to_human_complete(value) 
     127                        # Checking if the value is in the enumeration keys 
     128                        if @enum.keys.include?(value) 
     129                                return sprintf('0x%x', value) + ' (' + @enum[value].to_s + ')' 
     130 
     131                        # Otherwise, just returning the value 
     132                        else 
     133                                return sprintf('0x%x', value) 
     134                        end 
    103135                end      
    104136        end 
     
    148180 
    149181                def to_human_complete(value) 
    150  
     182                        puts "ok" 
    151183                        # Checking if the value is in the enumeration keys 
    152184                        if @enum.keys.include?(value) 
     
    202234                end 
    203235 
    204                 def to_net(value) 
    205                         return value.to_s 
    206                 end 
    207  
    208                 def to_human(value) 
    209                         return value.to_s.inspect 
    210                 end 
    211  
    212                 def to_human_complete(value) 
    213                         return value.to_s.inspect 
    214                 end 
    215  
    216236        end 
    217237 
     
    236256                def dissect(layer, string) 
    237257 
     258                        @@bitsdone ||= 0 
    238259                        # Cannot dissect if the wanted size is greater than the length of the string 
    239260                        # e.g. "IP('A'*7)" should not set frag=65 
     
    277298 
    278299                def to_net(value) 
     300                 
     301                        @@bitsdone ||= 0 
     302                         
    279303                        # OR'ing this value the value the previous ones 
    280304                        @@byte <<= @size 
     
    327351        # Same as ByteEnumField, displayed in hexadecimal form 
    328352        class XByteEnumField<ByteEnumField 
    329                 include FieldHumanHex 
     353                include FieldHumanHexEnum 
    330354        end 
    331355 
     
    351375        # Same as ShortEnumField, displayed in hexadecimal form 
    352376