Skip to content

Commit

Permalink
Merge pull request #122 from hkelley/dfsv2-sharenamefix
Browse files Browse the repository at this point in the history
Dfsv2 sharenamefix
  • Loading branch information
l0ss authored Jun 21, 2023
2 parents d5b73eb + 66f969e commit ac037a4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions SnaffCore/ActiveDirectory/DfsFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private List<DFSShare> Get_DomainDFSShareV2(DirectorySearch _directorySearch)

var target_list = resEnt.GetPropertyAsBytes(@"msdfs-targetlistv2");
var xml = new XmlDocument();
string thing = System.Text.Encoding.Unicode.GetString(target_list.Skip(2).Take(target_list.Length - 1 + 1 - 2).ToArray());
//string thing = System.Text.Encoding.Unicode.GetString(target_list.Skip(2).Take(target_list.Length - 1 + 1 - 2).ToArray());
xml.LoadXml(System.Text.Encoding.Unicode.GetString(target_list.Skip(2).Take(target_list.Length - 1 + 1 - 2).ToArray()));

if (xml.FirstChild != null)
Expand All @@ -126,12 +126,18 @@ private List<DFSShare> Get_DomainDFSShareV2(DirectorySearch _directorySearch)
{
try
{
var Target = node.InnerText;
var Target = babbynode.InnerText;
if (Target.Contains(@"\"))
{
var DFSroot = Target.Split('\\')[3];
string ShareName = resEnt.GetProperty(@"msdfs-linkpathv2").Replace("/","\\");
DFSShares.Add(new DFSShare { Name = $@"{DFSroot}{ShareName}", RemoteServerName = Target.Split('\\')[2], DFSNamespace = dfsnamespace });
var DFSroot = Target.Split('\\')[3];
string ShareName = resEnt.GetProperty(@"msdfs-linkpathv2").Replace("/","\\");

// FIX DFS V2 shares have the share name in the DFSroot, don't double-up
DFSShares.Add(new DFSShare {
Name = $@"{DFSroot}",
RemoteServerName = Target.Split('\\')[2],
DFSNamespace = dfsnamespace }
);
}
}
catch (Exception e)
Expand Down

0 comments on commit ac037a4

Please sign in to comment.