diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/ntclient.c | 112 | ||||
-rw-r--r-- | source3/include/proto.h | 29 | ||||
-rw-r--r-- | source3/include/smb.h | 91 | ||||
-rw-r--r-- | source3/pipenetlog.c | 18 | ||||
-rw-r--r-- | source3/pipentlsa.c | 16 | ||||
-rw-r--r-- | source3/pipesrvsvc.c | 10 | ||||
-rw-r--r-- | source3/pipeutil.c | 12 | ||||
-rw-r--r-- | source3/smbparse.c | 265 |
8 files changed, 456 insertions, 97 deletions
diff --git a/source3/client/ntclient.c b/source3/client/ntclient.c index 16bfaeccbe..c4fbdd13c1 100644 --- a/source3/client/ntclient.c +++ b/source3/client/ntclient.c @@ -111,7 +111,7 @@ static BOOL do_lsa_open_policy(uint16 fnum, char *server_name, LSA_POL_HND *hnd) /* turn parameters into data stream */ p = lsa_io_q_open_pol(False, &q_o, data + 0x18, data, 4, 0); - /* create the request RPC_HDR with no data */ + /* create the request RPC_HDR_RR with no data */ create_rpc_request(call_id, LSA_OPENPOLICY, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -126,7 +126,7 @@ static BOOL do_lsa_open_policy(uint16 fnum, char *server_name, LSA_POL_HND *hnd) &rparam, &rdata)) { LSA_R_OPEN_POL r_o; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -134,16 +134,16 @@ static BOOL do_lsa_open_policy(uint16 fnum, char *server_name, LSA_POL_HND *hnd) p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_open_policy: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_open_policy: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -151,11 +151,11 @@ static BOOL do_lsa_open_policy(uint16 fnum, char *server_name, LSA_POL_HND *hnd) pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_open_policy: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -208,7 +208,7 @@ static BOOL do_lsa_query_info_pol(uint16 fnum, LSA_POL_HND *hnd, uint16 info_cla /* turn parameters into data stream */ p = lsa_io_q_query(False, &q_q, data + 0x18, data, 4, 0); - /* create the request RPC_HDR with no data */ + /* create the request RPC_HDR_RR with no data */ create_rpc_request(call_id, LSA_QUERYINFOPOLICY, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -223,7 +223,7 @@ static BOOL do_lsa_query_info_pol(uint16 fnum, LSA_POL_HND *hnd, uint16 info_cla &rparam, &rdata)) { LSA_R_QUERY_INFO r_q; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -231,16 +231,16 @@ static BOOL do_lsa_query_info_pol(uint16 fnum, LSA_POL_HND *hnd, uint16 info_cla p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_query_info: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_query_info: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -248,11 +248,11 @@ static BOOL do_lsa_query_info_pol(uint16 fnum, LSA_POL_HND *hnd, uint16 info_cla pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_query_info: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -345,7 +345,7 @@ static BOOL do_lsa_close(uint16 fnum, LSA_POL_HND *hnd) /* turn parameters into data stream */ p = lsa_io_q_close(False, &q_c, data + 0x18, data, 4, 0); - /* create the request RPC_HDR with no data */ + /* create the request RPC_HDR_RR with no data */ create_rpc_request(call_id, LSA_CLOSE, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -360,7 +360,7 @@ static BOOL do_lsa_close(uint16 fnum, LSA_POL_HND *hnd) &rparam, &rdata)) { LSA_R_CLOSE r_c; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -368,16 +368,16 @@ static BOOL do_lsa_close(uint16 fnum, LSA_POL_HND *hnd) p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_close: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_close: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -385,11 +385,11 @@ static BOOL do_lsa_close(uint16 fnum, LSA_POL_HND *hnd) pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_close: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -458,7 +458,7 @@ static BOOL do_lsa_req_chal(uint16 fnum, /* turn parameters into data stream */ p = lsa_io_q_req_chal(False, &q_c, data + 0x18, data, 4, 0); - /* create the request RPC_HDR _after_ the main data: length is now known */ + /* create the request RPC_HDR_RR _after_ the main data: length is now known */ create_rpc_request(call_id, LSA_REQCHAL, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -473,7 +473,7 @@ static BOOL do_lsa_req_chal(uint16 fnum, &rparam,&rdata)) { LSA_R_REQ_CHAL r_c; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -481,16 +481,16 @@ static BOOL do_lsa_req_chal(uint16 fnum, p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_req_chal: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_req_chal: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -498,11 +498,11 @@ static BOOL do_lsa_req_chal(uint16 fnum, pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_req_chal: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -559,7 +559,7 @@ static BOOL do_lsa_auth2(uint16 fnum, /* turn parameters into data stream */ p = lsa_io_q_auth_2(False, &q_a, data + 0x18, data, 4, 0); - /* create the request RPC_HDR _after_ the main data: length is now known */ + /* create the request RPC_HDR_RR _after_ the main data: length is now known */ create_rpc_request(call_id, LSA_AUTH2, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -574,7 +574,7 @@ static BOOL do_lsa_auth2(uint16 fnum, &rparam,&rdata)) { LSA_R_AUTH_2 r_a; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -582,16 +582,16 @@ static BOOL do_lsa_auth2(uint16 fnum, p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_auth2: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_auth2: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -599,11 +599,11 @@ static BOOL do_lsa_auth2(uint16 fnum, pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_auth2: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -673,7 +673,7 @@ static BOOL do_lsa_sam_logon(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_clnt /* turn parameters into data stream */ p = lsa_io_q_sam_logon(False, &q_s, data + 0x18, data, 4, 0); - /* create the request RPC_HDR _after_ the main data: length is now known */ + /* create the request RPC_HDR_RR _after_ the main data: length is now known */ create_rpc_request(call_id, LSA_SAMLOGON, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -688,7 +688,7 @@ static BOOL do_lsa_sam_logon(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_clnt &rparam,&rdata)) { LSA_R_SAM_LOGON r_s; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -698,16 +698,16 @@ static BOOL do_lsa_sam_logon(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_clnt p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_sam_logon: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_sam_logon: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -715,11 +715,11 @@ static BOOL do_lsa_sam_logon(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_clnt pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_sam_logon: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } @@ -796,7 +796,7 @@ static BOOL do_lsa_sam_logoff(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_cln /* turn parameters into data stream */ p = lsa_io_q_sam_logoff(False, &q_s, data + 0x18, data, 4, 0); - /* create the request RPC_HDR _after_ the main data: length is now known */ + /* create the request RPC_HDR_RR _after_ the main data: length is now known */ create_rpc_request(call_id, LSA_SAMLOGOFF, data, PTR_DIFF(p, data)); /* create setup parameters. */ @@ -811,7 +811,7 @@ static BOOL do_lsa_sam_logoff(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_cln &rparam,&rdata)) { LSA_R_SAM_LOGOFF r_s; - RPC_HDR hdr; + RPC_HDR_RR hdr; int hdr_len; int pkt_len; @@ -819,16 +819,16 @@ static BOOL do_lsa_sam_logoff(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_cln p = rdata; - if (p) p = smb_io_rpc_hdr (True, &hdr, p, rdata, 4, 0); + if (p) p = smb_io_rpc_hdr_rr (True, &hdr, p, rdata, 4, 0); if (p) p = align_offset(p, rdata, 4); /* oh, what a surprise */ hdr_len = PTR_DIFF(p, rdata); - if (p && hdr_len != hdr.frag_len - hdr.alloc_hint) + if (p && hdr_len != hdr.hdr.frag_len - hdr.alloc_hint) { /* header length not same as calculated header length */ - DEBUG(2,("do_lsa_sam_logoff: hdr_len %x != frag_len-alloc_hint\n", - hdr_len, hdr.frag_len - hdr.alloc_hint)); + DEBUG(2,("do_lsa_sam_logoff: hdr_len %x != frag_len-alloc_hint %x\n", + hdr_len, hdr.hdr.frag_len - hdr.alloc_hint)); p = NULL; } @@ -836,11 +836,11 @@ static BOOL do_lsa_sam_logoff(uint16 fnum, uint32 sess_key[2], DOM_CRED *sto_cln pkt_len = PTR_DIFF(p, rdata); - if (p && pkt_len != hdr.frag_len) + if (p && pkt_len != hdr.hdr.frag_len) { /* packet data size not same as reported fragment length */ DEBUG(2,("do_lsa_sam_logoff: pkt_len %x != frag_len \n", - pkt_len, hdr.frag_len)); + pkt_len, hdr.hdr.frag_len)); p = NULL; } diff --git a/source3/include/proto.h b/source3/include/proto.h index 13368c873d..db8674a5a1 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -943,11 +943,36 @@ void make_sam_info(DOM_SAM_INFO *sam, DOM_ID_INFO_1 *id1); char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align, int depth); char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align, int depth); -void make_rpc_header(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, - uint32 call_id, int data_len, uint8 opnum); +void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len); char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align, int depth); +void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version); +char* smb_io_rpc_iface(BOOL io, RPC_IFACE *ifc, char *q, char *base, int align, int depth); +void make_rpc_addr_str(RPC_ADDR_STR *str, char *name); +char* smb_io_rpc_addr_str(BOOL io, RPC_ADDR_STR *str, char *q, char *base, int align, int depth); +void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid); +char* smb_io_rpc_hdr_bba(BOOL io, RPC_HDR_BBA *rpc, char *q, char *base, int align, int depth); +void make_rpc_hdr_rb(RPC_HDR_RB *rpc, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + uint32 num_elements, uint16 context_id, uint8 num_syntaxes, + RPC_IFACE *abstract, RPC_IFACE *transfer); +char* smb_io_rpc_hdr_rb(BOOL io, RPC_HDR_RB *rpc, char *q, char *base, int align, int depth); +void make_rpc_results(RPC_RESULTS *res, + uint8 num_results, uint16 result, uint16 reason); +char* smb_io_rpc_results(BOOL io, RPC_RESULTS *res, char *q, char *base, int align, int depth); +void make_rpc_hdr_ba(RPC_HDR_BA *rpc, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + char *pipe_addr, + uint8 num_results, uint16 result, uint16 reason, + RPC_IFACE *transfer); +char* smb_io_rpc_hdr_ba(BOOL io, RPC_HDR_BA *rpc, char *q, char *base, int align, int depth); void make_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, uint32 sec_qos); char* smb_io_obj_attr(BOOL io, LSA_OBJ_ATTR *attr, char *q, char *base, int align, int depth); +void make_rpc_hdr_rr(RPC_HDR_RR *hdr, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, uint8 opnum); +char* smb_io_rpc_hdr_rr(BOOL io, RPC_HDR_RR *rpc, char *q, char *base, int align, int depth); char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align, int depth); char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth); char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth); diff --git a/source3/include/smb.h b/source3/include/smb.h index cdd7bcac7a..f0ab45fb37 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -552,12 +552,101 @@ typedef struct rpc_hdr_info uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */ uint16 auth_len; /* 0 - authentication length */ uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */ + +} RPC_HDR; + +/* RPC_HDR_RR - ms request / response rpc header */ +typedef struct rpc_hdr_rr_info +{ + RPC_HDR hdr; + uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */ uint16 context_id; /* 0 - presentation context identifier */ uint8 cancel_count; /* 0 - cancel count */ uint8 opnum; /* request: 0 - reserved. response: opnum */ -} RPC_HDR; +} RPC_HDR_RR; + +/* the interfaces are numbered. as yet I haven't seen more than one interface + * used on the same pipe name + * srvsvc + * abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003) + * transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002) + */ +/* RPC_IFACE */ +typedef struct rpc_iface_info +{ + uint8 data[16]; /* 16 bytes of number */ + uint32 version; /* the interface number */ + +} RPC_IFACE; + + +/* this seems to be the same string name depending on the name of the pipe, + * but is more likely to be linked to the interface name + * "srvsvc", "\\PIPE\\ntsvcs" + * "samr", "\\PIPE\\lsass" + * "wkssvc", "\\PIPE\\wksvcs" + * "NETLOGON", "\\PIPE\\NETLOGON" + */ +/* RPC_ADDR_STR */ +typedef struct rpc_addr_info +{ + uint16 len; /* length of the string including null terminator */ + fstring addr; /* the string above in single byte, null terminated form */ + +} RPC_ADDR_STR; + +/* RPC_HDR_BBA */ +typedef struct rpc_hdr_bba_info +{ + uint16 max_tsize; /* maximum transmission fragment size (0x1630) */ + uint16 max_rsize; /* max receive fragment size (0x1630) */ + uint32 assoc_gid; /* associated group id (0x0) */ + +} RPC_HDR_BBA; + +/* RPC_HDR_RB - ms req bind header */ +typedef struct rpc_hdr_rb_info +{ + RPC_HDR hdr; + RPC_HDR_BBA bba; + + uint32 num_elements; /* the number of elements (0x1) */ + uint16 context_id; /* presentation context identifier (0x0) */ + uint8 num_syntaxes; /* the number of syntaxes (has always been 1?)(0x1) */ + + RPC_IFACE abstract; /* num and vers. of interface client is using */ + RPC_IFACE transfer; /* num and vers. of interface to use for replies */ + +} RPC_HDR_RB; + +/* RPC_RESULTS - can only cope with one reason, right now... */ +typedef struct rpc_results_info +{ +/* uint8[] # 4-byte alignment padding, against SMB header */ + + uint8 num_results; /* the number of results (0x01) */ + +/* uint8[] # 4-byte alignment padding, against SMB header */ + + uint16 result; /* result (0x00 = accept) */ + uint16 reason; /* reason (0x00 = no reason specified) */ + +} RPC_RESULTS; + +/* RPC_HDR_BA */ +typedef struct rpc_hdr_ba_info +{ + RPC_HDR hdr; + RPC_HDR_BBA bba; + + RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */ + RPC_RESULTS res ; /* results and reasons */ + RPC_IFACE transfer; /* the transfer syntax from the request */ + +} RPC_HDR_BA; + /* DOM_QUERY - info class 3 and 5 LSA Query response */ typedef struct dom_query_info diff --git a/source3/pipenetlog.c b/source3/pipenetlog.c index 664488b16d..d6a5131438 100644 --- a/source3/pipenetlog.c +++ b/source3/pipenetlog.c @@ -589,7 +589,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { user_struct *vuser; - RPC_HDR hdr; + RPC_HDR_RR hdr; if (data == NULL) { @@ -597,11 +597,11 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, return False; } - smb_io_rpc_hdr(True, &hdr, data, data, 4, 0); + smb_io_rpc_hdr_rr(True, &hdr, data, data, 4, 0); - if (hdr.pkt_type == RPC_BIND) /* RPC BIND */ + if (hdr.hdr.pkt_type == RPC_BIND) /* RPC BIND */ { - DEBUG(4,("netlogon rpc bind %x\n",hdr.pkt_type)); + DEBUG(4,("netlogon rpc bind %x\n",hdr.hdr.pkt_type)); LsarpcTNP1(data,rdata,rdata_len); return True; } @@ -618,7 +618,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_REQCHAL\n")); api_lsa_req_chal(cnum, uid, vuser, param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -626,7 +626,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_AUTH2\n")); api_lsa_auth_2(vuser, param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -634,7 +634,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_SRVPWSET\n")); api_lsa_srv_pwset(vuser, param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -642,7 +642,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_SAMLOGON\n")); api_lsa_sam_logon(vuser, param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -650,7 +650,7 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_SAMLOGOFF\n")); api_lsa_sam_logoff(vuser, param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } diff --git a/source3/pipentlsa.c b/source3/pipentlsa.c index cf40ccc7af..9cf670e464 100644 --- a/source3/pipentlsa.c +++ b/source3/pipentlsa.c @@ -345,7 +345,7 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, char **rdata,char **rparam, int *rdata_len,int *rparam_len) { - RPC_HDR hdr; + RPC_HDR_RR hdr; if (data == NULL) { @@ -353,11 +353,11 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, return False; } - smb_io_rpc_hdr(True, &hdr, data, data, 4, 0); + smb_io_rpc_hdr_rr(True, &hdr, data, data, 4, 0); - if (hdr.pkt_type == RPC_BIND) /* RPC BIND */ + if (hdr.hdr.pkt_type == RPC_BIND) /* RPC BIND */ { - DEBUG(4,("lsarpc rpc bind %x\n", hdr.pkt_type)); + DEBUG(4,("lsarpc rpc bind %x\n", hdr.hdr.pkt_type)); LsarpcTNP1(data,rdata,rdata_len); return True; } @@ -370,7 +370,7 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_OPENPOLICY\n")); api_lsa_open_policy(param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -379,7 +379,7 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, DEBUG(3,("LSA_QUERYINFOPOLICY\n")); api_lsa_query_info(param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -447,7 +447,7 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_OPENSECRET\n")); api_lsa_lookup_sids(param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } @@ -455,7 +455,7 @@ BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data, { DEBUG(3,("LSA_LOOKUPNAMES\n")); api_lsa_lookup_names(param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } diff --git a/source3/pipesrvsvc.c b/source3/pipesrvsvc.c index 2e578ada10..0dc2291eeb 100644 --- a/source3/pipesrvsvc.c +++ b/source3/pipesrvsvc.c @@ -188,7 +188,7 @@ BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data, char **rdata,char **rparam, int *rdata_len,int *rparam_len) { - RPC_HDR hdr; + RPC_HDR_RR hdr; if (data == NULL) { @@ -196,11 +196,11 @@ BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data, return False; } - smb_io_rpc_hdr(True, &hdr, data, data, 4, 0); + smb_io_rpc_hdr_rr(True, &hdr, data, data, 4, 0); - if (hdr.pkt_type == RPC_BIND) /* RPC BIND */ + if (hdr.hdr.pkt_type == RPC_BIND) /* RPC BIND */ { - DEBUG(4,("srvsvc rpc bind %x\n",hdr.pkt_type)); + DEBUG(4,("srvsvc rpc bind %x\n",hdr.hdr.pkt_type)); LsarpcTNP1(data,rdata,rdata_len); return True; } @@ -212,7 +212,7 @@ BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data, case NETSHAREENUM: { api_srv_net_share_info( param, data, rdata, rdata_len); - create_rpc_reply(hdr.call_id, *rdata, *rdata_len); + create_rpc_reply(hdr.hdr.call_id, *rdata, *rdata_len); break; } diff --git a/source3/pipeutil.c b/source3/pipeutil.c index 93a78df493..c242dc0fde 100644 --- a/source3/pipeutil.c +++ b/source3/pipeutil.c @@ -219,17 +219,17 @@ int make_dom_gids(char *gids_str, DOM_GID *gids) int create_rpc_request(uint32 call_id, uint8 op_num, char *q, int data_len) { - RPC_HDR hdr; + RPC_HDR_RR hdr; - make_rpc_header(&hdr, RPC_REQUEST, call_id, data_len, op_num); - return smb_io_rpc_hdr(False, &hdr, q, q, 4, 0) - q; + make_rpc_hdr_rr(&hdr, RPC_REQUEST, call_id, data_len, op_num); + return smb_io_rpc_hdr_rr(False, &hdr, q, q, 4, 0) - q; } int create_rpc_reply(uint32 call_id, char *q, int data_len) { - RPC_HDR hdr; + RPC_HDR_RR hdr; - make_rpc_header(&hdr, RPC_RESPONSE, call_id, data_len, 0); - return smb_io_rpc_hdr(False, &hdr, q, q, 4, 0) - q; + make_rpc_hdr_rr(&hdr, RPC_RESPONSE, call_id, data_len, 0); + return smb_io_rpc_hdr_rr(False, &hdr, q, q, 4, 0) - q; } diff --git a/source3/smbparse.c b/source3/smbparse.c index 6b02827006..ed15f2eea4 100644 --- a/source3/smbparse.c +++ b/source3/smbparse.c @@ -794,8 +794,8 @@ char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align, int dept /******************************************************************* creates an RPC_HDR structure. ********************************************************************/ -void make_rpc_header(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, - uint32 call_id, int data_len, uint8 opnum) +void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len) { if (hdr == NULL) return; @@ -807,10 +807,6 @@ void make_rpc_header(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, hdr->frag_len = data_len; /* fragment length, fill in later */ hdr->auth_len = 0; /* authentication length */ hdr->call_id = call_id; /* call identifier - match incoming RPC */ - hdr->alloc_hint = data_len - 0x18; /* allocation hint (no idea) */ - hdr->context_id = 0; /* presentation context identifier */ - hdr->cancel_count = 0; /* cancel count */ - hdr->opnum = opnum; /* opnum */ } /******************************************************************* @@ -831,10 +827,224 @@ char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align, int DBG_RW_SVAL("frag_len ", depth, base, io, q, rpc->frag_len); q += 2; DBG_RW_SVAL("auth_len ", depth, base, io, q, rpc->auth_len); q += 2; DBG_RW_IVAL("call_id ", depth, base, io, q, rpc->call_id); q += 4; - DBG_RW_IVAL("alloc_hint", depth, base, io, q, rpc->alloc_hint); q += 4; - DBG_RW_CVAL("context_id", depth, base, io, q, rpc->context_id); q++; - DBG_RW_CVAL("cancel_ct ", depth, base, io, q, rpc->cancel_count); q++; - DBG_RW_CVAL("opnum ", depth, base, io, q, rpc->opnum); q++; + + return q; +} + +/******************************************************************* +creates an RPC_IFACE structure. +********************************************************************/ +void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version) +{ + if (ifc == NULL || data == NULL) return; + + memcpy(ifc->data, data, sizeof(ifc->data)); /* 16 bytes of number */ + ifc->version = version; /* the interface number */ +} + +/******************************************************************* +reads or writes an RPC_IFACE structure. +********************************************************************/ +char* smb_io_rpc_iface(BOOL io, RPC_IFACE *ifc, char *q, char *base, int align, int depth) +{ + if (ifc == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_iface\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = align_offset(q, base, align); + + DBG_RW_SVAL ("version", depth, base, io, q, ifc->version); q += 2; + DBG_RW_PCVAL("data ", depth, base, io, q, ifc->data, sizeof(ifc->data)); q += sizeof(ifc->data); + + return q; +} + +/******************************************************************* +creates an RPC_ADDR_STR structure. +********************************************************************/ +void make_rpc_addr_str(RPC_ADDR_STR *str, char *name) +{ + if (str == NULL || name == NULL) return; + + str->len = strlen(name) + 1; + fstrcpy(str->addr, name); +} + +/******************************************************************* +reads or writes an RPC_ADDR_STR structure. +********************************************************************/ +char* smb_io_rpc_addr_str(BOOL io, RPC_ADDR_STR *str, char *q, char *base, int align, int depth) +{ + if (str == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_addr_str\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = align_offset(q, base, align); + + DBG_RW_IVAL ("len ", depth, base, io, q, str->len); q += 2; + DBG_RW_PSVAL("addr", depth, base, io, q, str->addr, str->len); q += str->len; + + return q; +} + +/******************************************************************* +creates an RPC_HDR_BBA structure. +********************************************************************/ +void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid) +{ + if (bba == NULL) return; + + bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */ + bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */ + bba->assoc_gid = assoc_gid; /* associated group id (0x0) */ +} + +/******************************************************************* +reads or writes an RPC_HDR_BBA structure. +********************************************************************/ +char* smb_io_rpc_hdr_bba(BOOL io, RPC_HDR_BBA *rpc, char *q, char *base, int align, int depth) +{ + if (rpc == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_hdr_bba\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + DBG_RW_SVAL("max_tsize", depth, base, io, q, rpc->max_tsize); q += 2; + DBG_RW_SVAL("max_rsize", depth, base, io, q, rpc->max_rsize); q += 2; + DBG_RW_IVAL("assoc_gid", depth, base, io, q, rpc->assoc_gid); q += 4; + + return q; +} + +/******************************************************************* +creates an RPC_HDR_RB structure. +********************************************************************/ +void make_rpc_hdr_rb(RPC_HDR_RB *rpc, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + uint32 num_elements, uint16 context_id, uint8 num_syntaxes, + RPC_IFACE *abstract, RPC_IFACE *transfer) +{ + if (rpc == NULL) return; + + make_rpc_hdr (&(rpc->hdr), pkt_type, call_id, data_len); + make_rpc_hdr_bba(&(rpc->bba), max_tsize, max_rsize, assoc_gid); + + rpc->num_elements = num_elements ; /* the number of elements (0x1) */ + rpc->context_id = context_id ; /* presentation context identifier (0x0) */ + rpc->num_syntaxes = num_syntaxes ; /* the number of syntaxes (has always been 1?)(0x1) */ + + /* num and vers. of interface client is using */ + memcpy(&(rpc->abstract), abstract, sizeof(rpc->abstract)); + + /* num and vers. of interface to use for replies */ + memcpy(&(rpc->transfer), transfer, sizeof(rpc->transfer)); +} + +/******************************************************************* +reads or writes an RPC_HDR_RB structure. +********************************************************************/ +char* smb_io_rpc_hdr_rb(BOOL io, RPC_HDR_RB *rpc, char *q, char *base, int align, int depth) +{ + if (rpc == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_hdr_bba\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = smb_io_rpc_hdr (io, &(rpc->hdr), q, base, align, depth); + q = smb_io_rpc_hdr_bba(io, &(rpc->bba), q, base, align, depth); + + DBG_RW_IVAL("num_elements", depth, base, io, q, rpc->num_elements); q += 4; + DBG_RW_IVAL("context_id ", depth, base, io, q, rpc->context_id ); q += 4; + DBG_RW_IVAL("num_syntaxes", depth, base, io, q, rpc->num_syntaxes); q += 4; + + q = smb_io_rpc_iface(io, &(rpc->abstract), q, base, align, depth); + q = smb_io_rpc_iface(io, &(rpc->transfer), q, base, align, depth); + + return q; +} + +/******************************************************************* +creates an RPC_RESULTS structure. + +lkclXXXX only one reason at the moment! + +********************************************************************/ +void make_rpc_results(RPC_RESULTS *res, + uint8 num_results, uint16 result, uint16 reason) +{ + if (res == NULL) return; + + res->num_results = num_results; /* the number of results (0x01) */ + res->result = result ; /* result (0x00 = accept) */ + res->reason = reason ; /* reason (0x00 = no reason specified) */ +} + +/******************************************************************* +reads or writes an RPC_RESULTS structure. + +lkclXXXX only one reason at the moment! + +********************************************************************/ +char* smb_io_rpc_results(BOOL io, RPC_RESULTS *res, char *q, char *base, int align, int depth) +{ + if (res == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_results\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = align_offset(q, base, align); + + DBG_RW_CVAL("num_results", depth, base, io, q, res->num_results); q++; + + q = align_offset(q, base, align); + + DBG_RW_SVAL("result ", depth, base, io, q, res->result ); q += 2; + DBG_RW_SVAL("reason ", depth, base, io, q, res->reason ); q += 2; + + return q; +} + +/******************************************************************* +creates an RPC_HDR_BA structure. + +lkclXXXX only one reason at the moment! + +********************************************************************/ +void make_rpc_hdr_ba(RPC_HDR_BA *rpc, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, + uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, + char *pipe_addr, + uint8 num_results, uint16 result, uint16 reason, + RPC_IFACE *transfer) +{ + if (rpc == NULL || transfer == NULL || pipe_addr == NULL) return; + + make_rpc_hdr (&(rpc->hdr ), pkt_type, call_id, data_len); + make_rpc_hdr_bba (&(rpc->bba ), max_tsize, max_rsize, assoc_gid); + make_rpc_addr_str(&(rpc->addr), pipe_addr); + make_rpc_results (&(rpc->res ), num_results, result, reason); + + /* the transfer syntax from the request */ + memcpy(&(rpc->transfer), transfer, sizeof(rpc->transfer)); +} + +/******************************************************************* +reads or writes an RPC_HDR_BA structure. +********************************************************************/ +char* smb_io_rpc_hdr_ba(BOOL io, RPC_HDR_BA *rpc, char *q, char *base, int align, int depth) +{ + if (rpc == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_hdr_ba\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = smb_io_rpc_hdr (io, &(rpc->hdr) , q, base, align, depth); + q = smb_io_rpc_hdr_bba (io, &(rpc->bba) , q, base, align, depth); + q = smb_io_rpc_addr_str(io, &(rpc->addr) , q, base, align, depth); + q = smb_io_rpc_results (io, &(rpc->res) , q, base, align, depth); return q; } @@ -892,6 +1102,41 @@ char* smb_io_obj_attr(BOOL io, LSA_OBJ_ATTR *attr, char *q, char *base, int alig } /******************************************************************* +creates an RPC_HDR_RR structure. +********************************************************************/ +void make_rpc_hdr_rr(RPC_HDR_RR *hdr, enum RPC_PKT_TYPE pkt_type, + uint32 call_id, int data_len, uint8 opnum) +{ + if (hdr == NULL) return; + + make_rpc_hdr(&(hdr->hdr), pkt_type, call_id, data_len); + + hdr->alloc_hint = data_len - 0x18; /* allocation hint */ + hdr->context_id = 0; /* presentation context identifier */ + hdr->cancel_count = 0; /* cancel count */ + hdr->opnum = opnum; /* opnum */ +} + +/******************************************************************* +reads or writes an RPC_HDR_RR structure. +********************************************************************/ +char* smb_io_rpc_hdr_rr(BOOL io, RPC_HDR_RR *rpc, char *q, char *base, int align, int depth) +{ + if (rpc == NULL) return NULL; + + DEBUG(5,("%s%04x smb_io_rpc_hdr_rr\n", tab_depth(depth), PTR_DIFF(q, base))); + depth++; + + q = smb_io_rpc_hdr(io, &(rpc->hdr), q, base, align, depth); + + DBG_RW_IVAL("alloc_hint", depth, base, io, q, rpc->alloc_hint); q += 4; + DBG_RW_CVAL("context_id", depth, base, io, q, rpc->context_id); q++; + DBG_RW_CVAL("cancel_ct ", depth, base, io, q, rpc->cancel_count); q++; + DBG_RW_CVAL("opnum ", depth, base, io, q, rpc->opnum); q++; + + return q; +} +/******************************************************************* reads or writes an LSA_POL_HND structure. ********************************************************************/ char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align, int depth) |