static void Main(string[] args) { Task.Run(async() => { while (true) { await Task.Delay(new TimeSpan(0, 0, 10)).ConfigureAwait(false); GC.Collect(); } }); //AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; //TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; const string PORNHUB_HOST = "www.livehub.com"; const string IWARA_HOST = "iwara.tv"; var ip = Dns.GetHostAddresses(Dns.GetHostName()).Where((item) => item.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault() ?? IPAddress.Loopback; var pornhubListensEndPoint = new IPEndPoint(ip, 1080); var pacListensEndPoint = new IPEndPoint(ip, 8080); var adErrorEndpoint = new IPEndPoint(IPAddress.Loopback, 80); var iwaraLsitensPoint = new IPEndPoint(ip, 6456); var adVido = File.ReadAllBytes("ad.mp4"); PacServer pacServer = PacServer.Start(pacListensEndPoint, PacHelper.Create((host) => host == "www.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => host == "hubt.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => host == "ajax.googleapis.com", ProxyMode.CreateHTTP(adErrorEndpoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, "pornhub.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, "adtng.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)), PacHelper.Create((host) => PacMethod.dnsDomainIs(host, IWARA_HOST), ProxyMode.CreateHTTP(iwaraLsitensPoint))); SetProxy.Set(PacServer.CreatePacUri(pacListensEndPoint)); var ca = File.ReadAllBytes("myCA.pfx"); X509Certificate2 mainCert = TLSBouncyCastleHelper.GenerateTls(ca, "pornhub.com", 2048, 2, new string[] { "pornhub.com", "*.pornhub.com" }); X509Certificate2 adCert = TLSBouncyCastleHelper.GenerateTls(ca, "adtng.com", 2048, 2, new string[] { "adtng.com", "*.adtng.com" }); X509Certificate2 iwaraCert = TLSBouncyCastleHelper.GenerateTls(ca, "iwara.tv", 2048, 2, new string[] { "*.iwara.tv" }); PornhubProxyInfo info = new PornhubProxyInfo { MainPageStreamCreate = Connect.CreateLocalStream(new X509Certificate2(mainCert), SslProtocols.Tls12), ADPageStreamCreate = Connect.CreateLocalStream(new X509Certificate2(adCert), SslProtocols.Tls12), RemoteStreamCreate = Connect.CreateRemoteStream(PORNHUB_HOST, 443, PORNHUB_HOST, (a, b) => new MHttpStream(a, b), SslProtocols.Tls12), MaxContentSize = 1024 * 1024 * 5, ADVideoBytes = adVido, CheckingVideoHtml = Connect.CheckingVideoHtml, MaxRefreshRequestCount = 30, ReplaceResponseHtml = Connect.ReplaceResponseHtml, }; PornhubProxyServer server = new PornhubProxyServer(info); Task t1 = server.Start(pornhubListensEndPoint); SniProxyInfo iwaraSniInfo = new SniProxyInfo( iwaraLsitensPoint, Connect.CreateDnsLocalStream(), Connect.CreateDnsRemoteStream("104.20.27.25", 443)); SniProxy iwaraSniProxy = new SniProxy(iwaraSniInfo); Task t2 = iwaraSniProxy.Start(); Task.WaitAll(t1, t2); }
static void Main(string[] args) { AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; //RuntimeInformation.IsOSPlatform string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets"); byte[] vidoBuffer = File.ReadAllBytes(Path.Combine(basePath, "ad.mp4")); var ca = GetCA(basePath, "myCA.pfx"); Info info = JsonSerializer.Deserialize <Info>(File.ReadAllText(Path.Combine(basePath, "info.json"), Encoding.UTF8), new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip }); const string PORNHUB_DNS_HOST = "www.livehub.com"; const string PORNHUB_HOST = "pornhub.com"; const string IWARA_HOST = "iwara.tv"; const string HENTAI_HOST = "e-hentai.org"; const string AD_HOST = "adtng.com"; const string APKMIRROR_HOST = "apkmirror.com"; const string APKPURE_HOST = "apkpure.com"; var pacListensEndPoint = IPEndPoint.Parse(info.PacServerListen); var listenEndPoint = IPEndPoint.Parse(info.ProxyServerListen); var invalidEndpoint = IPEndPoint.Parse(info.InvalidIPEndPoint); var pacWriteEndPoint = IPEndPoint.Parse(info.PacProxyIPEndPoint); var adVido = vidoBuffer; var mainCert = TLSCertificate.CreateTlsCertificate(ca, PORNHUB_HOST, 2048, 2, PORNHUB_HOST, "*." + PORNHUB_HOST); var adCert = TLSCertificate.CreateTlsCertificate(ca, AD_HOST, 2048, 2, AD_HOST, "*." + AD_HOST); var hentaiCert = TLSCertificate.CreateTlsCertificate(ca, HENTAI_HOST, 2048, 2, HENTAI_HOST, "*." + HENTAI_HOST); var apkmirrorCert = TLSCertificate.CreateTlsCertificate(ca, APKMIRROR_HOST, 2048, 2, APKMIRROR_HOST, "*." + APKMIRROR_HOST); var apkpureCert = TLSCertificate.CreateTlsCertificate(ca, APKPURE_HOST, 2048, 2, APKPURE_HOST, "*." + APKPURE_HOST); PacServer.Builder.Create(pacListensEndPoint) .Add((host) => host == "www.pornhub.com", ProxyMode.CreateHTTP(invalidEndpoint)) .Add((host) => host == "hubt.pornhub.com", ProxyMode.CreateHTTP(invalidEndpoint)) .Add((host) => host == "ajax.googleapis.com", ProxyMode.CreateHTTP(invalidEndpoint)) .Add((host) => PacMethod.dnsDomainIs(host, PORNHUB_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .Add((host) => PacMethod.dnsDomainIs(host, AD_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .Add((host) => host == "i.iwara.tv", ProxyMode.CreateDIRECT()) .Add((host) => PacMethod.dnsDomainIs(host, IWARA_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .Add((host) => PacMethod.dnsDomainIs(host, HENTAI_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .Add((host) => PacMethod.dnsDomainIs(host, APKMIRROR_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .Add((host) => PacMethod.dnsDomainIs(host, APKPURE_HOST), ProxyMode.CreateHTTP(pacWriteEndPoint)) .StartPACServer(); SetAutoPac(pacListensEndPoint); PornhubProxyInfo pornhubInfo = new PornhubProxyInfo { MainPageStreamCreate = ConnectHelper.CreateLocalStream(new X509Certificate2(mainCert), SslProtocols.Tls12), ADPageStreamCreate = ConnectHelper.CreateLocalStream(new X509Certificate2(adCert), SslProtocols.Tls12), RemoteStreamCreate = ConnectHelper.CreateRemoteStream(PORNHUB_DNS_HOST, 443, PORNHUB_DNS_HOST, (a, b) => new MHttpStream(a, b), SslProtocols.Tls12), MaxContentSize = 1024 * 1024 * 5, ADVideoBytes = adVido, CheckingVideoHtml = PornhubHelper.CheckingVideoHtml, MaxRefreshRequestCount = 30, ReplaceResponseHtml = PornhubHelper.ReplaceResponseHtml }; var pornhubAction = PornhubProxyServer.Start(pornhubInfo); TunnelProxyInfo iwaraSniInfo = new TunnelProxyInfo() { CreateLocalStream = ConnectHelper.CreateDnsLocalStream(), CreateRemoteStream = ConnectHelper.CreateDnsRemoteStream( 443, "104.26.12.12", "104.20.201.232", "104.24.48.227", "104.22.27.126", "104.24.53.193") }; var iwaraAction = TunnelProxy.Create(iwaraSniInfo); TunnelProxyInfo hentaiInfo = new TunnelProxyInfo() { CreateLocalStream = ConnectHelper.CreateLocalStream(hentaiCert, SslProtocols.Tls12), CreateRemoteStream = ConnectHelper.CreateRemoteStream("46.101.100.115", 443, "104.20.135.21", (s, ssl) => (Stream)ssl, SslProtocols.Tls12) }; var ehentaiAction = TunnelProxy.Create(hentaiInfo); TunnelProxyInfo apkmirrorInfo = new TunnelProxyInfo() { CreateLocalStream = ConnectHelper.CreateLocalStream(apkmirrorCert, SslProtocols.Tls12), CreateRemoteStream = ConnectHelper.CreateRemoteStream("104.19.133.58", 443, "104.19.133.58", (s, ssl) => (Stream)ssl, SslProtocols.None) }; var apkmirrorAction = TunnelProxy.Create(apkmirrorInfo); TunnelProxyInfo apkpureInfo = new TunnelProxyInfo() { //https://apkpure.com/ //172.67.1.139 CreateLocalStream = ConnectHelper.CreateLocalStream(apkpureCert, SslProtocols.Tls12), CreateRemoteStream = ConnectHelper.CreateRemoteStream("172.67.1.139", 443, "172.67.1.139", (s, ssl) => (Stream)ssl, SslProtocols.None) }; var apkpureAction = TunnelProxy.Create(apkpureInfo); var forw = ForwardTunnelRequest.Builder.Create() .Add(IWARA_HOST, iwaraAction) .Add(PORNHUB_HOST, pornhubAction) .Add(AD_HOST, pornhubAction) .Add(HENTAI_HOST, ehentaiAction) .Add(APKMIRROR_HOST, apkmirrorAction) .Add(APKPURE_HOST, apkpureAction) .Get(listenEndPoint); forw.ListenTask.Wait(); }
void StartProxy() { const string PORNHUB_HOST = "www.livehub.com"; const string IWARA_HOST = "iwara.tv"; var pornhubListensEndPoint = ServerInfo.PornhubProxyEndPoint; var pacListensEndPoint = ServerInfo.PacServerEndPoint; var adErrorEndpoint = ServerInfo.ADErrorEndPoint; var iwaraLsitensPoint = ServerInfo.IwaraProxyEndPoint; var adVido = ServerInfo.AdVideo; var caFile = ServerInfo.CaCert; var mainCert = new X509Certificate2(ServerInfo.PornCert); var adCert = new X509Certificate2(ServerInfo.AdCert); PacServer.Builder.Create(pacListensEndPoint) .Add((host) => host == "www.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)) .Add((host) => host == "hubt.pornhub.com", ProxyMode.CreateHTTP(adErrorEndpoint)) .Add((host) => host == "ajax.googleapis.com", ProxyMode.CreateHTTP(adErrorEndpoint)) .Add((host) => PacMethod.dnsDomainIs(host, "pornhub.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)) .Add((host) => PacMethod.dnsDomainIs(host, "adtng.com"), ProxyMode.CreateHTTP(pornhubListensEndPoint)) .Add((host) => host == "i.iwara.tv", ProxyMode.CreateDIRECT()) .Add((host) => PacMethod.dnsDomainIs(host, IWARA_HOST), ProxyMode.CreateHTTP(iwaraLsitensPoint)) .StartPACServer(); PornhubProxyInfo info = new PornhubProxyInfo { MainPageStreamCreate = ConnectHelper.CreateLocalStream(new X509Certificate2(mainCert), SslProtocols.Tls12), ADPageStreamCreate = ConnectHelper.CreateLocalStream(new X509Certificate2(adCert), SslProtocols.Tls12), RemoteStreamCreate = ConnectHelper.CreateRemoteStream(PORNHUB_HOST, 443, PORNHUB_HOST, (a, b) => new MHttpStream(a, b), SslProtocols.Tls12), MaxContentSize = 1024 * 1024 * 5, ADVideoBytes = adVido, CheckingVideoHtml = PornhubHelper.CheckingVideoHtml, MaxRefreshRequestCount = 30, ReplaceResponseHtml = PornhubHelper.ReplaceResponseHtml, ListenIPEndPoint = pornhubListensEndPoint }; Task t1 = PornhubProxyServer.Start(info).Task; TunnelProxyInfo iwaraSniInfo = new TunnelProxyInfo() { ListenIPEndPoint = iwaraLsitensPoint, CreateLocalStream = ConnectHelper.CreateDnsLocalStream(), CreateRemoteStream = ConnectHelper.CreateDnsRemoteStream( 443, "104.26.12.12", "104.20.201.232", "104.24.48.227", "104.22.27.126", "104.24.53.193") }; Task t2 = TunnelProxy.Start(iwaraSniInfo).Task; }