├── SharpGetTitle ├── bin │ ├── Debug │ │ ├── result.txt │ │ ├── SharpGetTitle.exe │ │ ├── SharpGetTitle.pdb │ │ └── SharpGetTitle.exe.config │ └── Release │ │ ├── SharpGetTitle.exe │ │ ├── SharpGetTitle.pdb │ │ └── SharpGetTitle.exe.config ├── obj │ ├── Debug │ │ ├── SharpGetTitle.csproj.CoreCompileInputs.cache │ │ ├── SharpGetTitle.exe │ │ ├── SharpGetTitle.pdb │ │ ├── SharpGetTitle.csprojAssemblyReference.cache │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── SharpGetTitle.csproj.FileListAbsolute.txt │ └── Release │ │ ├── SharpGetTitle.csproj.CoreCompileInputs.cache │ │ ├── SharpGetTitle.exe │ │ ├── SharpGetTitle.pdb │ │ ├── DesignTimeResolveAssemblyReferences.cache │ │ ├── SharpGetTitle.csprojAssemblyReference.cache │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── SharpGetTitle.csproj.FileListAbsolute.txt ├── app.config ├── SharpGetTitle.csproj.user ├── Properties │ └── AssemblyInfo.cs ├── CommandLineArgumentParser.cs ├── CommandLineArgument.cs ├── SharpGetTitle.csproj ├── ip_cidr.cs ├── Util.cs └── Program.cs ├── images └── Xnip2020-11-26_14-58-15.jpg ├── README.md └── SharpGetTitle.sln /SharpGetTitle/bin/Debug/result.txt: -------------------------------------------------------------------------------- 1 | http://39.100.93.20:80 [200] [nginx] [后台管理系统] 2 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/SharpGetTitle.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 5a90ef19aa29c67bf0d6b044ec2267a5ad5cf245 2 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/SharpGetTitle.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 29da9ef86401fc34dad0db2e16710b654d7c4383 2 | -------------------------------------------------------------------------------- /images/Xnip2020-11-26_14-58-15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/images/Xnip2020-11-26_14-58-15.jpg -------------------------------------------------------------------------------- /SharpGetTitle/bin/Debug/SharpGetTitle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/bin/Debug/SharpGetTitle.exe -------------------------------------------------------------------------------- /SharpGetTitle/bin/Debug/SharpGetTitle.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/bin/Debug/SharpGetTitle.pdb -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/SharpGetTitle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Debug/SharpGetTitle.exe -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/SharpGetTitle.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Debug/SharpGetTitle.pdb -------------------------------------------------------------------------------- /SharpGetTitle/bin/Release/SharpGetTitle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/bin/Release/SharpGetTitle.exe -------------------------------------------------------------------------------- /SharpGetTitle/bin/Release/SharpGetTitle.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/bin/Release/SharpGetTitle.pdb -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/SharpGetTitle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Release/SharpGetTitle.exe -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/SharpGetTitle.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Release/SharpGetTitle.pdb -------------------------------------------------------------------------------- /SharpGetTitle/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/SharpGetTitle.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Debug/SharpGetTitle.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Release/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /SharpGetTitle/bin/Debug/SharpGetTitle.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SharpGetTitle/bin/Release/SharpGetTitle.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/SharpGetTitle.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Release/SharpGetTitle.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ch1ngg/SharpGetTitle/HEAD/SharpGetTitle/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /SharpGetTitle/SharpGetTitle.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -i 39.100.93.20 -p 80 -v 5 | 6 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Debug/SharpGetTitle.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Debug\SharpGetTitle.exe.config 2 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Debug\SharpGetTitle.exe 3 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Debug\SharpGetTitle.pdb 4 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Debug\SharpGetTitle.csproj.CoreCompileInputs.cache 5 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Debug\SharpGetTitle.exe 6 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Debug\SharpGetTitle.pdb 7 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Debug\SharpGetTitle.csprojAssemblyReference.cache 8 | -------------------------------------------------------------------------------- /SharpGetTitle/obj/Release/SharpGetTitle.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Release\SharpGetTitle.exe.config 2 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Release\SharpGetTitle.exe 3 | F:\ws\SharpGetTitle\SharpGetTitle\bin\Release\SharpGetTitle.pdb 4 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Release\SharpGetTitle.csproj.CoreCompileInputs.cache 5 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Release\SharpGetTitle.exe 6 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Release\SharpGetTitle.pdb 7 | F:\ws\SharpGetTitle\SharpGetTitle\obj\Release\SharpGetTitle.csprojAssemblyReference.cache 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SharpGetTitle 2 | SharpGetTitle - 基于 C# 的多线程 Web Title 扫描器 3 | 4 | # 简介 5 | 由于在平时内网渗透中需要获取 C/B 段的 Web 信息,从而更加准确的进行定点渗透,所以基于 SharpWebScan 开发了此工具。此工具使用了 ThreadPool 作为多线程进行并发,并将编译环境降至 .NET 3.5,以便在 CobaltStrike 或者一些较旧的机器上运行。 6 | 7 | # 使用 8 | CommandLine: 9 | ``` 10 | SharpGetTitle.exe -i 127.0.0.1 11 | SharpGetTitle.exe -i 127.0.0.1 -v 12 | SharpGetTitle.exe -i 127.0.0.1 -p 80-443 13 | SharpGetTitle.exe -i 127.0.0.1/24 -p 80-443 14 | SharpGetTitle.exe -i 127.0.0.1/24 -p 80-443 -t 200 15 | SharpGetTitle.exe -i 127.0.0.1-127.0.0.255 -p 80,443,8080 -o demo.txt 16 | ``` 17 | Run in Cobaltstrike: 18 | ``` 19 | execute-assembly SharpGetTitle "-i 127.0.0.1 -p 80" 20 | ``` 21 | -v 参数的含义请看下图 22 | 23 | ![](./images/Xnip2020-11-26_14-58-15.jpg) 24 | 25 | # 感谢 26 | https://github.com/RcoIl/CSharp-Tools/tree/master/SharpWebScan 27 | 28 | # 注意 29 | > 该项目仅供合法的渗透测试以及爱好者参考学习,请勿用于非法用途,否则自行承担相关责任! 30 | -------------------------------------------------------------------------------- /SharpGetTitle/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("SharpGetTitle")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SharpGetTitle")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("f5b81d60-6d42-4d55-9bd4-8613d7b5415f")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpGetTitle/CommandLineArgumentParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpGetTitle 7 | { 8 | public class CommandLineArgumentParser 9 | { 10 | 11 | List _arguments; 12 | public static CommandLineArgumentParser Parse(string[] args) 13 | { 14 | return new CommandLineArgumentParser(args); 15 | } 16 | 17 | public CommandLineArgumentParser(string[] args) 18 | { 19 | _arguments = new List(); 20 | 21 | for (int i = 0; i < args.Length; i++) 22 | { 23 | _arguments.Add(new CommandLineArgument(_arguments, i, args[i])); 24 | } 25 | 26 | } 27 | 28 | public CommandLineArgument Get(string argumentName) 29 | { 30 | return _arguments.FirstOrDefault(p => p == argumentName); 31 | } 32 | 33 | public bool Has(string argumentName) 34 | { 35 | return _arguments.Count(p => p == argumentName) > 0; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /SharpGetTitle.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30128.74 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpGetTitle", "SharpGetTitle\SharpGetTitle.csproj", "{F5B81D60-6D42-4D55-9BD4-8613D7B5415F}" 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 | {F5B81D60-6D42-4D55-9BD4-8613D7B5415F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F5B81D60-6D42-4D55-9BD4-8613D7B5415F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F5B81D60-6D42-4D55-9BD4-8613D7B5415F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F5B81D60-6D42-4D55-9BD4-8613D7B5415F}.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 = {EC60202A-E734-4980-B0C4-BACCE3175517} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /SharpGetTitle/CommandLineArgument.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpGetTitle 7 | { 8 | public class CommandLineArgument 9 | { 10 | List _arguments; 11 | 12 | int _index; 13 | 14 | string _argumentText; 15 | 16 | public CommandLineArgument Next 17 | { 18 | get 19 | { 20 | if (_index < _arguments.Count - 1) 21 | { 22 | return _arguments[_index + 1]; 23 | } 24 | 25 | return null; 26 | } 27 | } 28 | public CommandLineArgument Previous 29 | { 30 | get 31 | { 32 | if (_index > 0) 33 | { 34 | return _arguments[_index - 1]; 35 | } 36 | 37 | return null; 38 | } 39 | } 40 | internal CommandLineArgument(List args, int index, string argument) 41 | { 42 | _arguments = args; 43 | _index = index; 44 | _argumentText = argument; 45 | } 46 | 47 | public CommandLineArgument Take() 48 | { 49 | return Next; 50 | } 51 | 52 | public IEnumerable Take(int count) 53 | { 54 | var list = new List(); 55 | var parent = this; 56 | for (int i = 0; i < count; i++) 57 | { 58 | var next = parent.Next; 59 | if (next == null) 60 | break; 61 | 62 | list.Add(next); 63 | 64 | parent = next; 65 | } 66 | 67 | return list; 68 | } 69 | 70 | public static implicit operator string(CommandLineArgument argument) 71 | { 72 | return argument._argumentText; 73 | } 74 | 75 | public override string ToString() 76 | { 77 | return _argumentText; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /SharpGetTitle/SharpGetTitle.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F5B81D60-6D42-4D55-9BD4-8613D7B5415F} 8 | Exe 9 | SharpGetTitle 10 | SharpGetTitle 11 | v3.5 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 | -------------------------------------------------------------------------------- /SharpGetTitle/ip_cidr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | 6 | namespace SharpGetTitle 7 | { 8 | class ip_cidr 9 | { 10 | public static List Get_ipAddr(String iip) 11 | { 12 | string[] sip = iip.Split(new char[] { '/' }); 13 | IPAddress ip = IPAddress.Parse(sip[0]); 14 | int bits = Convert.ToInt32(sip[1]); 15 | uint mask = ~(uint.MaxValue >> bits); 16 | // Convert the IP address to bytes. 17 | byte[] ipBytes = ip.GetAddressBytes(); 18 | 19 | // BitConverter gives bytes in opposite order to GetAddressBytes(). 20 | byte[] maskBytes = BitConverter.GetBytes(mask).Reverse().ToArray(); 21 | 22 | byte[] startIPBytes = new byte[ipBytes.Length]; 23 | byte[] endIPBytes = new byte[ipBytes.Length]; 24 | 25 | // Calculate the bytes of the start and end IP addresses. 26 | for (int i = 0; i < ipBytes.Length; i++) 27 | { 28 | startIPBytes[i] = (byte)(ipBytes[i] & maskBytes[i]); 29 | endIPBytes[i] = (byte)(ipBytes[i] | ~maskBytes[i]); 30 | } 31 | 32 | // Convert the bytes to IP addresses. 33 | IPAddress startIP = new IPAddress(startIPBytes); 34 | IPAddress endIP = new IPAddress(endIPBytes); 35 | string startip = Convert.ToString(startIP); 36 | string lip = Convert.ToString(endIP); 37 | List list = Get_CIDR(startip, lip); 38 | /*for (int i = 0; i < list.Count; i++) 39 | { 40 | Console.WriteLine("Ip: {0} ", list[i]); 41 | }*/ 42 | return list; 43 | } 44 | 45 | public static List Get_CIDR(string startIP, string lastIp) 46 | { 47 | string sip = Convert.ToString(startIP); 48 | string lip = Convert.ToString(lastIp); 49 | uint iStartip = ipTint(sip); 50 | uint iEndIp = ipTint(lip); 51 | //StringBuilder ip_result = new StringBuilder(); 52 | List ip_result = new List(); 53 | if (iEndIp >= iStartip) 54 | { 55 | for (uint ip = iStartip; ip <= iEndIp; ip++) 56 | { 57 | ip_result.Add(intTip(ip)); 58 | } 59 | 60 | } 61 | else 62 | { 63 | Console.WriteLine("error"); 64 | } 65 | return ip_result; 66 | } 67 | public static uint ipTint(string ipStr) 68 | { 69 | string[] ip = ipStr.Split('.'); 70 | uint ipcode = 0xFFFFFF00 | byte.Parse(ip[3]); 71 | ipcode = ipcode & 0xFFFF00FF | (uint.Parse(ip[2]) << 0x8); 72 | ipcode = ipcode & 0xFF00FFFF | (uint.Parse(ip[1]) << 0xF); 73 | ipcode = ipcode & 0x00FFFFFF | (uint.Parse(ip[0]) << 0x18); 74 | return ipcode; 75 | } 76 | public static string intTip(uint ipcode) 77 | { 78 | byte a = (byte)((ipcode & 0xFF000000) >> 0x18); 79 | byte b = (byte)((ipcode & 0x00FF0000) >> 0xF); 80 | byte c = (byte)((ipcode & 0x0000FF00) >> 0x8); 81 | byte d = (byte)(ipcode & 0x000000FF); 82 | string ipStr = string.Format("{0}.{1}.{2}.{3}", a, b, c, d); 83 | return ipStr; 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /SharpGetTitle/Util.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace SharpGetTitle 7 | { 8 | class Util 9 | { 10 | public static List GetLiveIP(string startIP, string endIP) 11 | { 12 | List result = new List(); 13 | var ipArray = startIP.Split('.'); 14 | int A1 = int.Parse(ipArray[0]); 15 | int A2 = int.Parse(ipArray[1]); 16 | int A3 = int.Parse(ipArray[2]); 17 | int A4 = int.Parse(ipArray[3]); 18 | 19 | int i = 0; 20 | while (i == 0) 21 | { 22 | 23 | string item = string.Empty; 24 | if (A4 != 255) 25 | { 26 | if (A4 == 0) 27 | { 28 | A4++; 29 | continue; 30 | } 31 | item = A1 + "." + A2 + "." + A3 + "." + A4; 32 | A4++; 33 | result.Add(item); 34 | } 35 | 36 | if (A4 == 255) 37 | { 38 | A3++; 39 | A4 = 0; 40 | } 41 | else if (A3 == 255) 42 | { 43 | A2++; 44 | A3 = 0; 45 | } 46 | else if (A2 == 255) 47 | { 48 | A1++; 49 | } 50 | 51 | if (item == endIP) 52 | { 53 | i = 1; 54 | } 55 | } 56 | 57 | return result; 58 | } 59 | 60 | public static List parsePort(String ports) 61 | { 62 | 63 | List allports = new List(); 64 | if (!ports.Contains(",") && !ports.Contains("-")) 65 | { 66 | allports.Add(ports); 67 | return allports; 68 | } 69 | else if(!ports.Contains(",") && ports.Contains("-")) 70 | { 71 | string[] p = ports.Split(new char[] { '-' }); 72 | for (int i = Convert.ToInt32(p[0]); i <= Convert.ToInt32(p[1]); i++) 73 | { 74 | allports.Add(Convert.ToString(i)); 75 | } 76 | return allports; 77 | } 78 | else 79 | { 80 | string[] port = ports.Split(new char[] { ',' }); 81 | foreach (var item in port) 82 | { 83 | if (item.Contains("-")) 84 | { 85 | string[] p = item.Split(new char[] { '-' }); 86 | for (int i = Convert.ToInt32(p[0]); i <= Convert.ToInt32(p[1]); i++) 87 | { 88 | allports.Add(Convert.ToString(i)); 89 | } 90 | continue; 91 | } 92 | allports.Add(Convert.ToString(item)); 93 | } 94 | } 95 | return allports; 96 | } 97 | public static bool regexAll(string string_0) 98 | { 99 | Regex regex = new Regex("^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$"); 100 | return regex.IsMatch(string_0); 101 | } 102 | public static bool regexAll_1(string string_0) 103 | { 104 | Regex regex = new Regex("^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$"); 105 | return regex.IsMatch(string_0); 106 | } 107 | 108 | public static void writre(string filename,string res) 109 | { 110 | StreamWriter sw = null; 111 | if (!File.Exists(filename)) 112 | { 113 | FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); 114 | sw = new StreamWriter(fs); 115 | sw.WriteLine(res); 116 | //记得要关闭!不然里面没有字! 117 | sw.Close(); 118 | fs.Close(); 119 | } 120 | else 121 | { 122 | sw = File.AppendText(filename); 123 | sw.WriteLine(res); 124 | sw.Close(); 125 | //MessageBox.Show("已经有log文件了!"); 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /SharpGetTitle/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net.Security; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Net; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Threading; 9 | using System.IO; 10 | using System.Linq; 11 | 12 | namespace SharpGetTitle 13 | { 14 | class Program 15 | { 16 | public static AutoResetEvent myEvent = new AutoResetEvent(false); 17 | public static Queue IPQueue = new Queue(); 18 | public static List listPorts = new List(); 19 | public static List listIP = new List(); 20 | public static int count = 0; 21 | public static bool isshow = false; 22 | public static string filename = "result.txt"; 23 | static void Main(string[] args) 24 | { 25 | string ip = ""; 26 | string ports = "80-89,443,7001,7002,8000-9999"; 27 | string threadsnum = "100"; 28 | var arguments = CommandLineArgumentParser.Parse(args); 29 | //help 30 | if (arguments.Has("-h") || args.Length <= 0) 31 | { 32 | help(); 33 | Environment.Exit(0); 34 | } 35 | 36 | //输出详细信息到Console 37 | if (args.Contains("-v")) 38 | { 39 | isshow = true; 40 | } 41 | 42 | //ip处理if 43 | if (arguments.Has("-i")) 44 | { 45 | ip = arguments.Get("-i").Next; 46 | if (ip.Contains("/")) 47 | { 48 | listIP = ip_cidr.Get_ipAddr(ip); 49 | } 50 | else if (ip.Contains("-")) 51 | { 52 | string[] p = ip.Split(new char[] { '-' }); 53 | listIP = Util.GetLiveIP(p[0], p[1]); 54 | } 55 | else 56 | { 57 | listIP.Add(ip); 58 | } 59 | } 60 | else 61 | { 62 | Console.WriteLine("-i is null !"); 63 | Environment.Exit(0); 64 | } 65 | 66 | //端口处理if 67 | if (arguments.Has("-p")) 68 | { 69 | ports = arguments.Get("-p").Next; 70 | listPorts = Util.parsePort(ports); 71 | } 72 | 73 | //输出文件处理if 74 | if (arguments.Has("-o")) 75 | { 76 | filename = arguments.Get("-o").Next; 77 | } 78 | 79 | //线程处理if 80 | if (arguments.Has("-t")) 81 | { 82 | threadsnum = arguments.Get("-t").Next; 83 | } 84 | 85 | 86 | //拼接 ip:port 87 | for (int i = 0; i < listIP.Count; i++) 88 | { 89 | for (int t = 0; t < listPorts.Count; t++) 90 | { 91 | IPQueue.Enqueue(listIP[i] + ":" + listPorts[t]); 92 | } 93 | } 94 | //设置最高和最低线程,数值是 -t 95 | ThreadPool.SetMinThreads(Convert.ToInt32(threadsnum), Convert.ToInt32(threadsnum)); 96 | ThreadPool.SetMaxThreads(Convert.ToInt32(threadsnum), Convert.ToInt32(threadsnum)); 97 | count = IPQueue.Count; 98 | 99 | for (int i = 1; i <= count; i++) 100 | { 101 | ThreadPool.QueueUserWorkItem(new WaitCallback(GetAll), IPQueue.Dequeue()); 102 | } 103 | Console.WriteLine("[*] {0} Start !", DateTime.Now.ToString()); 104 | while (true) 105 | { 106 | if (count == 0)//监听 count 是否为0,0为结束。 107 | { 108 | myEvent.Set(); 109 | break; 110 | } 111 | } 112 | myEvent.WaitOne(); 113 | Console.WriteLine("[*] {0} Done !", DateTime.Now.ToString()); 114 | //Console.ReadKey(); 115 | 116 | } 117 | public static void GetAll(object obj) 118 | { 119 | string url = ""; 120 | if (obj.ToString().Contains(":443")) 121 | { 122 | url = String.Format("https://{0}", obj.ToString().Replace(":443", "")); 123 | } 124 | else 125 | { 126 | url = String.Format("http://{0}", obj.ToString()); 127 | } 128 | String regex = @".+"; 129 | GC.Collect(); 130 | HttpWebRequest req = null; 131 | HttpWebResponse res = null; 132 | try 133 | { 134 | 135 | ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); 136 | ServicePointManager.DefaultConnectionLimit = 500; 137 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; 138 | req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); 139 | req.Method = "GET"; 140 | req.Timeout = 1000; 141 | req.Proxy = null; 142 | req.AllowWriteStreamBuffering = false; 143 | req.ServicePoint.UseNagleAlgorithm = false; 144 | res = (HttpWebResponse)req.GetResponse(); 145 | Stream myResponseStream = res.GetResponseStream(); 146 | StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8); 147 | string retString = myStreamReader.ReadToEnd(); 148 | String title = Regex.Match(retString, regex).ToString(); 149 | title = Regex.Replace(title, @"", ""); 150 | title = Regex.Replace(title, @"", ""); 151 | if (isshow) 152 | { 153 | Console.WriteLine("{0} [{1}] [{2}] [{3}]", url, Convert.ToInt32(res.StatusCode), res.Server, title); 154 | } 155 | Util.writre(filename,String.Format("{0} [{1}] [{2}] [{3}]", url, Convert.ToInt32(res.StatusCode), res.Server, title)); 156 | count -= 1;//用来统计线程数线程是否执行 157 | res.Close(); 158 | } 159 | catch (WebException ex) 160 | { 161 | 162 | if (ex.Response == null) 163 | { 164 | count -= 1;//用来统计线程数线程是否执行 165 | return; 166 | } 167 | res = (HttpWebResponse) ex.Response; 168 | StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8); 169 | string retString = sr.ReadToEnd(); 170 | String title = Regex.Match(retString, regex).ToString(); 171 | title = Regex.Replace(title, @"", ""); 172 | title = Regex.Replace(title, @"", ""); 173 | if (isshow) 174 | { 175 | Console.WriteLine("{0} [{1}] [{2}] [{3}]", url, Convert.ToInt32(res.StatusCode), res.Server, title); 176 | } 177 | Util.writre(filename, String.Format("{0} [{1}] [{2}] [{3}]", url, Convert.ToInt32(res.StatusCode), res.Server, title)); 178 | count -= 1;//用来统计线程数线程是否执行 179 | } 180 | } 181 | public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) 182 | { // 总是接受 183 | return true; 184 | } 185 | 186 | public static void help() 187 | { 188 | Console.WriteLine("SharpGetTitle V1.1"); 189 | Console.WriteLine("-h help Print help"); 190 | Console.WriteLine("-i ip Input IP. eg:127.0.0.1|127.0.0.1-127.0.0.22|127.0.0.1/24"); 191 | Console.WriteLine("-p ports Scanner ports. default:80-89,443,7001,7002,8000-9999"); 192 | Console.WriteLine("-t thread Threads. default:100"); 193 | Console.WriteLine("-o outfile Output result to file. default:result.txt"); 194 | Console.WriteLine("-v infomations Show Runlog"); 195 | Console.WriteLine(""); 196 | Console.WriteLine("Run in Cobaltstrike:"); 197 | Console.WriteLine("execute-assembly SharpGetTitle \"-i 127.0.0.1 -p 80\""); 198 | } 199 | } 200 | } 201 | --------------------------------------------------------------------------------