update sharpcifs

This commit is contained in:
Luke Pulverenti
2017-07-07 23:12:21 -04:00
parent a30e22c3a2
commit 0d10dfe471
221 changed files with 23704 additions and 25614 deletions

View File

@@ -18,26 +18,26 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class LsaPolicyHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public LsaPolicyHandle(DcerpcHandle handle, string server, int access)
{
if (server == null)
{
server = "\\\\";
}
MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
public class LsaPolicyHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public LsaPolicyHandle(DcerpcHandle handle, string server, int access)
{
if (server == null)
{
server = "\\\\";
}
MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
}

View File

@@ -18,17 +18,17 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
internal class LsarSidArrayX : Lsarpc.LsarSidArray
{
internal LsarSidArrayX(Sid[] sids)
{
NumSids = sids.Length;
this.Sids = new Lsarpc.LsarSidPtr[sids.Length];
for (int si = 0; si < sids.Length; si++)
{
this.Sids[si] = new Lsarpc.LsarSidPtr();
this.Sids[si].Sid = sids[si];
}
}
}
internal class LsarSidArrayX : Lsarpc.LsarSidArray
{
internal LsarSidArrayX(Sid[] sids)
{
NumSids = sids.Length;
this.Sids = new Lsarpc.LsarSidPtr[sids.Length];
for (int si = 0; si < sids.Length; si++)
{
this.Sids[si] = new Lsarpc.LsarSidPtr();
this.Sids[si].Sid = sids[si];
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,25 +19,25 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcDfsRootEnum : Netdfs.NetrDfsEnumEx
{
public MsrpcDfsRootEnum(string server) : base(server, 200, unchecked(0xFFFF), new Netdfs.DfsEnumStruct(), new NdrLong(0))
{
Info.Level = Level;
Info.E = new Netdfs.DfsEnumArray200();
Ptype = 0;
public class MsrpcDfsRootEnum : Netdfs.NetrDfsEnumEx
{
public MsrpcDfsRootEnum(string server) : base(server, 200, unchecked(0xFFFF), new Netdfs.DfsEnumStruct(), new NdrLong(0))
{
Info.Level = Level;
Info.E = new Netdfs.DfsEnumArray200();
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
public virtual IFileEntry[] GetEntries()
{
Netdfs.DfsEnumArray200 a200 = (Netdfs.DfsEnumArray200)Info.E;
SmbShareInfo[] entries = new SmbShareInfo[a200.Count];
for (int i = 0; i < a200.Count; i++)
{
entries[i] = new SmbShareInfo(a200.S[i].DfsName, 0, null);
}
return entries;
}
}
public virtual IFileEntry[] GetEntries()
{
Netdfs.DfsEnumArray200 a200 = (Netdfs.DfsEnumArray200)Info.E;
SmbShareInfo[] entries = new SmbShareInfo[a200.Count];
for (int i = 0; i < a200.Count; i++)
{
entries[i] = new SmbShareInfo(a200.S[i].DfsName, 0, null);
}
return entries;
}
}
}

View File

@@ -16,14 +16,14 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcEnumerateAliasesInDomain : Samr.SamrEnumerateAliasesInDomain
{
public MsrpcEnumerateAliasesInDomain(SamrDomainHandle domainHandle, int acctFlags
, Samr.SamrSamArray sam) : base(domainHandle, 0, acctFlags, null, 0)
{
this.Sam = sam;
Ptype = 0;
public class MsrpcEnumerateAliasesInDomain : Samr.SamrEnumerateAliasesInDomain
{
public MsrpcEnumerateAliasesInDomain(SamrDomainHandle domainHandle, int acctFlags
, Samr.SamrSamArray sam) : base(domainHandle, 0, acctFlags, null, 0)
{
this.Sam = sam;
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -16,14 +16,14 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcGetMembersInAlias : Samr.SamrGetMembersInAlias
{
public MsrpcGetMembersInAlias(SamrAliasHandle aliasHandle, Lsarpc.LsarSidArray sids
) : base(aliasHandle, sids)
{
this.Sids = sids;
Ptype = 0;
public class MsrpcGetMembersInAlias : Samr.SamrGetMembersInAlias
{
public MsrpcGetMembersInAlias(SamrAliasHandle aliasHandle, Lsarpc.LsarSidArray sids
) : base(aliasHandle, sids)
{
this.Sids = sids;
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -18,21 +18,17 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcLookupSids : Lsarpc.LsarLookupSids
{
internal Sid[] sids;
public class MsrpcLookupSids : Lsarpc.LsarLookupSids
{
internal Sid[] sids;
public MsrpcLookupSids(LsaPolicyHandle policyHandle, Sid[] sids)
: base(policyHandle,
new LsarSidArrayX(sids),
new Lsarpc.LsarRefDomainList(),
new Lsarpc.LsarTransNameArray(),
1,
sids.Length)
{
this.sids = sids;
Ptype = 0;
public MsrpcLookupSids(LsaPolicyHandle policyHandle, Sid[] sids) : base(policyHandle
, new LsarSidArrayX(sids), new Lsarpc.LsarRefDomainList(), new Lsarpc.LsarTransNameArray
(), 1, sids.Length)
{
this.sids = sids;
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -16,23 +16,20 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcLsarOpenPolicy2 : Lsarpc.LsarOpenPolicy2
{
public MsrpcLsarOpenPolicy2(string server, int access, LsaPolicyHandle policyHandle)
: base(server,
new Lsarpc.LsarObjectAttributes(),
access,
policyHandle)
{
ObjectAttributes.Length = 24;
Lsarpc.LsarQosInfo qos = new Lsarpc.LsarQosInfo();
qos.Length = 12;
qos.ImpersonationLevel = 2;
qos.ContextMode = 1;
qos.EffectiveOnly = 0;
ObjectAttributes.SecurityQualityOfService = qos;
Ptype = 0;
public class MsrpcLsarOpenPolicy2 : Lsarpc.LsarOpenPolicy2
{
public MsrpcLsarOpenPolicy2(string server, int access, LsaPolicyHandle policyHandle
) : base(server, new Lsarpc.LsarObjectAttributes(), access, policyHandle)
{
ObjectAttributes.Length = 24;
Lsarpc.LsarQosInfo qos = new Lsarpc.LsarQosInfo();
qos.Length = 12;
qos.ImpersonationLevel = 2;
qos.ContextMode = 1;
qos.EffectiveOnly = 0;
ObjectAttributes.SecurityQualityOfService = qos;
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -18,13 +18,13 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcQueryInformationPolicy : Lsarpc.LsarQueryInformationPolicy
{
public MsrpcQueryInformationPolicy(LsaPolicyHandle policyHandle, short level, NdrObject info)
: base(policyHandle, level, info)
{
Ptype = 0;
public class MsrpcQueryInformationPolicy : Lsarpc.LsarQueryInformationPolicy
{
public MsrpcQueryInformationPolicy(LsaPolicyHandle policyHandle, short level, NdrObject
info) : base(policyHandle, level, info)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -16,13 +16,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcSamrConnect2 : Samr.SamrConnect2
{
public MsrpcSamrConnect2(string server, int access, SamrPolicyHandle policyHandle)
: base(server, access, policyHandle)
{
Ptype = 0;
public class MsrpcSamrConnect2 : Samr.SamrConnect2
{
public MsrpcSamrConnect2(string server, int access, SamrPolicyHandle policyHandle
) : base(server, access, policyHandle)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -16,13 +16,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcSamrConnect4 : Samr.SamrConnect4
{
public MsrpcSamrConnect4(string server, int access, SamrPolicyHandle policyHandle)
: base(server, 2, access, policyHandle)
{
Ptype = 0;
public class MsrpcSamrConnect4 : Samr.SamrConnect4
{
public MsrpcSamrConnect4(string server, int access, SamrPolicyHandle policyHandle
) : base(server, 2, access, policyHandle)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -16,16 +16,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcSamrOpenAlias : Samr.SamrOpenAlias
{
public MsrpcSamrOpenAlias(SamrDomainHandle handle,
int access,
int rid,
SamrAliasHandle aliasHandle)
: base(handle, access, rid, aliasHandle)
{
Ptype = 0;
public class MsrpcSamrOpenAlias : Samr.SamrOpenAlias
{
public MsrpcSamrOpenAlias(SamrDomainHandle handle, int access, int rid, SamrAliasHandle
aliasHandle) : base(handle, access, rid, aliasHandle)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
}
}
}

View File

@@ -18,11 +18,8 @@ namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcSamrOpenDomain : Samr.SamrOpenDomain
{
public MsrpcSamrOpenDomain(SamrPolicyHandle handle,
int access,
Rpc.SidT sid,
SamrDomainHandle domainHandle)
: base(handle, access, sid, domainHandle)
public MsrpcSamrOpenDomain(SamrPolicyHandle handle, int access, Rpc.SidT sid, SamrDomainHandle
domainHandle) : base(handle, access, sid, domainHandle)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;

View File

@@ -18,38 +18,38 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcShareEnum : Srvsvc.ShareEnumAll
{
internal class MsrpcShareInfo1 : SmbShareInfo
{
internal MsrpcShareInfo1(MsrpcShareEnum enclosing, Srvsvc.ShareInfo1 info1)
{
this._enclosing = enclosing;
NetName = info1.Netname;
Type = info1.Type;
Remark = info1.Remark;
}
public class MsrpcShareEnum : Srvsvc.ShareEnumAll
{
internal class MsrpcShareInfo1 : SmbShareInfo
{
internal MsrpcShareInfo1(MsrpcShareEnum enclosing, Srvsvc.ShareInfo1 info1)
{
this._enclosing = enclosing;
NetName = info1.Netname;
Type = info1.Type;
Remark = info1.Remark;
}
private readonly MsrpcShareEnum _enclosing;
}
private readonly MsrpcShareEnum _enclosing;
}
public MsrpcShareEnum(string server)
: base("\\\\" + server, 1, new Srvsvc.ShareInfoCtr1(), -1, 0, 0)
{
Ptype = 0;
public MsrpcShareEnum(string server) : base("\\\\" + server, 1, new Srvsvc.ShareInfoCtr1
(), -1, 0, 0)
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
public virtual IFileEntry[] GetEntries()
{
Srvsvc.ShareInfoCtr1 ctr = (Srvsvc.ShareInfoCtr1)Info;
MsrpcShareInfo1[] entries = new MsrpcShareInfo1[ctr
.Count];
for (int i = 0; i < ctr.Count; i++)
{
entries[i] = new MsrpcShareInfo1(this, ctr.Array[i]);
}
return entries;
}
}
public virtual IFileEntry[] GetEntries()
{
Srvsvc.ShareInfoCtr1 ctr = (Srvsvc.ShareInfoCtr1)Info;
MsrpcShareInfo1[] entries = new MsrpcShareInfo1[ctr
.Count];
for (int i = 0; i < ctr.Count; i++)
{
entries[i] = new MsrpcShareInfo1(this, ctr.Array[i]);
}
return entries;
}
}
}

View File

@@ -18,26 +18,26 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class MsrpcShareGetInfo : Srvsvc.ShareGetInfo
{
public MsrpcShareGetInfo(string server, string sharename)
: base(server, sharename, 502, new Srvsvc.ShareInfo502())
{
Ptype = 0;
public class MsrpcShareGetInfo : Srvsvc.ShareGetInfo
{
public MsrpcShareGetInfo(string server, string sharename) : base(server, sharename
, 502, new Srvsvc.ShareInfo502())
{
Ptype = 0;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual Ace[] GetSecurity()
{
Srvsvc.ShareInfo502 info502 = (Srvsvc.ShareInfo502)Info;
if (info502.SecurityDescriptor != null)
{
SecurityDescriptor sd;
sd = new SecurityDescriptor(info502.SecurityDescriptor, 0, info502.SdSize);
return sd.Aces;
}
return null;
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual Ace[] GetSecurity()
{
Srvsvc.ShareInfo502 info502 = (Srvsvc.ShareInfo502)Info;
if (info502.SecurityDescriptor != null)
{
SecurityDescriptor sd;
sd = new SecurityDescriptor(info502.SecurityDescriptor, 0, info502.SdSize);
return sd.Aces;
}
return null;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -18,25 +18,23 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class SamrAliasHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrAliasHandle(DcerpcHandle handle,
SamrDomainHandle domainHandle,
int access,
int rid)
{
MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
public class SamrAliasHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrAliasHandle(DcerpcHandle handle, SamrDomainHandle domainHandle, int access
, int rid)
{
MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
}

View File

@@ -18,25 +18,24 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
public class SamrDomainHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrDomainHandle(DcerpcHandle handle,
SamrPolicyHandle policyHandle,
int access,
Rpc.SidT sid)
{
MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
public class SamrDomainHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrDomainHandle(DcerpcHandle handle, SamrPolicyHandle policyHandle, int access
, Rpc.SidT sid)
{
MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this
);
handle.Sendrecv(rpc);
if (rpc.Retval != 0)
{
throw new SmbException(rpc.Retval, false);
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
}

View File

@@ -16,34 +16,34 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Msrpc
{
public class SamrPolicyHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrPolicyHandle(DcerpcHandle handle, string server, int access)
{
if (server == null)
{
server = "\\\\";
}
MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this);
try
{
handle.Sendrecv(rpc);
}
catch (DcerpcException de)
{
if (de.GetErrorCode() != DcerpcError.DcerpcFaultOpRngError)
{
throw;
}
MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this);
handle.Sendrecv(rpc2);
}
}
public class SamrPolicyHandle : Rpc.PolicyHandle
{
/// <exception cref="System.IO.IOException"></exception>
public SamrPolicyHandle(DcerpcHandle handle, string server, int access)
{
if (server == null)
{
server = "\\\\";
}
MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this);
try
{
handle.Sendrecv(rpc);
}
catch (DcerpcException de)
{
if (de.GetErrorCode() != DcerpcError.DcerpcFaultOpRngError)
{
throw;
}
MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this);
handle.Sendrecv(rpc2);
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
/// <exception cref="System.IO.IOException"></exception>
public virtual void Close()
{
}
}
}

File diff suppressed because it is too large Load Diff