Skip to content

Commit

Permalink
Add ReverseDNSLookup in SnaffCon.cs to fix SnaffCon#161 for named tar…
Browse files Browse the repository at this point in the history
…get IPs

Reference: SnaffCon#161
  • Loading branch information
cmprmsd authored Oct 25, 2024
1 parent ba95a9f commit 4377df2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions SnaffCore/SnaffCon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,33 @@ private void ShareDiscovery(string[] computerTargets)
// skip any that are in the exclusion list
continue;
}
// Reverse DNS lookup
var computerName = "";
try
{
Mq.Trace("Performing reverse lookup for " + computer);
IPHostEntry result = Dns.GetHostEntry(computer);
computerName = result.HostName;
Mq.Trace("Got DNSName " + computerName + " for " + computer);
}
catch (Exception e)
{
Mq.Degub(e.Message);
// Keep IP if Reverse Lookup fails
computerName = computer;
}
// ShareFinder Task Creation - this kicks off the rest of the flow
Mq.Trace("Creating a ShareFinder task for " + computer);
Mq.Trace("Creating a ShareFinder task for " + computerName);
ShareTaskScheduler.New(() =>
{
try
{
ShareFinder shareFinder = new ShareFinder();
shareFinder.GetComputerShares(computer);
shareFinder.GetComputerShares(computerName);
}
catch (Exception e)
{
Mq.Error("Exception in ShareFinder task for host " + computer);
Mq.Error("Exception in ShareFinder task for host " + computerName);
Mq.Error(e.ToString());
}
});
Expand Down

0 comments on commit 4377df2

Please sign in to comment.