From 5a4d3907cdc21a7e4ec7a2a3bccd484fa0152309 Mon Sep 17 00:00:00 2001 From: Sean Kessler Date: Mon, 1 Apr 2024 22:55:24 -0400 Subject: [PATCH] Initial --- IPMonitor.v12.suo | Bin 50688 -> 42496 bytes Socket.cs | 548 ++++++++++++++++++++++++++++++++++++++++++++ UserAgent.cs | 120 ++++++++++ ZoneEditResponse.cs | 78 +++++++ 4 files changed, 746 insertions(+) create mode 100644 Socket.cs create mode 100644 UserAgent.cs create mode 100644 ZoneEditResponse.cs diff --git a/IPMonitor.v12.suo b/IPMonitor.v12.suo index b8753a624067e69b4ad07436b9f02600e46c175e..00ce3771741941f58a91d423dce6f30902976015 100644 GIT binary patch delta 1974 zcmchYZA@EL7{~9qy>x9U8;;WP(v6aA$lFR0n2fjG4wx{6!6dr)62S}=-GIpL#s%2^_=H9 z&w1&e=RDO%P5Od-u7X)_Rc?}59%afI389U@H5c@M&oU%Q3egF{_sMT+vN9KZ_85P{m52kKluk@ZXPfCuCB3~C_A1&#=+l7M%n4FJBG>{pfX9G{ z%R;{mm?L%)`U;QKG1La@^i&XUC)sYV$ z?7g5G)PRj(A8>#=P!INl25nI69FfYWWsju?E#>1B>%5lc*;h=%>r zSW0eJwz3nB=#!k*T#Q{N|JH@XcLtw&CTryU=Sx*qdvEPTD{tBME2BN`I3A~(n5C|L z?CPBtz9^v<$99*{MC6TVu7wYkyyVK3XaGN#`7`6%)=|YMn-jNYmuRW%J4MJ7JvLrE z2Gt~%OSD>4uZU!dPLfu9z{;XowB}tb{@Tjih!e}AUh@=;RcRf8bY^7FTf~DDNxl}J z1LG?jEobkyh!aFoN9Rb(!MRp=5@Nh8gD>U8%Z96N9pSjY*2H*URRg2yv`V9H&dPRR zt*Ae1yDrx0%*p+QBZ`qyP1W{7c9HxkO;#xvQJel0nbJ%(^%bP2hT~{4)kTS(!)%iL z9+XXS_57H4_BJiSA1*4Q3Pw+4XUN|$WIhSkPckhhpZuFl$yqN``mu5V41(9e5YYL9 za+7SN%_|;Ql<5`~J%RPnQvMJ-PX6?fK(jfp&m4GC4m3G~N906mJEW64*UX1cl`1^c zr?P2vSf=115BCgw8yCExGA5C4WKW#msT)C++@CsVVe$gK!YAk(!?~fWLp$F6+N)G>H`Q8z4a1G}k5!BA z4T(A}(d^ZOJVKin;^2EEPjE3)((*1x#JWONUVT`AQKQR!0WK89A^)vhvW((}eH?VQN z)GReh-BOp-DQV&b5xZH4(j{X~qynR%fR8pmr*r+19!K}DJL#jDHoj~6nu(lhuIq5e zi|zg++Vk4cp6b2c-5#x@SL^N2w9c-Vdg)npJE`t6o2S*^*&}{kB$`(%D0Cf~`9i+~ Dso8R4 delta 2558 zcmb`JZA_C_6vvgqxkU3QaS@4e@~ zoO91P_dfOB5xqTeeQTNiMp2^3^suE{4P9S~zqZ_GuL*+SMT^+Vu3=KFQZ1oAhI`WB z5OwS-JaKNFFiph}BTpEm4j1r}0j65mW~G*y;8S_Yr1qkiendJwT@xcS#kBeOF6z(u zhb%p&Z=<%BSWLtd+yV{pl+;bTsgXrw6R#6FL@tp>EF~O75h~5L{@P?+F?C9a%`<|X zTc|_ZOjl7IH8omSlWaS&gLspeOY9_!#9PGM#BO2_v6rYN_7VGur~O-x2gJ?Xq3{ib?rhSR( z%fyES4(Uy((sWuSYRvG6+3hqKT0lQkP801!2XTh@-?V5VS}w_$;+0>6WAS zK!N7&od*-kxBb%g`?#{zbe#p<>$nC*cK0$c`|a>v+!0YLH2jgM)nUrMNy}BI#Ed~M z@-nM3nKefY6qjkaV|fswOCc9m=)w=nbEj@3o7>niGSM9g6wi$48a2O;pW^Y#Rt9)B zwXt?gZmQ7omzO_d(P`{7Jgchkh9O7eA@PKWsSQ)igh@vmOI19}x>bRUGA%cKUd$@U z&U;}W@<%SZ733wAT0IG3La$SQK!RyJHgAArbB@X>Op$FBY?j0tq{RA8CB|&1i{unZ zlqYNA#6X^`=C6CZ(o){Z6lsB$;d^%>q-&u-^14~G&d)|Hw60lcF88YgM)_ZI&^TKT z;^+B=iq$os+mgo`L=|q< zM<*Zih8nqxj`Q6)kMUxVtWlLsTQ=l15I5xZbTr?s5w<+9y!nv6{blw6m{c zO+0`2NG;4~v*74VLZ~A@u~l#iD})02Ef7kDbg(mNOn~#uN94k@452H|fUg}7uVkX8 z+oXhiO(IV?Du)FtrJ*1sQCkz4T8*GT9~0*uqM>&+2Kq`<`DY|typ9mRd^}~!{CwML zjQ2QSF>G(FKju16e?-oEr!gJDz7%y>q8uDp#PHQ^kQsc94N~EF9EB-%|juUkh)y7dN_0q{t4b#|v%mh*~3*U5KbJ>{^49{rZv18l>+w z;@(iP61eyS!?>7?uHhWiCYbQarM0*}+@v%GgK=a=wxzEA-F==z@?QCHgR9iFB2TVw zlpE`1`Mo0t8nIQ%fMhMBiE9zE8eq8Q9BY?Y!i?L6BKiZ6iQjz7BOy_I9it4zzHI)X z6OiJ|4!c+H5>`<}PSM9-k^J-&K06W}C)6WBx{!;*Jyo!sH!8;7T*kc?@2;1RA3b&u zM+eNQ{4#|LIo&nWjGQ_j-t!WE>`h1H^otegg2dqHTBv;7|CHgU{vF{EQs{6!V3@=I zB@_}dAyY~R${D%7kTIMdEC~!%qi--r@ea|I-yeLHsj$>)#^qopLYJf&=Y1i*fa69( UD6y)se!(9QgGO><4!@Cq0R_Zs%K!iX diff --git a/Socket.cs b/Socket.cs new file mode 100644 index 0000000..665add8 --- /dev/null +++ b/Socket.cs @@ -0,0 +1,548 @@ +using System; +using System.Collections; +using System.Net.Sockets; +using System.Diagnostics; +using System.Net; +using System.IO; +using System.Text; + +// Filename: Socket.cs +// Author:Sean Kessler + +namespace IPMonitor +{ + internal class ContentHeader + { + private String server; + private String date; + private String pragma; + private String connection; + private String contentLength; + private String contentType; + private String cookie; + private String cache; + + public ContentHeader() + { + } + public String Server + { + get { return server; } + set { server = value; } + } + public String Date + { + get { return date; } + set { date = value; } + } + public String Pragma + { + get { return pragma; } + set { pragma = value; } + } + public String Connection + { + get { return connection; } + set { connection = value; } + } + public String ContentLength + { + get { return contentLength; } + set { contentLength = value; } + } + public String ContentType + { + get { return contentType; } + set { contentType = value; } + } + public String Cookie + { + get { return cookie; } + set { cookie = value; } + } + public String Cache + { + get { return cache; } + set { cache = value; } + } + } + public class SocketConnector : TcpClient + { + public SocketConnector(Socket serverSocket) + { + Client = serverSocket; + } + } + public class ServerSocketControl + { + private Socket acceptSocket; + private IPEndPoint ipLocalEndPoint; + + public ServerSocketControl(int port) + { + int index; + acceptSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + acceptSocket.ReceiveTimeout = -1; + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + IPAddress ipAddress = null; + for (index = 0; index < hostEntry.AddressList.Length; index++) + { + if (IPAddress.TryParse(hostEntry.AddressList[index].ToString(), out ipAddress)) + { + switch (ipAddress.AddressFamily) + { + case System.Net.Sockets.AddressFamily.InterNetwork: + break; + case System.Net.Sockets.AddressFamily.InterNetworkV6: + ipAddress = null; + break; + default: + ipAddress = null; + break; + } + if (null != ipAddress) break; + } + } + if (null == ipAddress) throw new Exception("Could not determine IPV4 address."); + ipLocalEndPoint = new IPEndPoint(ipAddress, port); + SocketControl.TraceOut("[ServerSocketControl] Binding to endpoint " + ipLocalEndPoint); + acceptSocket.Bind(ipLocalEndPoint); + SocketControl.TraceOut("[ServerSocketControl] socket bound"); + acceptSocket.Listen(-1); + } + public ServerSocketControl() + { + int index; + acceptSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + acceptSocket.ReceiveTimeout = -1; + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + IPAddress ipAddress = null; + for (index = 0; index < hostEntry.AddressList.Length; index++) + { + if (IPAddress.TryParse(hostEntry.AddressList[index].ToString(), out ipAddress)) + { + switch (ipAddress.AddressFamily) + { + case System.Net.Sockets.AddressFamily.InterNetwork: + break; + case System.Net.Sockets.AddressFamily.InterNetworkV6: + ipAddress = null; + break; + default: + ipAddress = null; + break; + } + if (null != ipAddress) break; + } + } + if (null == ipAddress) throw new Exception("Could not determine IPV4 address."); + ipLocalEndPoint = new IPEndPoint(ipAddress, 0); + SocketControl.TraceOut("[ServerSocketControl] Binding to endpoint " + ipLocalEndPoint); + acceptSocket.Bind(ipLocalEndPoint); + SocketControl.TraceOut("[ServerSocketControl] socket bound"); + acceptSocket.Listen(-1); + ipLocalEndPoint = (IPEndPoint)acceptSocket.LocalEndPoint; + } + public IPEndPoint LocalEndPoint() + { + return ipLocalEndPoint; + } + public IPAddress Address() + { + return ipLocalEndPoint.Address; + } + public int Port() + { + return ipLocalEndPoint.Port; + } + public void Close() + { + if (null == acceptSocket) return; + acceptSocket.Shutdown(SocketShutdown.Both); + acceptSocket.Close(); + acceptSocket = null; + } + public SocketControl Accept() + { + Socket socket = acceptSocket.Accept(); + ipLocalEndPoint = (IPEndPoint)socket.LocalEndPoint; + SocketControl.TraceOut("[ServerSocketControl::Accept] connect accepted on " + ipLocalEndPoint); + SocketConnector socketConnector = new SocketConnector(socket); + return new SocketControl(socketConnector); + } + } + public class SocketControl + { + public const int OkResult = 220; + public const int ErrorResult = 500; + private TcpClient tcpClient; + private NetworkStream networkStream; + private BinaryWriter binaryWriter; + private BinaryReader binaryReader; + + private bool isConnected = false; + + public SocketControl(SocketConnector socketConnector) + { + tcpClient = socketConnector; + tcpClient.LingerState = new LingerOption(false, 0); + tcpClient.ReceiveTimeout = -1; + networkStream = tcpClient.GetStream(); + binaryWriter = new BinaryWriter(networkStream); + binaryReader = new BinaryReader(networkStream); + isConnected = true; + } + public SocketControl(String strHost, int port) + { + tcpClient = new TcpClient(); + tcpClient.Connect(strHost, port); + tcpClient.LingerState = new LingerOption(false, 0); + tcpClient.ReceiveTimeout = -1; + networkStream = tcpClient.GetStream(); + binaryWriter = new BinaryWriter(networkStream); + binaryReader = new BinaryReader(networkStream); + isConnected = true; + } + public void Close() + { + if (!isConnected) return; + isConnected = false; + binaryWriter.Close(); + binaryWriter = null; + binaryReader.Close(); + binaryReader = null; + tcpClient.Close(); + tcpClient = null; + } + public string ReadLine() + { + StringBuilder strLine = new StringBuilder(); + if (!isConnected) return null; + byte[] streamByte = new byte[1]; + while (true) + { + binaryReader.Read(streamByte, 0, 1); + if (13 == streamByte[0]) continue; + else if (10 == streamByte[0]) break; + else if ('\0' == (char)streamByte[0]) break; + strLine.Append((char)streamByte[0]); + streamByte[0] = 0; + } + return strLine.ToString(); + } + public bool WriteLine(string strLine) + { + if (!isConnected || 0 == strLine.Length) return false; + strLine += "\r\n"; + char[] streamData = strLine.ToCharArray(); + binaryWriter.Write(streamData); + binaryWriter.Flush(); + return true; + } + public int GetResultCode(string strLine) + { + if (0 == strLine.Length) return 0; + string strResult = ""; + int strIndex = 0; + while (true) + { + if (strIndex >= 3) break; + if (' ' == strLine[strIndex]) break; + strResult += strLine[strIndex]; + strIndex++; + } + if (0 == strResult.Length) return 0; + return int.Parse(strResult); + } + public string GetResult(string strLine) + { + string strResult = ""; + int strIndex = 0; + int strLength = strLine.Length; + if (0 == strLength) return strResult; + while (' ' != strLine[strIndex] && strIndex < strLength) strIndex++; + strIndex++; + if (strIndex >= strLength) return strResult; + while (strIndex < strLength) + { + strResult += strLine[strIndex]; + strIndex++; + } + return strResult; + } + public char[] GetRequest(string strRequest, int max) + { + if (!isConnected || null == strRequest || 0 == max) return null; + WriteLine("GET " + strRequest); + return Receive(max); + } + public MemoryStream GetRequest(string strRequest) + { + if (!isConnected || null == strRequest) return null; + WriteLine("GET " + strRequest); + return Receive(); + } + public String GetRequestToString(String strRequest) + { + if (!isConnected || null == strRequest) return null; + WriteLine("GET " + strRequest); + MemoryStream memoryStream = Receive(); + memoryStream.Seek(0, SeekOrigin.Begin); + StreamReader streamReader = new StreamReader(memoryStream); + String strResponse = streamReader.ReadToEnd(); + streamReader.Close(); + memoryStream.Close(); + return strResponse; + } + public bool Write(char[] chars) + { + if (!isConnected || null == chars || 0 == chars.Length) return false; + binaryWriter.Write(chars); + binaryWriter.Flush(); + return true; + } + public bool Write(byte[] bytes) + { + if (!isConnected || null == bytes || 0 == bytes.Length) return false; + binaryWriter.Write(bytes); + binaryWriter.Flush(); + return true; + } + public bool Write(byte[] bytes, int length) + { + if (!isConnected || null == bytes || 0 == bytes.Length) return false; + binaryWriter.Write(bytes, 0, length); + binaryWriter.Flush(); + return true; + } + public int ReadInt() + { + char[] chars = new char[4]; + Receive(chars); + return (((byte)chars[3]) << 24) | (((byte)chars[2]) << 16) + (((byte)chars[1]) << 8) + ((byte)chars[0]); + } + public bool IsConnected() + { + return isConnected; + } + public bool Receive(char[] streamChars) + { + byte[] cb; + int count = 0; + int max; + int readCount; + + max = streamChars.Length; + if (!isConnected || 0 == max) return false; + cb = new byte[1]; + while (true) + { + readCount = binaryReader.Read(cb, 0, 1); + if (0 == readCount) break; + streamChars[count++] = (char)cb[0]; + if (count >= max) break; + } + return count == max; + } + public int Receive(ref byte[] streamBytes) + { + int count = 0; + int max; + int readLength = 0; + + max = streamBytes.Length; + if (!isConnected || 0 == max) return count; + while (true) + { + readLength = binaryReader.Read(streamBytes, count, max - count); + if (0 == readLength) break; + count += readLength; + if (count >= max) break; + } + if (0 == count) return count; + byte[] stream = new byte[count]; + Array.Copy(streamBytes, stream, count); + streamBytes = stream; + return count; + } + public char[] Receive(int maxChars) + { + char[] streamChar; + char[] stream; + byte[] cb; + int count = 0; + int readCount = 0; + + if (!isConnected || 0 == maxChars) return null; + streamChar = new char[maxChars]; + while (true) + { + cb = new byte[1]; + readCount = binaryReader.Read(cb, 0, 1); + if (0 == readCount) break; + streamChar[count++] = (char)cb[0]; + if (count >= maxChars) break; + } + stream = new char[count]; + Array.Copy(streamChar, stream, count); + return stream; + } + public MemoryStream Receive() + { + MemoryStream memoryStream = new MemoryStream(); + byte[] cb; + int readCount = 0; + + if (!isConnected) return null; + while (true) + { + cb = new byte[1]; + readCount = binaryReader.Read(cb, 0, 1); + if (0 == readCount) break; + memoryStream.WriteByte(cb[0]); + } + memoryStream.Seek(0, SeekOrigin.Begin); + return memoryStream; + } + public bool Receive(ArrayList receiveStrings, ArrayList responseStrings) + { + bool isInMultiLine = false; + bool returnCode = true; + string seriesItem = ""; + string stringData = ""; + + receiveStrings.Clear(); + if (!isConnected) return false; + while (true) + { + stringData = ReadLine(); + if (null == stringData || 0 == stringData.Length) break; + if (0 == receiveStrings.Count) + { + seriesItem = stringData.Substring(0, 3); + if (!IsInResponse(seriesItem, responseStrings)) + { + returnCode = false; + receiveStrings.Add(stringData); + break; + } + if ('-' == stringData[3]) isInMultiLine = true; + } + if (0 != receiveStrings.Count && isInMultiLine && '-' != stringData[3] && + stringData.Substring(0, 3).Equals(seriesItem)) + { + receiveStrings.Add(stringData); + break; + } + receiveStrings.Add(stringData); + if (!isInMultiLine) break; + } + return returnCode; + } + public bool Receive(ArrayList receiveStrings) + { + bool isInMultiLine = false; + string seriesItem = ""; + string stringData = ""; + + receiveStrings.Clear(); + if (!isConnected) return false; + while (true) + { + stringData = ReadLine(); + if (null == stringData || 0 == stringData.Length) break; + if (0 == receiveStrings.Count) + { + seriesItem = stringData.Substring(0, 3); + try { if ('-' == stringData[3])isInMultiLine = true; } + catch (Exception) { ;} + } + if (0 != receiveStrings.Count && isInMultiLine && '-' != stringData[3] && + stringData.Substring(0, 3).Equals(seriesItem)) + { + receiveStrings.Add(stringData); + break; + } + receiveStrings.Add(stringData); + if (!isInMultiLine) break; + } + if (0 != receiveStrings.Count) return true; + return false; + } + public bool ReceivePage(ArrayList stringArray) + { + string stringData = ""; + int reps = 0; + + stringArray.Clear(); + if (!isConnected) return false; + while (true) + { + stringData = ReadLine(); + if (null == stringData || 0 == stringData.Length) reps++; + else + { + stringArray.Add(stringData); + reps = 0; + } + if (2 == reps) break; + } + return 0 != stringArray.Count ? true : false; + } + public MemoryStream ReceivePage() + { + MemoryStream memoryStream; + ContentHeader contentHeader; + + contentHeader = ReadContentHeader(); + byte[] bytes = new byte[int.Parse(contentHeader.ContentLength)]; + Receive(ref bytes); + memoryStream = new MemoryStream(bytes); + return memoryStream; + } + public bool IsInResponse(string responseString, ArrayList responseStrings) + { + if (0 == responseStrings.Count) return false; + for (int index = 0; index < responseStrings.Count; index++) + { + if (responseString.Equals((string)responseStrings[index])) return true; + } + return false; + } + private ContentHeader ReadContentHeader() + { + ContentHeader contentHeader; + String stringLine; + String token; + String value; + + contentHeader = new ContentHeader(); + while (true) + { + stringLine = ReadLine(); + if (null == stringLine || 0 == stringLine.Length) break; + String[] elements = stringLine.Split(':'); + if (2 != elements.Length) continue; + token = elements[0].Trim().ToUpper(); + value = elements[1].Trim().ToUpper(); + if ("SERVER".Equals(token)) contentHeader.Server = value; + else if ("DATE".Equals(token)) contentHeader.Date = value; + else if ("PRAGMA".Equals(token)) contentHeader.Pragma = value; + else if ("CACHE-CONTROL".Equals(token)) contentHeader.Cache = value; + else if ("CONNECTION".Equals(token)) contentHeader.Connection = value; + else if ("CONTENT-LENGTH".Equals(token)) contentHeader.ContentLength = value; + else if ("CONTENT-TYPE".Equals(token)) contentHeader.ContentType = value; + else if ("SET-COOKIE".Equals(token)) contentHeader.Cookie = value; + } + return contentHeader; + } + [Conditional("TRACENET")] + public static void TraceOut(String strLine) + { + String strThread = "[Thread=" + System.Threading.Thread.CurrentThread.GetHashCode() + "]"; + String strDate = "[" + DateTime.Now.ToString() + "]"; + Trace.WriteLine(strThread + "[]" + strDate + strLine); + } + } +} + diff --git a/UserAgent.cs b/UserAgent.cs new file mode 100644 index 0000000..5eac91b --- /dev/null +++ b/UserAgent.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPMonitor +{ + public class UserAgent + { + private static UserAgent instance=null; + //private bool useVersioning=false; + private String[] userAgents= + { + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.3 24.31", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.1 23.33", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.1 14.12", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.3 13.92", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0. 3.92", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Agency/93.8.2357.5 3.92", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0. 3.92", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.3 3.92", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123. 3.14", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103. 1.57", + "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.3 0.78", + "Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115. 0.78", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Viewer/99.9.8853.8 0.78", + "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115. 0.78", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.3 0.78" + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36", + //"Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36", + //"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko)", + //"Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13G36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36", + //"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98) Internet Explorer 6", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063", + //"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15", + //"Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko", + //"Mozilla/5.0 (Windows NT 5.1; rv:36.0) Gecko/20100101 Firefox/36.0", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko)", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36", + //"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)", + //"Mozilla/5.0 (Windows NT 5.1; rv:33.0) Gecko/20100101 Firefox/33.0", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299", + //"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", + //"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)", + //"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0", + //"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36", + //"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2)", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36", + //"Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1", + //"Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0", + //"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36", + //"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0", + //"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36", + //"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.3 24.31", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.1 23.33", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.1 14.12", + //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.3 13.92", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0. 3.92", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Agency/93.8.2357.5 3.92", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0. 3.92", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.3 3.92", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123. 3.14", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103. 1.57", + //"Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.3 0.78", + //"Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115. 0.78", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Viewer/99.9.8853.8 0.78", + //"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115. 0.78", + //"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.3 0.78" + }; + + private Random random=new Random(); + private UserAgent() + { + } + public static UserAgent GetInstance() + { + lock(typeof(UserAgent)) + { + if(null==instance) instance=new UserAgent(); + return instance; + } + } + public String GetUserAgent() + { + lock(this) + { + double randomNumber=random.NextDouble(); // number between 0 and 1 + int index=(int)(randomNumber*((double)userAgents.Length)); + return userAgents[index]; + } + } + } + +} diff --git a/ZoneEditResponse.cs b/ZoneEditResponse.cs new file mode 100644 index 0000000..710aa98 --- /dev/null +++ b/ZoneEditResponse.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IPMonitor +{ + public class ZoneEditResponses : List + { + public ZoneEditResponses() + { + } + public bool IsSuccess() + { + if(Count==0)return false; + return this.Any(x => x.SuccessCode.Equals("200") || x.SuccessCode.Equals("201")); + } + public override string ToString() + { + StringBuilder sb=new StringBuilder(); + for(int index=0;index\n\n" string + + + public class ZoneEditResponse + { + public String SuccessCode { get; set; } + public String Text { get; set; } + public String Zone { get; set; } + + public ZoneEditResponse() + { + } + public ZoneEditResponse(String successCode, String text, String zone) + { + SuccessCode=successCode; + Text=text; + Zone=zone; + } + public override String ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("SUCCESS CODE=").Append(SuccessCode); + sb.Append(","); + sb.Append("TEXT=").Append(Text); + sb.Append(","); + sb.Append("ZONE=").Append(Zone); + return sb.ToString(); + } + } +}