-
Notifications
You must be signed in to change notification settings - Fork 92
/
SMBClient.h
108 lines (94 loc) · 2.3 KB
/
SMBClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#define SECURITY_WIN32
#pragma once
#include "Windows.h"
#define SEC_SUCCESS(Status) ((Status) >= 0)
#define DEFAULT_BUFLEN 8192
#define MessageAttribute ISC_REQ_INTEGRITY
#define TargetNameSpn L"cifs/127.0.0.1"
typedef union usmb2_header {
struct
{
BYTE ProtocolID[4];
BYTE StructureSize[2];
BYTE CreditCharge[2];
BYTE ChannelSequence[2];
BYTE Reserved[2];
BYTE Command[2];
BYTE CreditRequest[2];
BYTE Flags[4];
BYTE NextCommand[4];
long long MessageID;
BYTE ProcessID[4];
BYTE TreeID[4];
BYTE SessionID[8];
BYTE Signature[16];
} smb2_header;
BYTE buffer[64];
};
typedef union usmb2_data {
struct {
BYTE StructureSize[2];
BYTE Flags[1];
BYTE SecurityMode[1];
BYTE Capabilities[4];
BYTE Channel[4];
BYTE SecurityBufferOffset[2];
BYTE SecurityBufferLength[2];
BYTE PreviousSessionID[8];
} smb2_data;
BYTE buffer[24];
};
union myint {
unsigned int i;
char buffer[4];
};
union myshort {
unsigned short int i;
char buffer[2];
};
typedef struct {
short structured_size;;
short flags;
short path_offset;
short path_len;
} tree_connect_request_header;
typedef union {
tree_connect_request_header trh;
char buffer[sizeof(trh)];
} u_tree_connect_request_header;
typedef struct {
short StructuredSize;
byte SecurityFlags;
byte RequestedOplockLevel;
int ImpersonationLevel;
char SmbCreateFlags[8];
char Reserved[8];
char DesiredAccess[4];
char FileAttribute[4];
char ShareAccess[4];
char CreateDisposition[4];
char CreateOptions[4];
short NameOffset;
short NameLength;
int CreateContextsOffset;
int CreateContextsLength;
} create_request;
typedef union
{
create_request cr;
char buffer[sizeof(cr)];
} u_create_request;
typedef struct {
short StructureSize;
short DataOffset;
int WriteLen;
long long FileOffset;
char fileid[16];
int RemainingBytes;
char filler[8];
} write_request;
typedef union {
write_request wr;
char buffer[sizeof(wr)];
} u_write_request;
void SMBAuthenticatedFileWrite();