位置: 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引擎计算汇编长度(驱动开发做得长久吗)

  • 荣耀手机时间怎么设置为24小时(荣耀手机时间怎么显示秒)

    荣耀手机时间怎么设置为24小时(荣耀手机时间怎么显示秒)

  • 华为手机怎么把手机联系人导入卡里(华为手机怎么把旧手机导入新手机)

    华为手机怎么把手机联系人导入卡里(华为手机怎么把旧手机导入新手机)

  • 苹果照片上怎么显示地点和时间(苹果照片上怎么写字)

    苹果照片上怎么显示地点和时间(苹果照片上怎么写字)

  • 2.5英寸硬盘和3.5英寸有什么分别(2.5英寸硬盘和3.5英寸硬盘尺寸)

    2.5英寸硬盘和3.5英寸有什么分别(2.5英寸硬盘和3.5英寸硬盘尺寸)

  • mqa92cha是国行吗(mqa92cha是不是国行)

    mqa92cha是国行吗(mqa92cha是不是国行)

  • 小米售后寄修需要几天(小米售后寄修需要保价吗)

    小米售后寄修需要几天(小米售后寄修需要保价吗)

  • iPhone11慢动作拍照闪屏(苹果11相机慢动作)

    iPhone11慢动作拍照闪屏(苹果11相机慢动作)

  • jovi可以语音唤醒吗(jovi语音设置)

    jovi可以语音唤醒吗(jovi语音设置)

  • 大数据五大基本特点(大数据五大基本特点包括容量种类速度可变性真实)

    大数据五大基本特点(大数据五大基本特点包括容量种类速度可变性真实)

  • 苹果11微信视频声音小是怎么回事(苹果11微信视频怎么开美颜)

    苹果11微信视频声音小是怎么回事(苹果11微信视频怎么开美颜)

  • 个人订阅号可以改成企业的吗(个人订阅号可以转让吗)

    个人订阅号可以改成企业的吗(个人订阅号可以转让吗)

  • 微信可以加多少好友就会满(微信可以加多少人才满)

    微信可以加多少好友就会满(微信可以加多少人才满)

  • 微信怎么没有暗黑模式(微信设置暗色)

    微信怎么没有暗黑模式(微信设置暗色)

  • 电脑下载不了东西怎么回事(电脑下载不上)

    电脑下载不了东西怎么回事(电脑下载不上)

  • 信息显示感叹号是什么意思(为什么信息显示感叹号)

    信息显示感叹号是什么意思(为什么信息显示感叹号)

  • 小米9后期可以升级5g吗(小米9后期可以升级吗)

    小米9后期可以升级5g吗(小米9后期可以升级吗)

  • 苹果充电次数可以刷吗(苹果充电次数可以被刷掉吗)

    苹果充电次数可以刷吗(苹果充电次数可以被刷掉吗)

  • 抖音收藏别人看得到吗(抖音别人收藏你作品你能不能看到)

    抖音收藏别人看得到吗(抖音别人收藏你作品你能不能看到)

  • 电池优化是允许还是不允许(忽略电池优化)

    电池优化是允许还是不允许(忽略电池优化)

  • 为什么喜马拉雅app下载不了(为什么喜马拉雅总是卡顿)

    为什么喜马拉雅app下载不了(为什么喜马拉雅总是卡顿)

  • 苹果ios12信任证书怎么删除(iphone12pro max信任证书)

    苹果ios12信任证书怎么删除(iphone12pro max信任证书)

  • 怎么隐藏相册里的视频(怎么隐藏相册里的照片vivo)

    怎么隐藏相册里的视频(怎么隐藏相册里的照片vivo)

  • 炫酷登录注册 完整功能版【本地存储+JS+HTML+CSS+jQuery】(炫酷登录注册教程)

    炫酷登录注册 完整功能版【本地存储+JS+HTML+CSS+jQuery】(炫酷登录注册教程)

  • 【Node.js实战】一文带你开发博客项目(API 对接 MySQL)(node.js教程详细)

    【Node.js实战】一文带你开发博客项目(API 对接 MySQL)(node.js教程详细)

  • 农村个体工商户的定义
  • 小规模纳税人0税率发票
  • 出口免税收入会退税吗
  • 企业交的增值税怎么做账
  • 房屋契税缴纳比例
  • 更改开票信息需要多久
  • 个人所得税应补税额怎么办
  • 电子税务局自然人怎么切换到企业
  • 小规模纳税人租金发票的税率是多少
  • 无形资产可以一次性摊销吗?
  • 一笔多少钱
  • 应税服务增值税抵免
  • 公司债券投资的优缺点
  • 视同销售要确认收入吗?
  • 盘盈存货会计处理会计分录
  • 土地承包经营合同无效情形
  • 电子发票如何报销做账
  • 收到管理费用的会计科目
  • 交社保公积金需要劳动合同吗
  • 一般企业可以开检测费吗
  • 公司转账不开票备注服务费怎么入账
  • 房企的预收账款是什么
  • 实收资本怎样入账
  • xmp是什么格式的文件是一种预设吗
  • php7.3
  • 虚拟机系统vmware
  • window10没有激活码
  • win10右键失灵解决办法
  • 有限责任公司股东对公司债务承担
  • 固定资产与固定资产净值
  • 时域卷积图解法
  • webpack打包步骤
  • php 压缩文件
  • bug的定位和跟踪
  • 体检的收据是什么
  • 销售旧货物的增值税
  • javascript前端开发案例教程源码
  • 公司费用计入什么科目
  • Linux下MySQL数据库的主从同步复制配置
  • 应收账款让售会计怎么做
  • 个人所得税申报截止时间
  • 一联发票和二联发票
  • 出口退税率为0的账务处理
  • 出口退税如何做进料核销凭证
  • 收到红字发票如何申报增值税?
  • 企业被列入经营异常名录可以注销吗
  • 房地产开发公司是做什么的
  • 房地产企业抵押借款
  • 医院的自助缴费机怎么开具发票
  • 预提费用在新会计准则下该如何列支?
  • 企业注销未分配是从注册开始吗
  • 存货周转率 高
  • 未取得合法支付凭据和与本单位无关的收入
  • mysql安装配置教程5.7.25
  • 防火墙监视模式
  • win8系统运行在哪里
  • linux操作系统的基本操作
  • pe硬盘安装win7系统教程
  • win7系统通知
  • win8.1最流畅
  • 运维是什么的
  • win10预览体验推荐哪个通道
  • [置顶] 此外,车牌号:458143(懂得都懂[吃瓜])
  • Windows搭建代理服务器
  • js自动生成序号
  • prototype用法
  • android view详解
  • pm2系统的操作
  • python简易
  • Python 数据清洗
  • actionscript与javascript的区别
  • node stream(流)有哪些?
  • jquery实现自动轮播
  • java教程
  • 广州出租车发票号码在哪里
  • 打印个人住房信息查询记录需要什么资料
  • 施工企业应缴纳的税金计算
  • 什么叫关联单位
  • 小汽车碰撞游戏视频
  • 济南税务局,济南电子税务局官网
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设