Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * smb/server-message-block comunication methods/rpc eval methods for GOPHER
- */
- #
- include "include/tlv.h"
- /*
- * smb_extract_tlv() - Parses arbitrary data passed to it. Determines which method
- * to eval, and calls it appropriately. Utilizes a rpc-like
- * procedure to determine the function call.
- */
- int smb_extract_tlv(void * phandle) {
- if (!phandle) {
- return -1;
- }
- uint32_t dwlength = 0, total = 0;
- struct tlv_header hdr = * (struct tlv_header * ) malloc(sizeof h);
- struct tlv_packet * p = tlv_packet_new(TLV_PACKET_TYPE_REQUEST, 0);
- while (dwlength != 8) {
- if (!ReadFile(phandle, (char * ) & h, (DWORD) 8, (PDWORD) & dwlength, NULL)) {
- goto err;
- };
- };
- *(struct tlv_header * ) p = h;
- dwlength = 0;
- while (total < p - > h.len - TLV_MIN_LENGTH) {
- if (!ReadFile(phandle, (char * )(p + sizeof(struct tlv_header) + total),
- (DWORD)(p - > h.len - TLV_MIN_LENGTH - total),
- (PDWORD) & dwlength, NULL)) {
- goto err;
- }
- total += dwlength;
- }
- err:
- if ((struct tlv_header * ) & hdr != NULL) {
- free(hdr);
- };
- if (p != NULL) {
- tlv_packet_free(p);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement