How to By Pass Proxy

此博客展示了一段C#代码,用于在代理需要认证模式时,提供用户名、密码和域名进行网页请求。代码通过创建HttpWebRequest对象,设置网络凭证和缓存,获取网页响应并读取内容,最后将结果显示在页面上。
// Source Code starts
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage("http://www.c-sharpcorner.com");
}

private String readHtmlPage(string url)
{
String result;
WebResponse objResponse;
WebProxy proxyObject = new WebProxy("http://urproxy:port/",true);
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objRequest.Proxy = proxyObject; 

objResponse = objRequest.GetResponse();
using (StreamReader sr = 
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;

</script>
<html>
<body>

<b>This content is being populated from a separate HTTP request to
<a href="http://www.c-sharpcorner.com">www.c-sharpcorner.com</a></b><hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>

// Source Code End

//While Here is the Code where you need to Provide UserName,Password and //domainName if your Proxy requires these Authentication Mode.

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage("http://www.c-sharpcorner.com");
}

private String readHtmlPage(string url)
{
String result;
HttpWebRequest makeReq =(HttpWebRequest)WebRequest.Create("http://www.shivanicreations.com/");
NetworkCredential giveCred = new NetworkCredential("username","password","domain"); 
CredentialCache putCache = new CredentialCache(); 
putCache.Add(new Uri("http://www.shivanicreations.com/"), "Basic", myCred); 
makeReq.Credentials = myCache;
WebResponse objResponse;
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;

</script>
<html>
<body>
<b>The below given Page is generated from a separate Request to this URL
<a href="http://www.c-sharpcorner.com">www.c-sharpcorner.com</a></b>
<hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>

# proxychains.conf VER 3.1 # # HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS. # # The option below identifies how the ProxyList is treated. # only one option should be uncommented at time, # otherwise the last appearing option will be accepted # #dynamic_chain # # Dynamic - Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # at least one proxy must be online to play in chain # (dead proxies are skipped) # otherwise EINTR is returned to the app # strict_chain # # Strict - Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # all proxies must be online to play in chain # otherwise EINTR is returned to the app # #random_chain # # Random - Each connection will be done via random proxy # (or proxy chain, see chain_len) from the list. # this option is good to test your IDS :) # Make sense only if random_chain #chain_len = 2 # Quiet mode (no output from library) #quiet_mode # Proxy DNS requests - no leak for DNS data proxy_dns # Some timeouts in milliseconds tcp_read_time_out 15000 tcp_connect_time_out 8000 # ProxyList format # type host port [user pass] # (values separated by 'tab' or 'blank') # # # Examples: # # socks5 192.168.67.78 1080 lamer secret # http 192.168.89.3 8080 justu hidden # socks4 192.168.1.49 1080 # http 192.168.39.93 8080 # # # proxy types: http, socks4, socks5 # ( auth types supported: "basic"-http "user/pass"-socks ) # [ProxyList] # add proxy here ... # meanwile # defaults set to "tor" socks5 192.168.23.15 10808 dns_server = 8.8.8.8
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值