Security Issues About HTTP and HTTPS

Security Issues About HTTP and HTTPS

 

 

Problems with ordinary HTTP requests

 

      HTTP itself is transmitted in clear text without any security processing. For example, if a user searches for a keyword on Baidu, such as "Apple phone", the intermediary can fully view this information, and may call to harass the user. There are also some users who complained that when using Baidu, they found that a long and large advertisement floated on the homepage or result page, which must be the content of the advertisement inserted by the middleman on the page. If the hijacking technology is relatively poor, users can't even access Baidu.

 

      The intermediaries mentioned here mainly refer to some network nodes, which are the nodes that user data must pass through in the transmission between the browser and the Baidu server. Such as WIFI hotspots, routers, firewalls, reverse proxies, cache servers, etc.

 

      Under the HTTP protocol, middlemen can sniff user search content at will, steal privacy and even tamper with web pages. However, HTTPS is the nemesis of these hijackings and is a completely effective defense against them.

 

      Therefore, there is HTTPS. The main purpose of using the HTTPS protocol is to protect user privacy and prevent traffic hijacking.

 

 

 

 

 

Solution

 

  • Use HTTPS (convenient, but you need to apply for a certificate)
  • Encrypt the data yourself, and change the plaintext transmission to ciphertext transmission (trouble, because you have to encrypt and decrypt it yourself, there are many steps, and it is easy to make mistakes)
  • HTTPS + own data encryption (this is the most troublesome, but safer)

 

 

 

 

Features of HTTPS

 

  • Content encryption . The content from the browser to the Baidu server is transmitted in encrypted form, and the intermediary cannot directly view the original content.
  • Authentication . Ensure that users are accessing Baidu services. Even if they are hijacked by DNS to a third-party site, users will be reminded that they have not accessed Baidu services and may be hijacked.
  • data integrity . Prevent content from being impersonated or tampered with by third parties.

 

 

 

 

HTTPS principle

 



 

The process is as follows:

    1. The client initiates an https request and sends a series of Cipher Suite (Key Algorithm Suite, Cipher for short) that it supports to the server.

 

 

    2. The server has a public key and a private key.

 

 

    3. 服务端,接收到客户端所有的Cipher后与自身支持的对比,如果不支持则连接断开,反之则会从中选出一种加密算法和HASH算法以证书的形式返回给客户端 证书中还包含了 公钥 颁证机构 网址 失效日期等等。

 

 

    4. 客户端收到服务端响应后会做以下几件事

 

      (1)验证证书的合法性

 

       颁发证书的机构是否合法与是否过期,证书中包含的网站地址是否与正在访问的地址一致等,证书验证通过后,在浏览器的地址栏会加上一把小锁(每家浏览器验证通过后的提示不一样 不做讨论)。

 

     (2)生成随机密码

 

       如果证书验证通过,或者用户接受了不授信的证书,此时浏览器会生成一串随机数,然后用证书中的公钥加密。 

 

      (3)HASH握手信息

 

       用最开始约定好的HASH方式,把握手消息取HASH值,  然后用 随机数加密 “握手消息+握手消息HASH值(签名)”  并一起发送给服务端。

 

       在这里之所以要取握手消息的HASH值,主要是把握手消息做一个签名,用于验证握手消息在传输过程中没有被篡改过。

 

 

    5. 客户端将加密后的内容传给服务端

 

 

    6. 服务端拿到客户端传来的密文,用自己的私钥来解密握手消息取出随机数密码,再用随机数密码 解密 握手消息与HASH值,并与传过来的HASH值做对比确认是否一致。

 

 

    7. 然后用随机密码加密一段握手消息(握手消息+握手消息的HASH值 )给客户端。

 

 

    8. 客户端用随机数解密并计算握手消息的HASH,如果与服务端发来的HASH一致,此时握手过程结束,之后所有的通信数据将由之前浏览器生成的随机密码并利用对称加密算法进行加密。

 

       因为这串密钥只有客户端和服务端知道,所以即使中间请求被拦截也是没法解密数据的,以此保证了通信的安全

 

 

 

 

常用加密解密算法

 

  • 非对称加密算法:RSA,DSA/DSS     在客户端与服务端相互验证的过程中用的是对称加密 
  • 对称加密算法:AES,RC4,3DES     客户端与服务端相互验证通过后,以随机数作为密钥时,就是对称加密
  • HASH算法:MD5,SHA1,SHA256  在确认握手消息没有被篡改时 

 

 

 

