位置: IT常识 - 正文

HTTP Tunneling (HTTP Proxy Socket Client)

编辑:rootadmin
HTTP Tunneling (HTTP Proxy Socket Client)HTTP TunnelingHTTP is a text-based protocol to retreive Web

推荐整理分享HTTP Tunneling (HTTP Proxy Socket Client),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

HTTP Tunneling

HTTP is a text-based protocol to retreive Web pages through a Web browser. Mostly if you are on a LAN connection, you are behind a proxy server; this proxy server has one HTTP proxy running on some defined port. In your Internet Explorer's Connection option, you specify LAN settings as required. This proxy server is definitely running on a text-based protocol and you can only get HTTP-related data from the outside network, right!! Well, there is a small loophole from which you can go through HTTP and connect to the outside world and get any data you want in binary protocol, or even your own protocol. It's through HTTPS.

HTTPS Explanation

In HTTPS, data is transferred from browser to server and server to browser in a secure manner. It's a binary protocol; when it goes through a proxy, the proxy doesn't understand anything. The proxy just allows a binary stream to open and let both server and client exchange the data. Now, we can fool the proxy server and connect to any server and exchange data. The proxy server will think that we doing some secure HTTP session.

For HTTPS, your browser connects to a proxyserver and sends a command.

CONNECT neurospeech.com:443HTTP/1.0<CR><LF>HOST neurospeech.com:443<CR><LF>[... other HTTP header lines ending with<CR><LF>if required]><CR><LF>// Last Empty Line

Then, the proxy server treats this as some HTTP Secure Session, and opens a binary stream to the required server and port as defined. If a connection established, the proxy server returns the following response:

HTTP/1.0200ConnectionEstablished<CR><LF>[.... other HTTP header lines ending with<CR><LF>..ignore all of them]<CR><LF>// Last Empty Line

Now, the browser is connected to the end server and can exchange data in both a binary and secure form.

How to Do This

Now, it's your program's turn to fool the proxy server and behave as Internet Explorer behaves for Secure HTTP.

Connect to Proxy Server first.Issue CONNECT Host:Port HTTP/1.1<CR><LF>.Issue <CR><LF>.Wait for a line of response. If it contains HTTP/1.X 200 , the connection is successful.Read further lines of response until you receive an empty line.Now, you are connected to outside world through a proxy. Do any data exchange you want.Sample Source Code// You need to connect to mail.yahoo.com on port 25// Through a proxy on 192.0.1.1, on HTTP Proxy 4480// CSocketClient is Socket wrapping class// When you apply operator << on CString, it writes CString// To Socket ending with CRLF// When you apply operator >> on CString, it receives// a Line of response from socket until CRLFtry{CStringRequest,Response;CSocketClientClient;Client.ConnectTo("192.0.1.1",4480);// Issue CONNECT CommandRequest="CONNECT mail.yahoo.com:25 HTTP/1.0";Client<<Request;// Issue empty lineRequest="";Client<<Request;// Receive Response From ServerClient>>Response;// Ignore HTTP Versionint n =Response.Find(' ');Response=Response.Mid(n+1);// Http Response Must be 200 onlyif(Response.Left(3)!="200"){// Connection refused from HTTP Proxy ServerAfxMessageBox(Response);}// Read Response Lines until you receive an empty line.do{Client>>Response;if(Response.IsEmpty())break;}while(true);// Coooooooool.... Now connected to mail.yahoo.com:25// Do further SMTP Protocol here..}catch(CSocketException* pE){ pE->ReportError();}Library Source CodeHTTP Tunneling (HTTP Proxy Socket Client)

The Dns.h file contains all DNS-related source code. It uses other libraries, as SocketEx.h, SocketClient.h, and NeuroBuffer.h.

CSocketEx

