static void filter_request(char *buf) { int msg_type = CVAL(buf,0); int type = CVAL(buf,smb_com); pstring name1,name2; unsigned x; if (msg_type) { /* it's a netbios special */ switch (msg_type) { case 0x81: /* session request */ name_extract(buf,4,name1); name_extract(buf,4 + name_len(buf + 4),name2); DEBUG(0,("sesion_request: %s -> %s\n", name1, name2)); if (netbiosname) { /* replace the destination netbios name */ name_mangle(netbiosname, buf+4, 0x20); } } return; } /* it's an ordinary SMB request */ switch (type) { case SMBsesssetupX: /* force the client capabilities */ x = IVAL(buf,smb_vwv11); x = (x | CLI_CAPABILITY_SET) & ~CLI_CAPABILITY_MASK; SIVAL(buf, smb_vwv11, x); break; } }
static void filter_request(char *buf) { int msg_type = CVAL(buf,0); int type = CVAL(buf,smb_com); pstring name1,name2; unsigned x; if (msg_type) { /* it's a netbios special */ switch (msg_type) { case 0x81: /* session request */ name_extract(buf,4,name1); name_extract(buf,4 + name_len(buf + 4),name2); d_printf("sesion_request: %s -> %s\n", name1, name2); if (netbiosname) { /* replace the destination netbios name */ name_mangle(netbiosname, buf+4, 0x20); } } return; } /* it's an ordinary SMB request */ switch (type) { case SMBsesssetupX: /* force the client capabilities */ x = IVAL(buf,smb_vwv11); d_printf("SMBsesssetupX cap=0x%08x\n", x); d_printf("pwlen=%d/%d\n", SVAL(buf, smb_vwv7), SVAL(buf, smb_vwv8)); system("mv sessionsetup.dat sessionsetup1.dat"); save_file("sessionsetup.dat", smb_buf(buf), SVAL(buf, smb_vwv7)); x = (x | CLI_CAPABILITY_SET) & ~CLI_CAPABILITY_MASK; SIVAL(buf, smb_vwv11, x); break; } }
static void filter_request(char *buf, size_t buf_len) { int msg_type = CVAL(buf,0); int type = CVAL(buf,smb_com); unsigned x; fstring name1,name2; int name_len1, name_len2; int name_type1, name_type2; if (msg_type) { /* it's a netbios special */ switch (msg_type) case 0x81: /* session request */ /* inbuf_size is guaranteed to be at least 4. */ name_len1 = name_len((unsigned char *)(buf+4), buf_len - 4); if (name_len1 <= 0 || name_len1 > buf_len - 4) { DEBUG(0,("Invalid name length in session request\n")); return; } name_len2 = name_len((unsigned char *)(buf+4+name_len1), buf_len - 4 - name_len1); if (name_len2 <= 0 || name_len2 > buf_len - 4 - name_len1) { DEBUG(0,("Invalid name length in session request\n")); return; } name_type1 = name_extract((unsigned char *)buf, buf_len,(unsigned int)4,name1); name_type2 = name_extract((unsigned char *)buf, buf_len,(unsigned int)(4 + name_len1),name2); if (name_type1 == -1 || name_type2 == -1) { DEBUG(0,("Invalid name type in session request\n")); return; } d_printf("sesion_request: %s -> %s\n", name1, name2); if (netbiosname) { char *mangled = name_mangle( talloc_tos(), netbiosname, 0x20); if (mangled != NULL) { /* replace the destination netbios * name */ memcpy(buf+4, mangled, name_len((unsigned char *)mangled, talloc_get_size(mangled))); TALLOC_FREE(mangled); } } return; } /* it's an ordinary SMB request */ switch (type) { case SMBsesssetupX: /* force the client capabilities */ x = IVAL(buf,smb_vwv11); d_printf("SMBsesssetupX cap=0x%08x\n", x); d_printf("pwlen=%d/%d\n", SVAL(buf, smb_vwv7), SVAL(buf, smb_vwv8)); system("mv sessionsetup.dat sessionsetup1.dat"); save_file("sessionsetup.dat", smb_buf(buf), SVAL(buf, smb_vwv7)); x = (x | CLI_CAPABILITY_SET) & ~CLI_CAPABILITY_MASK; SIVAL(buf, smb_vwv11, x); break; } }