如何抓取HTTPS的请求数据

 

      当站点由HTTP转成HTTPS后是更安全了,但是有时候要看线上的请求数据解决问题时却麻烦了,因为是HTTPS的请求,你就算拦截到了那也是加密的数据,没有任何意义。

 

抓取流程如下:

http://www.cnblogs.com/zery/p/5164795.html

 

 

 

 

HTTPS是否真的足够安全

 

HTTPS是安全的,因为有证书和加密机制做保障!

 

但是,有个可怕的方法叫“ DNS劫持 ”,简单的说黑客为了绕过HTTPS,采用了SSL层剥离的技术,黑客阻止用户和使用HTTPS请求的网站之间建立SSL连接,使用户和代理服务器(攻击者所控制的服务器)之间使用了未加密的HTTP通信。

 

工作流程如下图:



 

 工作原理

 

     1. 客户端发送域名请求给 dns

 

     2. dns通过遍历查询dns数据库,来解析此域名对应的ip,然后反馈至浏览器客户端

 

     3. 客户端通过ip与对方建立数据连接

 

     4. 问题就出在DNS服务器上,如果用户访问的DNS服务器是黑客的,然后返回的ip也是黑客预先准备好的服务器,那么用户信息就会泄露

 

 

 

 

预防DNS劫持的方法

 

    1. 从用户的角度,防止DNS劫持

 

       (1)手动设置DNS服务器,如果是自动的就百度一下自己的DNS ip,如果是国外的就要警惕了

 

       (2)修改路由器Web登陆密码,不要用过于简单的密码,也能预防被入侵

 

       (3)注意URL是否被重写了,是否是https,是否有一把小锁

 

 

    2. 服务端通过流程去预防,不要想着用户有多聪明,会上面的配置,所以要加入自己的流程来预防。

 

        流程如下(还是需要HTTPS):

        模仿https的流程,可以看草稿箱

 

    这个流程跟HTTPS的验证流程很相似,也存在验证效果,就是因为做多了几部验证的操作,让黑客无法猜测到如何访问服务器的API,即使入侵了用户的电脑,窃取到用户的账号密码,也无法登陆系统窃取用户钱财,是跟黑客一起讨论后得出的结果。

  

 

 

中间人攻击

 

       除了DNS劫持,黑客还有其他方法能够截取用户信息,如下:

 

  • DNS劫持:黑客黑了被攻击人的DNS服务器,然后每次请求都会先转到黑客的服务器后,再转到真正的服务器
  • 会话劫持:我们可以把会话劫持攻击分为两种类型:1)中间人攻击(Man In The Middle,简称MITM),2)注射式攻击(Injection);并且还可以把会话劫持攻击分为两种形式:1)被动劫持,2)主动劫持;被动劫持实际上就是在后台监视双方会话的数据流,丛中获得敏感数据;而主动劫持则是将会话当中的某一台主机“踢”下线,然后由攻击者取代并接管会话,这种攻击方法危害非常大,攻击者可以做很多事情
  • 代理服务器

 

 

注射式攻击

 

这种方式的会话劫持比中间人攻击实现起来简单一些,它不会改变会话双方的通讯流,而是在双方正常的通讯流插入恶意数据。在注射式攻击中,需要实现两种技术:

 

  • IP欺骗
  • 预测TCP序列号

       如果是UDP协议,只需伪造IP地址,然后发送过去就可以了,因为UDP没有所谓的TCP三次握手,但基于UDP的应用协议有流控机制,所以也要做一些额外的工作。对于IP欺骗,有两种情况需要用到:1)隐藏自己的IP地址;2)利用两台机器之间的信任关系实施入侵。在Unix/Linux平台上,可以直接使用Socket构造IP包,在IP头中填上虚假的IP地址,但需要root权限;在Windows平台上,不能使用Winsock,需要使用Winpacp(也可以使用Libnet)。例如在Linux系统,首先打开一个Raw Socket(原始套接字),然后自己编写IP头及其他数据。

 

  参考  http://blog.csdn.net/maray/article/details/2937456 http://netsecurity.51cto.com/art/201303/386031.htm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326321639&siteId=291194637