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

  • 手机上如何取消酷喵会员(手机上如何取消银行卡短信服务费)

    手机上如何取消酷喵会员(手机上如何取消银行卡短信服务费)

  • 酷我音乐是腾讯的吗(酷我音乐是腾讯软件吗)

    酷我音乐是腾讯的吗(酷我音乐是腾讯软件吗)

  • 文档格式怎么调行间距(文档格式怎么调大小)

    文档格式怎么调行间距(文档格式怎么调大小)

  • 防火墙自身会不会被攻破(防火墙会中毒吗)

    防火墙自身会不会被攻破(防火墙会中毒吗)

  • 手机90hz和60刷新率有什么区别(手机屏幕刷新60和90有什么区别)

    手机90hz和60刷新率有什么区别(手机屏幕刷新60和90有什么区别)

  • 怎么删除撤回消息字迹(怎么删除撤回消息字迹微信)

    怎么删除撤回消息字迹(怎么删除撤回消息字迹微信)

  • 演示文稿与幻灯片的关系是(演示文稿与幻灯片,工作簿与工作表,word文档与页面)

    演示文稿与幻灯片的关系是(演示文稿与幻灯片,工作簿与工作表,word文档与页面)

  • 网易云听歌听到一半突然换歌(网易云听歌听到自己声音)

    网易云听歌听到一半突然换歌(网易云听歌听到自己声音)

  • 苹果se2系统是ios多少(苹果se2是ios几)

    苹果se2系统是ios多少(苹果se2是ios几)

  • 开通抖音直播要不要钱(开通抖音直播要收费吗)

    开通抖音直播要不要钱(开通抖音直播要收费吗)

  • pdf是电子版的意思吗(pdf是电子版是什么意思)

    pdf是电子版的意思吗(pdf是电子版是什么意思)

  • 网络显示hd是啥意思(网络上面显示hd)

    网络显示hd是啥意思(网络上面显示hd)

  • vivo闪充和线有关系吗(vivo闪充是数据线还是插头重要)

    vivo闪充和线有关系吗(vivo闪充是数据线还是插头重要)

  • 苹果8微信视频怎么美颜(苹果8微信视频来电没声音)

    苹果8微信视频怎么美颜(苹果8微信视频来电没声音)

  • 18w快充对手机电池有损害吗(18w快充会影响电池寿命吗)

    18w快充对手机电池有损害吗(18w快充会影响电池寿命吗)

  • 怎样发位置给微信好友(怎样发位置微信)

    怎样发位置给微信好友(怎样发位置微信)

  • 快手删作品会影响权重(快手删作品会影响浏览吗)

    快手删作品会影响权重(快手删作品会影响浏览吗)

  • 手机卡怎么查号码(手机卡怎么查号码归属地)

    手机卡怎么查号码(手机卡怎么查号码归属地)

  • 手机浏览器怎么登录(手机浏览器怎么扫描二维码)

    手机浏览器怎么登录(手机浏览器怎么扫描二维码)

  • 手机优酷会员卡怎么激活(手机优酷会员卡密怎么激活)

    手机优酷会员卡怎么激活(手机优酷会员卡密怎么激活)

  • 华为mate20x5G怎么设置虚拟键

    华为mate20x5G怎么设置虚拟键

  • oppo手机呼吸灯设置(OPPO手机呼吸灯一直闪)

    oppo手机呼吸灯设置(OPPO手机呼吸灯一直闪)

  • 华为荣耀路由pro和pro2区别(华为荣耀路由pro2说明书)

    华为荣耀路由pro和pro2区别(华为荣耀路由pro2说明书)

  • 华为p30pro无线快充怎么用(华为p30pro无线快充)

    华为p30pro无线快充怎么用(华为p30pro无线快充)

  • yolov8 瑞芯微RKNN和地平线Horizon芯片仿真测试部署(瑞芯微 8nm)

    yolov8 瑞芯微RKNN和地平线Horizon芯片仿真测试部署(瑞芯微 8nm)

  • 关于Chrome新建标签页被hao123劫持(chrome新建标签为打开特定网页)

    关于Chrome新建标签页被hao123劫持(chrome新建标签为打开特定网页)

  • 经营用的电饭锅有哪些
  • 商贸公司营业执照范围
  • 生产车间领用的低值易耗品
  • 售后回租利息和租金区别
  • 税务部门罚没收入200元
  • 未收到发票暂估入库的进项税额可以暂估进原料成本吗
  • 亏损企业股东年底借钱未还
  • 实缴年月正常补收
  • 税务登记号就是发票吗
  • 增值税发票的基数是什么
  • 大额联行号和开户行号是一样的吗
  • 子公司给的股利用交税吗
  • 电子发票报销有什么用
  • 预付的货款可以计入应付账款吗
  • 医疗卫生机构可以向其他单位或者个人分发第一类疫苗
  • 公司低价处理旧汽车涉税账务处理
  • 差额银行承兑汇票
  • 公允价值变动借方是增还是减
  • linux禁用root用户
  • 少计提的地税怎么做分录
  • 同一控股下的控股合并
  • 还款本息和本金哪个划算
  • 固定资产增值税税率
  • 支付航天的代理公司
  • 鸿蒙怎么装app
  • 正版的win10多少钱
  • SetPoint.exe - SetPoint是什么进程 有什么用
  • PHP:__halt_compiler()的用法_misc函数
  • 盈余公积转增资本会计科目
  • php追加写入
  • 增值税专用发票上注明的价款含税吗
  • php格式图片
  • pa等比例缩放
  • php常用的魔术方法有哪些
  • unet网络的优缺点
  • phpsubstr方法参数
  • 危废处理需要哪些手续
  • unipoint
  • tr命令详解
  • 处置固定资产清理费用影响利润吗
  • 财政零余额账户是什么
  • 摘要概括增值税专用发票的基本联次
  • 企业付的房租税费会计分录
  • 差额开票和全额开票
  • 国有划拔土地房整体可以买卖吗
  • 短信收到电子退库收入什么意思
  • 营改增后可以抵扣的进项
  • 增值税免征印花税怎么算
  • 废品收入该如何开票
  • 汇算清缴所得税的账务处理会计分录
  • 被选为工会代表
  • 发票报销抵扣税点是给谁
  • 企业搬迁安置费一般怎么赔
  • 下列项目的进项税额可以从销项税额中抵扣的是()
  • 退票费收入按什么征税
  • 什么是对公账户?
  • 收到保险公司的赔款计入什么科目
  • 暂估入库后发票来不了会计分录
  • 实收资本未到账减资要交税吗
  • 会计总账怎么做账
  • 年化收益率怎么算
  • win7系统宽带连接
  • 如何重设路由器密码怎么办
  • windows7字体安装方法
  • dx12不支持dx11解决办法
  • Mac怎么更改锁屏密码
  • xp主题怎么改成win7
  • 怎么设置虚拟硬盘储存路径
  • centos pptpd
  • windos8怎么样
  • 在linux系统中获取帮助信息的命令为
  • 使用cp命令时以下说法错误的是
  • linux终端怎么用
  • win10网络共享失败
  • cocos2d开发的知名游戏
  • android 基础
  • ipc漏洞入侵的基本步骤
  • 医疗费发票查询
  • 个人经营所得税怎么做账务处理
  • 洗煤与选煤
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设