├── .DS_Store ├── .gitattributes ├── QueryDC.cs ├── bin ├── .DS_Store └── Release │ ├── SharpSniper.exe │ ├── SharpSniper.pdb │ ├── .vs │ └── SharpSniper │ │ └── v16 │ │ └── .suo │ └── SharpSniper.exe.config ├── obj ├── Debug │ ├── SharpSniper.csproj.CoreCompileInputs.cache │ ├── SharpSniper.exe │ ├── SharpSniper.pdb │ ├── SharpSniper.csprojAssemblyReference.cache │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ └── SharpSniper.csproj.FileListAbsolute.txt └── Release │ ├── SharpSniper.csproj.CoreCompileInputs.cache │ ├── SharpSniper.exe │ ├── SharpSniper.pdb │ ├── .NETFramework,Version=v4.0.AssemblyAttributes.cs │ └── SharpSniper.csproj.FileListAbsolute.txt ├── .vs └── SharpSniper │ └── v16 │ ├── .suo │ └── Server │ └── sqlite3 │ ├── storage.ide │ ├── storage.ide-shm │ └── storage.ide-wal ├── app.config ├── README.md ├── SharpSniper.sln ├── Properties └── AssemblyInfo.cs ├── GetDomain.cs ├── Program.cs └── SharpSniper.csproj /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /QueryDC.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/QueryDC.cs -------------------------------------------------------------------------------- /bin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/bin/.DS_Store -------------------------------------------------------------------------------- /obj/Debug/SharpSniper.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 8d04856903599688273e6731202a051f84bf5f43 2 | -------------------------------------------------------------------------------- /obj/Release/SharpSniper.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 81b86c008c8c285d0053db55b61987fca7a9eae3 2 | -------------------------------------------------------------------------------- /.vs/SharpSniper/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/.vs/SharpSniper/v16/.suo -------------------------------------------------------------------------------- /bin/Release/SharpSniper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/bin/Release/SharpSniper.exe -------------------------------------------------------------------------------- /bin/Release/SharpSniper.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/bin/Release/SharpSniper.pdb -------------------------------------------------------------------------------- /obj/Debug/SharpSniper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Debug/SharpSniper.exe -------------------------------------------------------------------------------- /obj/Debug/SharpSniper.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Debug/SharpSniper.pdb -------------------------------------------------------------------------------- /obj/Release/SharpSniper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Release/SharpSniper.exe -------------------------------------------------------------------------------- /obj/Release/SharpSniper.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Release/SharpSniper.pdb -------------------------------------------------------------------------------- /bin/Release/.vs/SharpSniper/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/bin/Release/.vs/SharpSniper/v16/.suo -------------------------------------------------------------------------------- /.vs/SharpSniper/v16/Server/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/.vs/SharpSniper/v16/Server/sqlite3/storage.ide -------------------------------------------------------------------------------- /.vs/SharpSniper/v16/Server/sqlite3/storage.ide-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/.vs/SharpSniper/v16/Server/sqlite3/storage.ide-shm -------------------------------------------------------------------------------- /.vs/SharpSniper/v16/Server/sqlite3/storage.ide-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/.vs/SharpSniper/v16/Server/sqlite3/storage.ide-wal -------------------------------------------------------------------------------- /obj/Debug/SharpSniper.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Debug/SharpSniper.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jumbo-WJB/SharpSniper-Modify/HEAD/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bin/Release/SharpSniper.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /obj/Release/.NETFramework,Version=v4.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")] 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SharpSniper-Modify 2 | 3 | 修改[SharpSniper](https://github.com/HunnicCyber/SharpSniper),原项目不能指定查询的IP、不能指定查询天数且只显示最后一条数据,该项目对其修改使其支持上述三个方法。 4 | 5 | ## usage 6 | 7 | ``` 8 | SharpSniper.exe domain_name Remote_IP DAUSER DAPASSWORD TARGET_USERNAME SEARCH_DAY 9 | ``` 10 | -------------------------------------------------------------------------------- /obj/Debug/SharpSniper.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\tomka\source\repos\SharpSniper\bin\Debug\SharpSniper.exe 2 | C:\Users\tomka\source\repos\SharpSniper\bin\Debug\SharpSniper.pdb 3 | C:\Users\tomka\source\repos\SharpSniper\obj\Debug\SharpSniper.csprojAssemblyReference.cache 4 | C:\Users\tomka\source\repos\SharpSniper\obj\Debug\SharpSniper.csproj.CoreCompileInputs.cache 5 | C:\Users\tomka\source\repos\SharpSniper\obj\Debug\SharpSniper.exe 6 | C:\Users\tomka\source\repos\SharpSniper\obj\Debug\SharpSniper.pdb 7 | C:\Users\tomka\source\repos\SharpSniper\bin\Debug\SharpSniper.exe.config 8 | -------------------------------------------------------------------------------- /obj/Release/SharpSniper.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\tomka\source\repos\SharpSniper\obj\Release\SharpSniper.csprojAssemblyReference.cache 2 | C:\Users\tomka\source\repos\SharpSniper\obj\Release\SharpSniper.csproj.CoreCompileInputs.cache 3 | C:\Users\tomka\source\repos\SharpSniper\bin\Release\SharpSniper.exe.config 4 | C:\Users\tomka\source\repos\SharpSniper\bin\Release\SharpSniper.exe 5 | C:\Users\tomka\source\repos\SharpSniper\bin\Release\SharpSniper.pdb 6 | C:\Users\tomka\source\repos\SharpSniper\obj\Release\SharpSniper.exe 7 | C:\Users\tomka\source\repos\SharpSniper\obj\Release\SharpSniper.pdb 8 | C:\Users\jumbo\Desktop\SharpSniper\bin\Release\SharpSniper.exe.config 9 | C:\Users\jumbo\Desktop\SharpSniper\bin\Release\SharpSniper.exe 10 | C:\Users\jumbo\Desktop\SharpSniper\bin\Release\SharpSniper.pdb 11 | C:\Users\jumbo\Desktop\SharpSniper\obj\Release\SharpSniper.csproj.CoreCompileInputs.cache 12 | C:\Users\jumbo\Desktop\SharpSniper\obj\Release\SharpSniper.exe 13 | C:\Users\jumbo\Desktop\SharpSniper\obj\Release\SharpSniper.pdb 14 | -------------------------------------------------------------------------------- /SharpSniper.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.202 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSniper", "SharpSniper.csproj", "{C8BB840C-04CE-4B60-A734-FAF15ABF7B18}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C8BB840C-04CE-4B60-A734-FAF15ABF7B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C8BB840C-04CE-4B60-A734-FAF15ABF7B18}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C8BB840C-04CE-4B60-A734-FAF15ABF7B18}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C8BB840C-04CE-4B60-A734-FAF15ABF7B18}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {AFFF76C5-3F9E-4D9F-A788-55EC0699D804} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpSniper")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SharpSniper")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c8bb840c-04ce-4b60-a734-faf15abf7b18")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GetDomain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace SharpSniper 5 | { 6 | public static class DomainInformation 7 | { 8 | [DllImport("Netapi32.dll")] 9 | static extern int NetApiBufferFree(IntPtr Buffer); 10 | 11 | [DllImport("Netapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 12 | static extern int NetGetJoinInformation( 13 | string server, 14 | out IntPtr domain, 15 | out NetJoinStatus status); 16 | 17 | // Win32 Result Code Constant 18 | const int ErrorSuccess = 0; 19 | 20 | public enum NetJoinStatus 21 | { 22 | NetSetupUnknownStatus = 0, 23 | NetSetupUnjoined, 24 | NetSetupWorkgroupName, 25 | NetSetupDomainName 26 | } 27 | 28 | // Returns the domain name the computer is joined to, or "" if not joined. 29 | public static string GetDomainOrWorkgroup() 30 | { 31 | int result = 0; 32 | string domain = null; 33 | IntPtr pDomain = IntPtr.Zero; 34 | NetJoinStatus status = NetJoinStatus.NetSetupUnknownStatus; 35 | try 36 | { 37 | result = NetGetJoinInformation(null, out pDomain, out status); 38 | if (result == ErrorSuccess) 39 | switch (status) 40 | { 41 | case NetJoinStatus.NetSetupDomainName: 42 | case NetJoinStatus.NetSetupWorkgroupName: 43 | domain = Marshal.PtrToStringAuto(pDomain); 44 | break; 45 | } 46 | } 47 | finally 48 | { 49 | if (pDomain != IntPtr.Zero) 50 | NetApiBufferFree(pDomain); 51 | } 52 | if (domain == null) domain = ""; 53 | return domain; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.DirectoryServices.ActiveDirectory; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace SharpSniper 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | if (args.Length != 6) 13 | { 14 | System.Console.WriteLine("\r\n\r\nSniper: Find hostname and IP address of specific user (CEO etc) in Domain (requires Domain Admin Rights or DC Event" + 15 | "logs must be readable by your user."); 16 | System.Console.WriteLine("Usage:"); 17 | System.Console.WriteLine("Credentialed Auth: SharpSniper.exe domain_name Remote_IP DAUSER DAPASSWORD TARGET_USERNAME SEARCH_DAY"); 18 | System.Environment.Exit(1); 19 | } 20 | 21 | string domain_name = String.Empty; 22 | string DC_IP = String.Empty; 23 | string dauser = String.Empty; 24 | string dapass = String.Empty; 25 | string targetusername = String.Empty; 26 | int SEARCH_DAY; 27 | 28 | domain_name = args[0]; 29 | DC_IP = args[1]; 30 | dauser = args[2]; 31 | dapass = args[3]; 32 | targetusername = args[4]; 33 | SEARCH_DAY = int.Parse(args[5]); 34 | // Loop through domain controllers and find hostname of user 35 | string target_hostname = string.Empty; 36 | QueryDC.QueryRemoteComputer(targetusername, domain_name, DC_IP, dauser, dapass, SEARCH_DAY); 37 | /* Console.WriteLine(target_hostname); 38 | if (target_hostname.Contains("something is error")) 39 | { 40 | Console.WriteLine(target_hostname); 41 | } 42 | else 43 | { 44 | Regex ip = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"); 45 | MatchCollection result = ip.Matches(target_hostname); 46 | { 47 | Console.WriteLine("User: " + targetusername + " - " + "IP Address: " + result[0]); 48 | } 49 | } 50 | */ 51 | 52 | 53 | 54 | 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /SharpSniper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C8BB840C-04CE-4B60-A734-FAF15ABF7B18} 8 | Exe 9 | SharpSniper 10 | SharpSniper 11 | v4.0 12 | 512 13 | true 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | --------------------------------------------------------------------------------