| 1 | #include "idl_types.h" | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | IDL structures for NBT operations | 
|---|
| 5 |  | 
|---|
| 6 | NBT is not traditionally encoded using IDL/NDR. This is a bit of an | 
|---|
| 7 | experiment, and I may well switch us back to a more traditional | 
|---|
| 8 | encoding if it doesn't work out | 
|---|
| 9 | */ | 
|---|
| 10 |  | 
|---|
| 11 | import "misc.idl", "security.idl", "svcctl.idl", "samr.idl"; | 
|---|
| 12 | [ | 
|---|
| 13 | helper("../libcli/netlogon/netlogon.h", "../libcli/nbt/libnbt.h"), | 
|---|
| 14 | helpstring("NBT messages"), | 
|---|
| 15 | uuid("6def41b6-86e4-4c32-997c-ed33af7bcd8e") | 
|---|
| 16 | ] | 
|---|
| 17 | interface nbt | 
|---|
| 18 | { | 
|---|
| 19 | const int NBT_NAME_SERVICE_PORT  = 137; | 
|---|
| 20 | const int NBT_DGRAM_SERVICE_PORT = 138; | 
|---|
| 21 |  | 
|---|
| 22 | typedef [bitmap16bit] bitmap { | 
|---|
| 23 | NBT_RCODE                   = 0x000F, | 
|---|
| 24 | NBT_FLAG_BROADCAST          = 0x0010, | 
|---|
| 25 | NBT_FLAG_RECURSION_AVAIL    = 0x0080, | 
|---|
| 26 | NBT_FLAG_RECURSION_DESIRED  = 0x0100, | 
|---|
| 27 | NBT_FLAG_TRUNCATION         = 0x0200, | 
|---|
| 28 | NBT_FLAG_AUTHORITATIVE      = 0x0400, | 
|---|
| 29 | NBT_OPCODE                  = 0x7800, | 
|---|
| 30 | NBT_FLAG_REPLY              = 0x8000 | 
|---|
| 31 | } nbt_operation; | 
|---|
| 32 |  | 
|---|
| 33 | /* the opcodes are in the operation field, masked with | 
|---|
| 34 | NBT_OPCODE */ | 
|---|
| 35 | typedef enum { | 
|---|
| 36 | NBT_OPCODE_QUERY          =  (0x0<<11), | 
|---|
| 37 | NBT_OPCODE_REGISTER       =  (0x5<<11), | 
|---|
| 38 | NBT_OPCODE_RELEASE        =  (0x6<<11), | 
|---|
| 39 | NBT_OPCODE_WACK           =  (0x7<<11), | 
|---|
| 40 | NBT_OPCODE_REFRESH        =  (0x8<<11), | 
|---|
| 41 | NBT_OPCODE_REFRESH2       =  (0x9<<11), | 
|---|
| 42 | NBT_OPCODE_MULTI_HOME_REG =  (0xf<<11) | 
|---|
| 43 | } nbt_opcode; | 
|---|
| 44 |  | 
|---|
| 45 | /* rcode values */ | 
|---|
| 46 | typedef enum { | 
|---|
| 47 | NBT_RCODE_OK  = 0x0, | 
|---|
| 48 | NBT_RCODE_FMT = 0x1, | 
|---|
| 49 | NBT_RCODE_SVR = 0x2, | 
|---|
| 50 | NBT_RCODE_NAM = 0x3, | 
|---|
| 51 | NBT_RCODE_IMP = 0x4, | 
|---|
| 52 | NBT_RCODE_RFS = 0x5, | 
|---|
| 53 | NBT_RCODE_ACT = 0x6, | 
|---|
| 54 | NBT_RCODE_CFT = 0x7 | 
|---|
| 55 | } nbt_rcode; | 
|---|
| 56 |  | 
|---|
| 57 | /* we support any 8bit name type, but by defining the common | 
|---|
| 58 | ones here we get better debug displays */ | 
|---|
| 59 | typedef [enum8bit] enum { | 
|---|
| 60 | NBT_NAME_CLIENT   = 0x00, | 
|---|
| 61 | NBT_NAME_MS       = 0x01, | 
|---|
| 62 | NBT_NAME_USER     = 0x03, | 
|---|
| 63 | NBT_NAME_SERVER   = 0x20, | 
|---|
| 64 | NBT_NAME_PDC      = 0x1B, | 
|---|
| 65 | NBT_NAME_LOGON    = 0x1C, | 
|---|
| 66 | NBT_NAME_MASTER   = 0x1D, | 
|---|
| 67 | NBT_NAME_BROWSER  = 0x1E | 
|---|
| 68 | } nbt_name_type; | 
|---|
| 69 |  | 
|---|
| 70 | /* the ndr parser for nbt_name is separately defined in | 
|---|
| 71 | nbtname.c (along with the parsers for nbt_string) */ | 
|---|
| 72 | typedef [public,nopull,nopush] struct { | 
|---|
| 73 | string        name; | 
|---|
| 74 | string        scope; | 
|---|
| 75 | nbt_name_type type; | 
|---|
| 76 | } nbt_name; | 
|---|
| 77 |  | 
|---|
| 78 | typedef [public,enum16bit] enum { | 
|---|
| 79 | NBT_QCLASS_IP = 0x01 | 
|---|
| 80 | } nbt_qclass; | 
|---|
| 81 |  | 
|---|
| 82 | typedef [public,enum16bit] enum { | 
|---|
| 83 | NBT_QTYPE_ADDRESS     = 0x0001, | 
|---|
| 84 | NBT_QTYPE_NAMESERVICE = 0x0002, | 
|---|
| 85 | NBT_QTYPE_NULL        = 0x000A, | 
|---|
| 86 | NBT_QTYPE_NETBIOS     = 0x0020, | 
|---|
| 87 | NBT_QTYPE_STATUS      = 0x0021 | 
|---|
| 88 | } nbt_qtype; | 
|---|
| 89 |  | 
|---|
| 90 | typedef struct { | 
|---|
| 91 | nbt_name   name; | 
|---|
| 92 | nbt_qtype  question_type; | 
|---|
| 93 | nbt_qclass question_class; | 
|---|
| 94 | } nbt_name_question; | 
|---|
| 95 |  | 
|---|
| 96 | /* these are the possible values of the NBT_NM_OWNER_TYPE | 
|---|
| 97 | field */ | 
|---|
| 98 | typedef enum { | 
|---|
| 99 | NBT_NODE_B = 0x0000, | 
|---|
| 100 | NBT_NODE_P = 0x2000, | 
|---|
| 101 | NBT_NODE_M = 0x4000, | 
|---|
| 102 | NBT_NODE_H = 0x6000 | 
|---|
| 103 | } nbt_node_type; | 
|---|
| 104 |  | 
|---|
| 105 | typedef [bitmap16bit] bitmap { | 
|---|
| 106 | NBT_NM_PERMANENT        = 0x0200, | 
|---|
| 107 | NBT_NM_ACTIVE           = 0x0400, | 
|---|
| 108 | NBT_NM_CONFLICT         = 0x0800, | 
|---|
| 109 | NBT_NM_DEREGISTER       = 0x1000, | 
|---|
| 110 | NBT_NM_OWNER_TYPE       = 0x6000, | 
|---|
| 111 | NBT_NM_GROUP            = 0x8000 | 
|---|
| 112 | } nb_flags; | 
|---|
| 113 |  | 
|---|
| 114 | typedef struct { | 
|---|
| 115 | nb_flags nb_flags; | 
|---|
| 116 | ipv4address ipaddr; | 
|---|
| 117 | } nbt_rdata_address; | 
|---|
| 118 |  | 
|---|
| 119 | typedef struct { | 
|---|
| 120 | uint16 length; | 
|---|
| 121 | nbt_rdata_address addresses[length/6]; | 
|---|
| 122 | } nbt_rdata_netbios; | 
|---|
| 123 |  | 
|---|
| 124 | typedef struct { | 
|---|
| 125 | uint8 unit_id[6]; | 
|---|
| 126 | uint8 jumpers; | 
|---|
| 127 | uint8 test_result; | 
|---|
| 128 | uint16 version_number; | 
|---|
| 129 | uint16 period_of_statistics; | 
|---|
| 130 | uint16 number_of_crcs; | 
|---|
| 131 | uint16 number_alignment_errors; | 
|---|
| 132 | uint16 number_of_collisions; | 
|---|
| 133 | uint16 number_send_aborts; | 
|---|
| 134 | uint32 number_good_sends; | 
|---|
| 135 | uint32 number_good_receives; | 
|---|
| 136 | uint16 number_retransmits; | 
|---|
| 137 | uint16 number_no_resource_conditions; | 
|---|
| 138 | uint16 number_free_command_blocks; | 
|---|
| 139 | uint16 total_number_command_blocks; | 
|---|
| 140 | uint16 max_total_number_command_blocks; | 
|---|
| 141 | uint16 number_pending_sessions; | 
|---|
| 142 | uint16 max_number_pending_sessions; | 
|---|
| 143 | uint16 max_total_sessions_possible; | 
|---|
| 144 | uint16 session_data_packet_size; | 
|---|
| 145 | } nbt_statistics; | 
|---|
| 146 |  | 
|---|
| 147 | typedef struct { | 
|---|
| 148 | [charset(DOS)] uint8 name[15]; | 
|---|
| 149 | nbt_name_type type; | 
|---|
| 150 | nb_flags  nb_flags; | 
|---|
| 151 | } nbt_status_name; | 
|---|
| 152 |  | 
|---|
| 153 | typedef struct { | 
|---|
| 154 | [value(num_names * 18 + 47)] uint16 length; | 
|---|
| 155 | uint8 num_names; | 
|---|
| 156 | nbt_status_name names[num_names]; | 
|---|
| 157 | nbt_statistics  statistics; | 
|---|
| 158 | } nbt_rdata_status; | 
|---|
| 159 |  | 
|---|
| 160 | typedef struct { | 
|---|
| 161 | uint16 length; | 
|---|
| 162 | uint8  data[length]; | 
|---|
| 163 | } nbt_rdata_data; | 
|---|
| 164 |  | 
|---|
| 165 | typedef [nodiscriminant,public] union { | 
|---|
| 166 | [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios; | 
|---|
| 167 | [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status; | 
|---|
| 168 | [default]                 nbt_rdata_data   data; | 
|---|
| 169 | } nbt_rdata; | 
|---|
| 170 |  | 
|---|
| 171 | /* | 
|---|
| 172 | * this macro works around the problem | 
|---|
| 173 | * that we need to use nbt_rdata_data | 
|---|
| 174 | * together with NBT_QTYPE_NETBIOS | 
|---|
| 175 | * for WACK replies | 
|---|
| 176 | */ | 
|---|
| 177 | typedef [flag(LIBNDR_PRINT_ARRAY_HEX),nopush] struct { | 
|---|
| 178 | nbt_name   name; | 
|---|
| 179 | nbt_qtype  rr_type; | 
|---|
| 180 | nbt_qclass rr_class; | 
|---|
| 181 | uint32     ttl; | 
|---|
| 182 | [switch_is(rr_type)] nbt_rdata rdata; | 
|---|
| 183 | } nbt_res_rec; | 
|---|
| 184 |  | 
|---|
| 185 | typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 186 | uint16            name_trn_id; | 
|---|
| 187 | nbt_operation     operation; | 
|---|
| 188 | uint16            qdcount; | 
|---|
| 189 | uint16            ancount; | 
|---|
| 190 | uint16            nscount; | 
|---|
| 191 | uint16            arcount; | 
|---|
| 192 | nbt_name_question questions[qdcount]; | 
|---|
| 193 | nbt_res_rec       answers[ancount]; | 
|---|
| 194 | nbt_res_rec       nsrecs[nscount]; | 
|---|
| 195 | nbt_res_rec       additional[arcount]; | 
|---|
| 196 | [flag(NDR_REMAINING)] DATA_BLOB padding; | 
|---|
| 197 | } nbt_name_packet; | 
|---|
| 198 |  | 
|---|
| 199 |  | 
|---|
| 200 | /* | 
|---|
| 201 | NBT DGRAM packets (UDP/138) | 
|---|
| 202 | */ | 
|---|
| 203 |  | 
|---|
| 204 | typedef [enum8bit] enum { | 
|---|
| 205 | DGRAM_DIRECT_UNIQUE  = 0x10, | 
|---|
| 206 | DGRAM_DIRECT_GROUP   = 0x11, | 
|---|
| 207 | DGRAM_BCAST          = 0x12, | 
|---|
| 208 | DGRAM_ERROR          = 0x13, | 
|---|
| 209 | DGRAM_QUERY          = 0x14, | 
|---|
| 210 | DGRAM_QUERY_POSITIVE = 0x15, | 
|---|
| 211 | DGRAM_QUERY_NEGATIVE = 0x16 | 
|---|
| 212 | } dgram_msg_type; | 
|---|
| 213 |  | 
|---|
| 214 | typedef [bitmap8bit] bitmap { | 
|---|
| 215 | DGRAM_FLAG_MORE         = 0x01, | 
|---|
| 216 | DGRAM_FLAG_FIRST        = 0x02, | 
|---|
| 217 | DGRAM_FLAG_NODE_TYPE    = 0x0C | 
|---|
| 218 | } dgram_flags; | 
|---|
| 219 |  | 
|---|
| 220 | typedef [enum8bit] enum { | 
|---|
| 221 | DGRAM_NODE_B    = 0x00, | 
|---|
| 222 | DGRAM_NODE_P    = 0x04, | 
|---|
| 223 | DGRAM_NODE_M    = 0x08, | 
|---|
| 224 | DGRAM_NODE_NBDD = 0x0C | 
|---|
| 225 | } dgram_node_type; | 
|---|
| 226 |  | 
|---|
| 227 | /* a dgram_message is the main dgram body in general use */ | 
|---|
| 228 |  | 
|---|
| 229 | /* the most common datagram type is a SMB_TRANSACTION | 
|---|
| 230 | operation, where a SMB packet is used in the data section | 
|---|
| 231 | of a dgram_message to hold a trans request, which in turn | 
|---|
| 232 | holds a small command structure. It's a very strange beast | 
|---|
| 233 | indeed. To make the code cleaner we define a basic SMB | 
|---|
| 234 | packet in IDL here. This is not a general purpose SMB | 
|---|
| 235 | packet, and won't be used in the core SMB client/server | 
|---|
| 236 | code, but it does make working with these types of dgrams | 
|---|
| 237 | easier */ | 
|---|
| 238 |  | 
|---|
| 239 | const string NBT_MAILSLOT_NETLOGON = "\\MAILSLOT\\NET\\NETLOGON"; | 
|---|
| 240 | const string NBT_MAILSLOT_NTLOGON  = "\\MAILSLOT\\NET\\NTLOGON"; | 
|---|
| 241 | const string NBT_MAILSLOT_GETDC    = "\\MAILSLOT\\NET\\GETDC"; | 
|---|
| 242 | const string NBT_MAILSLOT_BROWSE   = "\\MAILSLOT\\BROWSE"; | 
|---|
| 243 |  | 
|---|
| 244 | typedef [enum8bit] enum { | 
|---|
| 245 | SMB_TRANSACTION = 0x25 | 
|---|
| 246 | } smb_command; | 
|---|
| 247 |  | 
|---|
| 248 | typedef struct { | 
|---|
| 249 | [range(17,17),value(17)] uint8 wct; | 
|---|
| 250 | uint16                      total_param_count; | 
|---|
| 251 | uint16                      total_data_count; | 
|---|
| 252 | uint16                      max_param_count; | 
|---|
| 253 | uint16                      max_data_count; | 
|---|
| 254 | uint8                       max_setup_count; | 
|---|
| 255 | uint8                       pad; | 
|---|
| 256 | uint16                      trans_flags; | 
|---|
| 257 | uint32                      timeout; | 
|---|
| 258 | uint16                      reserved; | 
|---|
| 259 | uint16                      param_count; | 
|---|
| 260 | uint16                      param_offset; | 
|---|
| 261 | uint16                      data_count; | 
|---|
| 262 | uint16                      data_offset; | 
|---|
| 263 | [range(3,3),value(3)] uint8 setup_count; | 
|---|
| 264 | uint8                       pad2; | 
|---|
| 265 | uint16                      opcode; | 
|---|
| 266 | uint16                      priority; | 
|---|
| 267 | uint16                      _class; | 
|---|
| 268 | [value(strlen(mailslot_name)+1+data.length)] | 
|---|
| 269 | uint16                byte_count; | 
|---|
| 270 | astring                     mailslot_name; | 
|---|
| 271 | [flag(NDR_REMAINING)]       DATA_BLOB data; | 
|---|
| 272 | } smb_trans_body; | 
|---|
| 273 |  | 
|---|
| 274 | typedef [nodiscriminant] union { | 
|---|
| 275 | [case(SMB_TRANSACTION)] smb_trans_body trans; | 
|---|
| 276 | } smb_body; | 
|---|
| 277 |  | 
|---|
| 278 |  | 
|---|
| 279 | typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 280 | smb_command                smb_command; | 
|---|
| 281 | uint8                      err_class; | 
|---|
| 282 | uint8                      pad; | 
|---|
| 283 | uint16                     err_code; | 
|---|
| 284 | uint8                      flags; | 
|---|
| 285 | uint16                     flags2; | 
|---|
| 286 | uint16                     pid_high; | 
|---|
| 287 | uint8                      signature[8]; | 
|---|
| 288 | uint16                     reserved; | 
|---|
| 289 | uint16                     tid; | 
|---|
| 290 | uint16                     pid; | 
|---|
| 291 | uint16                     vuid; | 
|---|
| 292 | uint16                     mid; | 
|---|
| 293 | [switch_is(smb_command)]   smb_body body; | 
|---|
| 294 | } dgram_smb_packet; | 
|---|
| 295 |  | 
|---|
| 296 | const uint32 DGRAM_SMB = 0xff534d42; /* 0xffSMB */ | 
|---|
| 297 |  | 
|---|
| 298 | typedef [nodiscriminant] union { | 
|---|
| 299 | [case(DGRAM_SMB)] dgram_smb_packet smb; | 
|---|
| 300 | } dgram_message_body; | 
|---|
| 301 |  | 
|---|
| 302 | typedef struct { | 
|---|
| 303 | uint16          length; | 
|---|
| 304 | uint16          offset; | 
|---|
| 305 | nbt_name        source_name; | 
|---|
| 306 | nbt_name        dest_name; | 
|---|
| 307 | uint32          dgram_body_type; | 
|---|
| 308 | [switch_is(dgram_body_type)] dgram_message_body body; | 
|---|
| 309 | } dgram_message; | 
|---|
| 310 |  | 
|---|
| 311 | typedef [enum8bit] enum { | 
|---|
| 312 | DGRAM_ERROR_NAME_NOT_PRESENT = 0x82, | 
|---|
| 313 | DGRAM_ERROR_INVALID_SOURCE   = 0x83, | 
|---|
| 314 | DGRAM_ERROR_INVALID_DEST     = 0x84 | 
|---|
| 315 | } dgram_err_code; | 
|---|
| 316 |  | 
|---|
| 317 | typedef [nodiscriminant] union { | 
|---|
| 318 | [case(DGRAM_DIRECT_UNIQUE)]   dgram_message  msg; | 
|---|
| 319 | [case(DGRAM_DIRECT_GROUP)]    dgram_message  msg; | 
|---|
| 320 | [case(DGRAM_BCAST)]           dgram_message  msg; | 
|---|
| 321 | [case(DGRAM_ERROR)]           dgram_err_code error; | 
|---|
| 322 | [case(DGRAM_QUERY)]           nbt_name       dest_name; | 
|---|
| 323 | [case(DGRAM_QUERY_POSITIVE)]  nbt_name       dest_name; | 
|---|
| 324 | [case(DGRAM_QUERY_NEGATIVE)]  nbt_name       dest_name; | 
|---|
| 325 | } dgram_data; | 
|---|
| 326 |  | 
|---|
| 327 | typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct { | 
|---|
| 328 | dgram_msg_type msg_type; | 
|---|
| 329 | dgram_flags    flags; | 
|---|
| 330 | uint16         dgram_id; | 
|---|
| 331 | ipv4address    src_addr; | 
|---|
| 332 | uint16         src_port; | 
|---|
| 333 | [switch_is(msg_type)] dgram_data data; | 
|---|
| 334 | } nbt_dgram_packet; | 
|---|
| 335 |  | 
|---|
| 336 |  | 
|---|
| 337 | /****************************************** | 
|---|
| 338 | * \MAILSLOT\NET\NETLOGON mailslot requests | 
|---|
| 339 | * and | 
|---|
| 340 | * \MAILSLOT\NET\NTLOGON mailslot requests | 
|---|
| 341 | */ | 
|---|
| 342 |  | 
|---|
| 343 | typedef [public,gensize] struct { | 
|---|
| 344 | uint32                  sockaddr_family; | 
|---|
| 345 | [flag(NDR_BIG_ENDIAN)]  ipv4address pdc_ip; | 
|---|
| 346 | [flag(NDR_REMAINING)]   DATA_BLOB remaining; | 
|---|
| 347 | } nbt_sockaddr; | 
|---|
| 348 |  | 
|---|
| 349 | typedef [bitmap32bit,public] bitmap { | 
|---|
| 350 | NBT_SERVER_PDC                          = 0x00000001, | 
|---|
| 351 | NBT_SERVER_GC                           = 0x00000004, | 
|---|
| 352 | NBT_SERVER_LDAP                         = 0x00000008, | 
|---|
| 353 | NBT_SERVER_DS                           = 0x00000010, | 
|---|
| 354 | NBT_SERVER_KDC                          = 0x00000020, | 
|---|
| 355 | NBT_SERVER_TIMESERV                     = 0x00000040, | 
|---|
| 356 | NBT_SERVER_CLOSEST                      = 0x00000080, | 
|---|
| 357 | NBT_SERVER_WRITABLE                     = 0x00000100, | 
|---|
| 358 | NBT_SERVER_GOOD_TIMESERV                = 0x00000200, | 
|---|
| 359 | NBT_SERVER_NDNC                         = 0x00000400, | 
|---|
| 360 | NBT_SERVER_SELECT_SECRET_DOMAIN_6       = 0x00000800, | 
|---|
| 361 | NBT_SERVER_FULL_SECRET_DOMAIN_6         = 0x00001000, | 
|---|
| 362 | NBT_SERVER_ADS_WEB_SERVICE              = 0x00002000, | 
|---|
| 363 | NBT_SERVER_HAS_DNS_NAME                 = 0x20000000, | 
|---|
| 364 | NBT_SERVER_IS_DEFAULT_NC                = 0x40000000, | 
|---|
| 365 | NBT_SERVER_FOREST_ROOT                  = 0x80000000 | 
|---|
| 366 | } nbt_server_type; | 
|---|
| 367 |  | 
|---|
| 368 | typedef [bitmap32bit,public] bitmap { | 
|---|
| 369 | NETLOGON_NT_VERSION_1                   = 0x00000001, | 
|---|
| 370 | NETLOGON_NT_VERSION_5                   = 0x00000002, | 
|---|
| 371 | NETLOGON_NT_VERSION_5EX                 = 0x00000004, | 
|---|
| 372 | NETLOGON_NT_VERSION_5EX_WITH_IP         = 0x00000008, | 
|---|
| 373 | NETLOGON_NT_VERSION_WITH_CLOSEST_SITE   = 0x00000010, | 
|---|
| 374 | NETLOGON_NT_VERSION_AVOID_NT4EMUL       = 0x01000000, | 
|---|
| 375 | NETLOGON_NT_VERSION_PDC                 = 0x10000000, | 
|---|
| 376 | NETLOGON_NT_VERSION_IP                  = 0x20000000, | 
|---|
| 377 | NETLOGON_NT_VERSION_LOCAL               = 0x40000000, | 
|---|
| 378 | NETLOGON_NT_VERSION_GC                  = 0x80000000 | 
|---|
| 379 | } netlogon_nt_version_flags; | 
|---|
| 380 |  | 
|---|
| 381 | typedef [enum16bit,public] enum { | 
|---|
| 382 | LOGON_REQUEST                     = 0, | 
|---|
| 383 | LOGON_RESPONSE2                   = 6, | 
|---|
| 384 | LOGON_PRIMARY_QUERY               = 7,  /* Was also NETLOGON_QUERY_FOR_PDC */ | 
|---|
| 385 | NETLOGON_ANNOUNCE_UAS             = 10, | 
|---|
| 386 | NETLOGON_RESPONSE_FROM_PDC        = 12, | 
|---|
| 387 | LOGON_SAM_LOGON_REQUEST           = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */ | 
|---|
| 388 | LOGON_SAM_LOGON_RESPONSE          = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */ | 
|---|
| 389 | LOGON_SAM_LOGON_PAUSE_RESPONSE    = 20, | 
|---|
| 390 | LOGON_SAM_LOGON_USER_UNKNOWN      = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */ | 
|---|
| 391 | LOGON_SAM_LOGON_RESPONSE_EX       = 23,  /* was NETLOGON_RESPONSE_FROM_PDC2     */ | 
|---|
| 392 | LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24, | 
|---|
| 393 | LOGON_SAM_LOGON_USER_UNKNOWN_EX   = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */ | 
|---|
| 394 | } netlogon_command; | 
|---|
| 395 |  | 
|---|
| 396 | typedef bitmap samr_AcctFlags samr_AcctFlags; | 
|---|
| 397 |  | 
|---|
| 398 | /* query to dc hand marshaled, as it has 'optional' | 
|---|
| 399 | * parts */ | 
|---|
| 400 | typedef [nopull,nopush] struct { | 
|---|
| 401 | uint16               request_count; | 
|---|
| 402 | nstring              computer_name; | 
|---|
| 403 | nstring              user_name; | 
|---|
| 404 | astring              mailslot_name; | 
|---|
| 405 | samr_AcctFlags       acct_control; | 
|---|
| 406 | [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; | 
|---|
| 407 | /* The manual alignment is required because this | 
|---|
| 408 | * structure is marked flag(NDR_NOALIGN) via the | 
|---|
| 409 | * nbt_netlogon_packet below. | 
|---|
| 410 | * | 
|---|
| 411 | * However, both MUST only be present if sid_size > 0 | 
|---|
| 412 | */ | 
|---|
| 413 | [flag(NDR_ALIGN4)]   DATA_BLOB _pad; | 
|---|
| 414 | [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; | 
|---|
| 415 | netlogon_nt_version_flags               nt_version; | 
|---|
| 416 | uint16               lmnt_token; | 
|---|
| 417 | uint16               lm20_token; | 
|---|
| 418 | } NETLOGON_SAM_LOGON_REQUEST; | 
|---|
| 419 |  | 
|---|
| 420 | typedef struct { | 
|---|
| 421 | astring              computer_name; | 
|---|
| 422 | astring              user_name; | 
|---|
| 423 | astring              mailslot_name; | 
|---|
| 424 | uint8                request_count; | 
|---|
| 425 | uint16               lmnt_token; | 
|---|
| 426 | uint16               lm20_token; | 
|---|
| 427 | } NETLOGON_LOGON_REQUEST; | 
|---|
| 428 |  | 
|---|
| 429 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 430 | netlogon_command command; | 
|---|
| 431 | nstring              pdc_name; | 
|---|
| 432 | nstring              user_name; | 
|---|
| 433 | nstring              domain_name; | 
|---|
| 434 | netlogon_nt_version_flags               nt_version; | 
|---|
| 435 | uint16               lmnt_token; | 
|---|
| 436 | uint16               lm20_token; | 
|---|
| 437 | } NETLOGON_SAM_LOGON_RESPONSE_NT40; | 
|---|
| 438 |  | 
|---|
| 439 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 440 | netlogon_command command; | 
|---|
| 441 | nstring              pdc_name; | 
|---|
| 442 | nstring              user_name; | 
|---|
| 443 | nstring              domain_name; | 
|---|
| 444 | GUID                 domain_uuid; | 
|---|
| 445 | GUID                 zero_uuid; | 
|---|
| 446 | nbt_string           forest; | 
|---|
| 447 | nbt_string           dns_domain; | 
|---|
| 448 | nbt_string           pdc_dns_name; | 
|---|
| 449 | ipv4address          pdc_ip; | 
|---|
| 450 | nbt_server_type      server_type; | 
|---|
| 451 | netlogon_nt_version_flags    nt_version; | 
|---|
| 452 | uint16               lmnt_token; | 
|---|
| 453 | uint16               lm20_token; | 
|---|
| 454 | } NETLOGON_SAM_LOGON_RESPONSE; | 
|---|
| 455 |  | 
|---|
| 456 | /* response from pdc hand marshaled (we have an additional | 
|---|
| 457 | * function that uses this structure), as it has 'optional' | 
|---|
| 458 | * parts */ | 
|---|
| 459 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 460 | netlogon_command command; | 
|---|
| 461 | uint16               sbz; /* From the docs */ | 
|---|
| 462 | nbt_server_type      server_type; | 
|---|
| 463 | GUID                 domain_uuid; | 
|---|
| 464 | nbt_string           forest; | 
|---|
| 465 | nbt_string           dns_domain; | 
|---|
| 466 | nbt_string           pdc_dns_name; | 
|---|
| 467 | nbt_string           domain_name; | 
|---|
| 468 | nbt_string           pdc_name; | 
|---|
| 469 | nbt_string           user_name; | 
|---|
| 470 | nbt_string           server_site; | 
|---|
| 471 | nbt_string           client_site; | 
|---|
| 472 |  | 
|---|
| 473 | /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */ | 
|---|
| 474 | [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size; | 
|---|
| 475 | [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr; | 
|---|
| 476 |  | 
|---|
| 477 | /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */ | 
|---|
| 478 | nbt_string           next_closest_site; | 
|---|
| 479 |  | 
|---|
| 480 | netlogon_nt_version_flags               nt_version; | 
|---|
| 481 | uint16               lmnt_token; | 
|---|
| 482 | uint16               lm20_token; | 
|---|
| 483 | } NETLOGON_SAM_LOGON_RESPONSE_EX; | 
|---|
| 484 |  | 
|---|
| 485 | /* query for pdc request */ | 
|---|
| 486 | typedef struct { | 
|---|
| 487 | astring              computer_name; | 
|---|
| 488 | astring              mailslot_name; | 
|---|
| 489 | [flag(NDR_ALIGN2)]   DATA_BLOB _pad; | 
|---|
| 490 | nstring              unicode_name; | 
|---|
| 491 | netlogon_nt_version_flags               nt_version; | 
|---|
| 492 | uint16               lmnt_token; | 
|---|
| 493 | uint16               lm20_token; | 
|---|
| 494 | } nbt_netlogon_query_for_pdc; | 
|---|
| 495 |  | 
|---|
| 496 | /* response from pdc */ | 
|---|
| 497 | typedef [public] struct { | 
|---|
| 498 | netlogon_command command; | 
|---|
| 499 | astring pdc_name; | 
|---|
| 500 | [flag(NDR_ALIGN2)]   DATA_BLOB _pad; | 
|---|
| 501 | nstring              unicode_pdc_name; | 
|---|
| 502 | nstring              domain_name; | 
|---|
| 503 | netlogon_nt_version_flags               nt_version; | 
|---|
| 504 | uint16               lmnt_token; | 
|---|
| 505 | uint16               lm20_token; | 
|---|
| 506 | } nbt_netlogon_response_from_pdc; | 
|---|
| 507 |  | 
|---|
| 508 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 509 | netlogon_command command; | 
|---|
| 510 | astring pdc_name; | 
|---|
| 511 | uint16 lm20_token; | 
|---|
| 512 | } nbt_netlogon_response2; | 
|---|
| 513 |  | 
|---|
| 514 | typedef enum netr_SamDatabaseID netr_SamDatabaseID; | 
|---|
| 515 |  | 
|---|
| 516 | /* used to announce SAM changes - MS-NRPC 2.2.1.5.1 */ | 
|---|
| 517 | typedef struct { | 
|---|
| 518 | netr_SamDatabaseID   db_index; | 
|---|
| 519 | hyper                serial; | 
|---|
| 520 | NTTIME               timestamp; | 
|---|
| 521 | } nbt_db_change_info; | 
|---|
| 522 |  | 
|---|
| 523 | typedef struct { | 
|---|
| 524 | uint32           serial_lo; | 
|---|
| 525 | time_t           timestamp; | 
|---|
| 526 | uint32           pulse; | 
|---|
| 527 | uint32           random; | 
|---|
| 528 | astring          pdc_name; | 
|---|
| 529 | astring          domain; | 
|---|
| 530 | [flag(NDR_ALIGN2)] DATA_BLOB _pad; | 
|---|
| 531 | nstring          unicode_pdc_name; | 
|---|
| 532 | nstring          unicode_domain; | 
|---|
| 533 | uint32           db_count; | 
|---|
| 534 | nbt_db_change_info    dbchange[db_count]; | 
|---|
| 535 | [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size; | 
|---|
| 536 | [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid; | 
|---|
| 537 | uint32           message_format_version; | 
|---|
| 538 | uint32           message_token; | 
|---|
| 539 | } NETLOGON_DB_CHANGE; | 
|---|
| 540 |  | 
|---|
| 541 | typedef [nodiscriminant] union { | 
|---|
| 542 | [case(LOGON_REQUEST)]  NETLOGON_LOGON_REQUEST logon0; | 
|---|
| 543 | [case(LOGON_SAM_LOGON_REQUEST)]       NETLOGON_SAM_LOGON_REQUEST logon; | 
|---|
| 544 | [case(LOGON_PRIMARY_QUERY)] nbt_netlogon_query_for_pdc pdc; | 
|---|
| 545 | [case(NETLOGON_ANNOUNCE_UAS)] NETLOGON_DB_CHANGE uas; | 
|---|
| 546 | } nbt_netlogon_request; | 
|---|
| 547 |  | 
|---|
| 548 | #if 0 | 
|---|
| 549 | [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response; | 
|---|
| 550 | [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2; | 
|---|
| 551 |  | 
|---|
| 552 | [case(LOGON_SAM_LOGON_PAUSE_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 553 | [case(LOGON_SAM_LOGON_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 554 | [case(LOGON_SAM_LOGON_USER_UNKNOWN)] NETLOGON_SAM_LOGON_RESPONSE reply; | 
|---|
| 555 | [case(LOGON_SAM_LOGON_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 556 | [case(LOGON_SAM_LOGON_PAUSE_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 557 | [case(LOGON_SAM_LOGON_USER_UNKNOWN_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex; | 
|---|
| 558 | #endif | 
|---|
| 559 |  | 
|---|
| 560 | typedef [flag(NDR_NOALIGN),public] struct { | 
|---|
| 561 | netlogon_command command; | 
|---|
| 562 | [switch_is(command)] nbt_netlogon_request req; | 
|---|
| 563 | } nbt_netlogon_packet; | 
|---|
| 564 |  | 
|---|
| 565 | void decode_nbt_netlogon_packet( | 
|---|
| 566 | [in] nbt_netlogon_packet packet | 
|---|
| 567 | ); | 
|---|
| 568 |  | 
|---|
| 569 | /********************************************************/ | 
|---|
| 570 | /* \MAILSLOT\BROWSE mailslot requests                   */ | 
|---|
| 571 | /* for details see http://ubiqx.org/cifs/Browsing.html  */ | 
|---|
| 572 | /********************************************************/ | 
|---|
| 573 | typedef bitmap svcctl_ServerType svcctl_ServerType; | 
|---|
| 574 |  | 
|---|
| 575 | typedef [enum8bit] enum { | 
|---|
| 576 | HostAnnouncement        = 1, | 
|---|
| 577 | AnnouncementRequest     = 2, | 
|---|
| 578 | Election                = 8, | 
|---|
| 579 | GetBackupListReq        = 9, | 
|---|
| 580 | GetBackupListResp       = 10, | 
|---|
| 581 | BecomeBackup            = 11, | 
|---|
| 582 | DomainAnnouncement      = 12, | 
|---|
| 583 | MasterAnnouncement      = 13, | 
|---|
| 584 | ResetBrowserState       = 14, | 
|---|
| 585 | LocalMasterAnnouncement = 15 | 
|---|
| 586 | } nbt_browse_opcode; | 
|---|
| 587 |  | 
|---|
| 588 | typedef struct { | 
|---|
| 589 | uint8 UpdateCount; | 
|---|
| 590 | uint32 Periodicity; | 
|---|
| 591 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 592 | uint8 OSMajor; | 
|---|
| 593 | uint8 OSMinor; | 
|---|
| 594 | svcctl_ServerType ServerType; | 
|---|
| 595 | uint8 BroMajorVer; | 
|---|
| 596 | uint8 BroMinorVer; | 
|---|
| 597 | uint16 Signature; | 
|---|
| 598 | astring Comment; | 
|---|
| 599 | } nbt_browse_host_announcement; | 
|---|
| 600 |  | 
|---|
| 601 | typedef struct { | 
|---|
| 602 | uint8 Unused; | 
|---|
| 603 | astring ResponseName; | 
|---|
| 604 | } nbt_browse_announcement_request; | 
|---|
| 605 |  | 
|---|
| 606 | typedef struct { | 
|---|
| 607 | uint8 Version; | 
|---|
| 608 | uint32 Criteria; | 
|---|
| 609 | uint32 UpTime; /* In milliseconds */ | 
|---|
| 610 | uint32 Reserved; /* Must be zero */ | 
|---|
| 611 | astring ServerName; | 
|---|
| 612 | } nbt_browse_election_request; | 
|---|
| 613 |  | 
|---|
| 614 | typedef struct { | 
|---|
| 615 | uint8 ReqCount; | 
|---|
| 616 | uint32 Token; | 
|---|
| 617 | } nbt_browse_backup_list_request; | 
|---|
| 618 |  | 
|---|
| 619 | typedef struct { | 
|---|
| 620 | uint8 BackupCount; | 
|---|
| 621 | uint32 Token; | 
|---|
| 622 | nbt_name BackupServerList[BackupCount];/* TODO: this is wrong */ | 
|---|
| 623 | } nbt_browse_backup_list_response; | 
|---|
| 624 |  | 
|---|
| 625 | typedef struct { | 
|---|
| 626 | astring BrowserName; | 
|---|
| 627 | } nbt_browse_become_backup; | 
|---|
| 628 |  | 
|---|
| 629 | typedef struct { | 
|---|
| 630 | uint8 UpdateCount; | 
|---|
| 631 | uint32 Periodicity; | 
|---|
| 632 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 633 | uint8 OSMajor; | 
|---|
| 634 | uint8 OSMinor; | 
|---|
| 635 | svcctl_ServerType ServerType; | 
|---|
| 636 | uint32 MysteriousField; | 
|---|
| 637 | astring Comment; | 
|---|
| 638 | } nbt_browse_domain_announcement; | 
|---|
| 639 |  | 
|---|
| 640 | typedef struct { | 
|---|
| 641 | astring ServerName; | 
|---|
| 642 | } nbt_browse_master_announcement; | 
|---|
| 643 |  | 
|---|
| 644 | typedef struct { | 
|---|
| 645 | uint8 Command; | 
|---|
| 646 | } nbt_browse_reset_state; | 
|---|
| 647 |  | 
|---|
| 648 | typedef struct { | 
|---|
| 649 | uint8 UpdateCount; | 
|---|
| 650 | uint32 Periodicity; | 
|---|
| 651 | [charset(DOS)] uint8 ServerName[16]; | 
|---|
| 652 | uint8 OSMajor; | 
|---|
| 653 | uint8 OSMinor; | 
|---|
| 654 | svcctl_ServerType ServerType; | 
|---|
| 655 | uint8 BroMajorVer; | 
|---|
| 656 | uint8 BroMinorVer; | 
|---|
| 657 | uint16 Signature; | 
|---|
| 658 | astring Comment; | 
|---|
| 659 | } nbt_browse_local_master_announcement; | 
|---|
| 660 |  | 
|---|
| 661 | typedef [nodiscriminant] union { | 
|---|
| 662 | [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement; | 
|---|
| 663 | [case(AnnouncementRequest)] nbt_browse_announcement_request announcement_request; | 
|---|
| 664 | [case(Election)] nbt_browse_election_request election_request; | 
|---|
| 665 | [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request; | 
|---|
| 666 | [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response; | 
|---|
| 667 | [case(BecomeBackup)] nbt_browse_become_backup become_backup; | 
|---|
| 668 | [case(DomainAnnouncement)] nbt_browse_domain_announcement domain_announcement; | 
|---|
| 669 | [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement; | 
|---|
| 670 | [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state; | 
|---|
| 671 | [case(LocalMasterAnnouncement)] nbt_browse_local_master_announcement local_master_announcement; | 
|---|
| 672 | } nbt_browse_payload; | 
|---|
| 673 |  | 
|---|
| 674 | typedef [public,flag(NDR_NOALIGN)] struct { | 
|---|
| 675 | nbt_browse_opcode opcode; | 
|---|
| 676 | [switch_is(opcode)] nbt_browse_payload payload; | 
|---|
| 677 | } nbt_browse_packet; | 
|---|
| 678 | } | 
|---|