Socket functions as a wrapper class. (CSocket is very heavy and unreliable if you don't have the exact idea of how it works.) All the functions are of same name as CSocket. You can use this class directly.

CSocketClient

Derived from CSocketEx and throws proper exceptions with details of Winsock errors. It defines two operators, >> and <<, for easy sending and receiving; it also changes network to host and host to network order of bytes if required.

CHttpProxySocketClient

Derived from CSocketClient, you can call the SetProxySettings(ProxyServer,Port) method and set proxy settings. Then, you can connect to the desired host and port as you need. The ConnectTo method is overridden and it automatically implements an HTTP proxy protocol and gives you a connection without any hassle.

How to Use CHttpProxySocketClient// e.g. You need to connect to mail.yahoo.com on port 25// Through a proxy on 192.0.1.1, on HTTP Proxy 4480// CSocketClient is Socket wrapping class// When you apply operator << on CString, it writes CString// To Socket ending with CRLF// When you apply operator >> on CString, it receives// Line of response from socket until CRLFtry{CHttpProxySocketClientClient;Client.SetProxySettings("192.0.1.1",1979);// Connect to server mail.yahoo.com on port 25Client.ConnectTo("mail.yahoo.com",25);// You now have access to mail.yahoo.com on port 25// If you do not call SetProxySettings, then// you are connected to mail.yahoo.com directly if// you have direct access, so always use// CHttpProxySocketClient and no need to do any// extra coding.}catch(CSocketException* pE){ pE->ReportError();}

Note: I usually don't program in the form of .h and .cpp different files, because using them the next time somewhere else is a big problem because you must move both files here and there. So, I put all the code in my .h file only; I don't write to the .cpp file unless it's required. You need to copy only the SocketEx.h, SocketClient.h, and HttpProxySocket.h files into your project's directory, and add line

#include"HttpProxySocket.h"

after your

#if !defined(.....

and so forth code of your Visual Studio-generated file. If you put anything above this, you will get n number of errors.

Downloads

Download source - 17 Kb

Note: I usually don't program in the form of .h and .cpp different files, because using them the next time somewhere else is a big problem because you must move both files here and there. So, I put all the code in my .h file only; I don't write to the .cpp file unless it's required. You need to copy only the SocketEx.h, SocketClient.h, and HttpProxySocket.h files into your project's directory, and add line

#include"HttpProxySocket.h"

after your

#if !defined(.....

and so forth code of your Visual Studio-generated file. If you put anything above this, you will get n number of errors.

本文链接地址:https://www.jiuchutong.com/zhishi/304101.html 转载请保留说明!

上一篇:实现自己的http server loop_in_codes C++博客

下一篇:驱动开发:内核LDE64引擎计算汇编长度(驱动开发做得长久吗)

  • 孙春兰强调 总结基层经验做法 推动防控措施持续优化

    孙春兰强调 总结基层经验做法 推动防控措施持续优化

  • 苹果怎么给app悬浮窗权限(苹果怎么给app悬浮窗设置)

    苹果怎么给app悬浮窗权限(苹果怎么给app悬浮窗设置)

  • 关闭当前演示文稿的快捷键是什么(关闭当前演示文稿)

    关闭当前演示文稿的快捷键是什么(关闭当前演示文稿)

  • 华为屏幕录制怎么去掉那个小点(华为屏幕录制怎么关闭)

    华为屏幕录制怎么去掉那个小点(华为屏幕录制怎么关闭)

  • 双卡怎么设置一个卡不接电话(双卡怎么设置一样的来电铃声)

    双卡怎么设置一个卡不接电话(双卡怎么设置一样的来电铃声)

  • 内部存储器有哪些(说说内部存储器有哪些)

    内部存储器有哪些(说说内部存储器有哪些)

  • 卡贴激活sim卡无效(卡贴激活显示无sim卡)

    卡贴激活sim卡无效(卡贴激活显示无sim卡)

  • qq气泡免费的有哪些(qq气泡免费使用有哪些)

    qq气泡免费的有哪些(qq气泡免费使用有哪些)

  • 电动车充电器发烫是什么原因(电动车充电器发烫)

    电动车充电器发烫是什么原因(电动车充电器发烫)

  • voc是什么电脑(voc是啥牌子)

    voc是什么电脑(voc是啥牌子)

  • ipadmini3为什么停产(ipad mini老是闪退怎么回事)

    ipadmini3为什么停产(ipad mini老是闪退怎么回事)

  • 进程由哪几部分组成(进程由哪几部分组成,每一部分的内容和作用)

    进程由哪几部分组成(进程由哪几部分组成,每一部分的内容和作用)

  • 抖音企业号怎么取消(抖音企业号怎么恢复个人账号)

    抖音企业号怎么取消(抖音企业号怎么恢复个人账号)

  • 苹果x短信有个感叹号(苹果手机短信上有一个!是什么意思)

    苹果x短信有个感叹号(苹果手机短信上有一个!是什么意思)

  • 微信步数多长时间更新一次(微信步数多久)

    微信步数多长时间更新一次(微信步数多久)

  • 红米k20pro是多少赫兹刷新率(红米k20pro是多少w快充)

    红米k20pro是多少赫兹刷新率(红米k20pro是多少w快充)

  • imessage怎么放烟花

    imessage怎么放烟花

  • 笔记本变卡了怎么解决(笔记本变卡了怎么处理)

    笔记本变卡了怎么解决(笔记本变卡了怎么处理)

  • 货车帮闪退是怎么回事(货车帮登录异常)

    货车帮闪退是怎么回事(货车帮登录异常)

  • vⅰvo手机的字体大小怎么调(ⅴiv0y66手机字体变大从哪里找)

    vⅰvo手机的字体大小怎么调(ⅴiv0y66手机字体变大从哪里找)

  • 小米9水滴屏开关在哪(小米九水滴屏)

    小米9水滴屏开关在哪(小米九水滴屏)

  • 美团会员续费怎么关(美团会员续费怎么退)

    美团会员续费怎么关(美团会员续费怎么退)

  • urlproc.exe是什么进程(urlerror什么意思)

    urlproc.exe是什么进程(urlerror什么意思)

  • pavupg.exe是什么进程 pavupg进程查询(pnaico.exe是什么软件)

    pavupg.exe是什么进程 pavupg进程查询(pnaico.exe是什么软件)

  • 图书管理系统的需求分析和项目介绍(图书管理系统的软件结构图)

    图书管理系统的需求分析和项目介绍(图书管理系统的软件结构图)

  • 附加税申报表怎么做
  • 免征的增值税怎么计算
  • 以房抵债如何计算契税?
  • 发票收款人和复核没写可以用吗
  • 冲红凭证更正时摘要怎么写
  • 契税和房产税的减免政策
  • 专票当普票用,发票勾选怎么操作
  • 软件企业购进软件服务怎么入账
  • 未取得发票的费用
  • 转登记小规模纳税人留抵税额
  • 资金成本加价收入能作为收入开票吗
  • 银行承兑汇票贴现率多少
  • 少付了几毛钱会计分录
  • 固定资产抵扣期限
  • 计提工资数大于实际支付数怎么办?
  • 福利费可以抵扣个税吗
  • 没交社保能扣工伤保险吗
  • 申报状态显示申报失败
  • 享受企业所得税税额抵免优惠的设备包括
  • 个人交社保可以交生育险吗
  • 已备案购销合同
  • 企业所得税固定资产折旧计算
  • 多交附加税怎么做账
  • 公司购买理财产品如何做账
  • windows10如何移动文件
  • 笔记本电池怎么换
  • Win10宽带无法连接
  • ghost还原问题1823
  • 装电脑系统的方法和步骤
  • deskrun.exe是什么东西
  • 森林里雾气弥漫,给大家带来了什么困难?
  • 专业初审
  • 违约金需要缴纳企业所得税吗
  • 设计资质承担范围
  • yii gridview
  • 只申报个税不交社保
  • bit/ttagapp
  • vue-router导航守卫
  • PHP自定义函数实现计算机整数的四次方
  • python二叉树遍历算法
  • 一个小柜的货代费用
  • 门锁开票的服务名称编码
  • 为什么分红不影响损益
  • react 上下文hooks内容存储到本地
  • python os.path.join()函数的使用
  • 补贴,津贴是否合理
  • 应付利息的账务处理
  • 残疾人就业相关论文题目
  • 企业食堂的费用入什么科目
  • 出口企业有哪些税收
  • 分期收款发出商品是什么意思
  • 应付账款借方余额负数表示什么
  • 关联交易现金流
  • 职工福利费无发放原因
  • 委托加工业务的财务职责
  • 出口样品的销售好做吗
  • 对公账户进出账常识
  • 小企业成本核算方法怎么填
  • 基本户转账法人会知道吗
  • 内部资金管理实施细则
  • sql导入csv数据
  • mysql count详解及函数实例代码
  • 32位操作系统不能玩cf
  • linux lftp命令
  • 哪款系统重装软件比较好
  • centos永久修改主机名
  • win7浏览器主页怎么设置
  • mm server conection failed
  • pavsrv50.exe - pavsrv50进程管理信息
  • win10系统如何禁用u盘
  • linux不小心删除目录怎么恢复
  • linux userdel
  • 事件处理的三个要素
  • jquery实现图片懒加载
  • HttpURLConnection连接 详解
  • linux用户配置文件是什么
  • 深入理解ts
  • JAVAscript字符串类型单引号和双引号意一样吗
  • 用js实现类的方法
  • 新疆伊犁水费怎么交
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设