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

  • 趁着年轻,赶紧去实现你的梦想(趁着年轻赶紧挣钱)

    趁着年轻,赶紧去实现你的梦想(趁着年轻赶紧挣钱)

  • qq小世界怎么看访客(qq小世界怎么看好友点赞过的视频)

    qq小世界怎么看访客(qq小世界怎么看好友点赞过的视频)

  • miui12如何显示网速(miui12如何显示wifi)

    miui12如何显示网速(miui12如何显示wifi)

  • 华为手机打字声音怎么开(华为手机打字声音怎么设置)

    华为手机打字声音怎么开(华为手机打字声音怎么设置)

  • 抖音一万音浪 主播可以分到多少(抖音一万音浪到手多少钱)

    抖音一万音浪 主播可以分到多少(抖音一万音浪到手多少钱)

  • 网上怎么找真正的官网(网上怎么找真正的女朋友)

    网上怎么找真正的官网(网上怎么找真正的女朋友)

  • 华为nova7手机耳机怎么用(华为nova7手机耳机插上去没反应)

    华为nova7手机耳机怎么用(华为nova7手机耳机插上去没反应)

  • hms华为是干什么用的(华为hms是华为应用市场吗)

    hms华为是干什么用的(华为hms是华为应用市场吗)

  • 路由器1900m和1200m有什么区别(路由器1900m和2100m的区别)

    路由器1900m和1200m有什么区别(路由器1900m和2100m的区别)

  • 苹果手机显示3g网络怎么回事(苹果手机显示3g为什么没有网络)

    苹果手机显示3g网络怎么回事(苹果手机显示3g为什么没有网络)

  • pdf能直接编辑吗(pdf上可以直接编辑吗)

    pdf能直接编辑吗(pdf上可以直接编辑吗)

  • ipad air1上市时间(ipad air2上市时间)

    ipad air1上市时间(ipad air2上市时间)

  • EC是什么(ec是什么意思)

    EC是什么(ec是什么意思)

  • 怎样反电子干扰(反电子干扰的主要措施)

    怎样反电子干扰(反电子干扰的主要措施)

  • 微信什么是视频号(微信什么视频格式最高清)

    微信什么是视频号(微信什么视频格式最高清)

  • 手机恢复出厂照片还在吗(手机恢复出厂照片找回)

    手机恢复出厂照片还在吗(手机恢复出厂照片找回)

  • 淘宝ifasion是什么意思(淘宝ifishon啥意思)

    淘宝ifasion是什么意思(淘宝ifishon啥意思)

  • 修改未知应用权限在哪里(未知应用修改权限之后还是无法下载)

    修改未知应用权限在哪里(未知应用修改权限之后还是无法下载)

  • 怎么卸载win10系统(怎么卸载win10系统更新文件)

    怎么卸载win10系统(怎么卸载win10系统更新文件)

  • 怎样删除微信聊天记录不能被恢复(怎样删除微信聊天记录,对方也不能看)

    怎样删除微信聊天记录不能被恢复(怎样删除微信聊天记录,对方也不能看)

  • 在电脑上怎么下载微信电脑版(在电脑上怎么下载steam)

    在电脑上怎么下载微信电脑版(在电脑上怎么下载steam)

  • 云闪付多久到账(云闪付)

    云闪付多久到账(云闪付)

  • OPPO k5怎么开启自动切换免提(oppok5怎么开启游戏模式)

    OPPO k5怎么开启自动切换免提(oppok5怎么开启游戏模式)

  • 京东授权管理在哪里(京东店铺授权)

    京东授权管理在哪里(京东店铺授权)

  • oppoa9禁止系统更新(oppo手机禁止更新系统)

    oppoa9禁止系统更新(oppo手机禁止更新系统)

  • 华为p30pro能隐藏虚拟按键吗(华为p30怎样隐藏)

    华为p30pro能隐藏虚拟按键吗(华为p30怎样隐藏)

  • 华为mate20能插内存卡吗(华为mate20插内存卡)

    华为mate20能插内存卡吗(华为mate20插内存卡)

  • 支付税金怎么算
  • 销项税额的计算方法
  • 增值税发票抵扣是什么意思
  • 原始凭证太多如何删除
  • 小规模纳税人不动产租赁税率
  • 借款利息收入要开票吗
  • 医院工作服记什么科目
  • 个税三代手续费返还增值税报表怎么填
  • 个体工商户开普票流程
  • 企业缴纳残疾人保证金按什么标准缴纳
  • 预缴增值税是否要预缴印花税
  • 工作过失扣工资合法吗
  • 担保预计负债要如何做账?
  • 预提职工福利怎么记账
  • 没有进货发票怎么处罚
  • 预付房租是否需要分摊处理呢?
  • 工资不到3500用交个税吗
  • 哪些费用可在缴纳企业所得税前扣除呢?
  • 企业报社保可以用医保吗
  • 普通发票税率为1%吗
  • 集体福利支出包括
  • 境内个人去境外开设公司
  • 记账凭证按照填列方式的分类包括
  • 什么发票可以抵成本
  • 鸿蒙系统图标底色变白
  • 电脑系统还原步骤
  • 出租人负责维修
  • 外购固定资产入账
  • 华为鸿蒙harmonyos官网4.0升级
  • 电脑扩展卷是灰色的的怎么办
  • 代发工资跨行手续怎么办
  • autorun.exe无法运行
  • 继续涉入资产会计处理
  • 应发工资扣税
  • 汇兑损失是否可以抵扣
  • 固定资产的预计使用寿命和净残值发生变更
  • js如何随机生成字符串
  • 应收账款在贷方如何平账
  • vue全家桶介绍
  • Windows 10 python 3.9安装运行Mockingbird--拎包入住功略
  • 员工持股平台合伙企业
  • 结转成本涉及的科目
  • 工资和五险一金在公司发,个税在子公司扣
  • 资产减值损失账户核算内容
  • python3.9怎么删除
  • mysql基础知识点
  • sql2008强制还原数据库
  • 广告被罚
  • 应付职工薪酬账户贷方登记的是
  • 调整以前年度利息支出
  • 空调销售又安装如何税收筹划
  • 会计人员必备的知识和技能
  • 会务费所需要注意的细节
  • casewhen嵌套查询
  • mysql远程访问不了
  • win8系统安装步骤
  • 智能abc不能输入汉字
  • windows vista在哪里
  • linux那些事儿
  • 正确安全管理操作手册
  • win7安装sqlserver2000
  • win10屏幕图片
  • win7系统如何给文件夹加密
  • 深入理解rcu
  • cocos2dx4.0教程
  • bootstrap响应式工具使用详解
  • firefox浏览器标识ua
  • vue miniui
  • python快速上手 自动化
  • shell定时删除指定目录下的文件夹
  • jQuery实现获取table表格第一列值的方法
  • jquery鼠标点击
  • python中time模块源代码
  • python socketcan
  • 3、BluetoothChat之BluetoothChatService.java
  • 如何打印个人所得税的税单
  • 福建省税务局举报中心
  • 北京税务分所怎么样啊
  • 个体工商户银行卡是对公还是对私
  • 广东为什么用粤做简称?
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设