HTTPS -01

该博客通过实例演示了网站被劫持的过程,强调了HTTPS在数据传输安全中的重要性。作者配置了一个正常网站,并模拟了网站被中间人攻击的情况,展示了HTTP协议下数据易被篡改的脆弱性。然后,讨论了HTTPS证书的下发流程,以及HTTP流量的不安全性,突显了切换到HTTPS协议对于保护用户信息安全的必要性。
摘要由CSDN通过智能技术生成

HTTPS

一、HTTPS介绍
## 1.概述

为什么需要使用HTTPS,因为HTTP不安全,当我们使用http网站时,会被黑客的劫持和篡改,如果采用https协议,那么数据在传输过程中是加密的,所以HTTPS安全的!

在这里插入图片描述

2.模拟网站劫持
# 1、配置一个正常网站
[root@web01 ~]# vim /etc/nginx/conf.d/linux12.jc.com.conf
server {
    listen 80;
    server_name linux12.jc.com;

    location / {
        root /mm;
        index index.html;
    }
}

# 2、配置一个正经页面
[root@web01 ~]# vim /mm/index.html
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>LOVE YOU</title>

<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css" >

<script src="http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js" ></script>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

</head>

<body>

<div class="container">

<div class="row col-md-3"></div>

<div class="row col-md-6" >

<div class="row question">

<div class="col-md-6 col-xs-12">

<p style="line-height: 50px;font-size: 10px;">“小萍萍,我观察你很久了”</p>

<p style="line-height: 50px;font-size: 20px;">做我女朋友好不好?</p>

</div>

<div class="col-md-6 col-xs-12">

<img src="http://ozef40uqu.bkt.clouddn.com/1.png" alt="" style="height: 200px;">

</div>

</div>

<div class="row question" style="margin-top: 20px;">

<div class="col-md-6 col-xs-6" style="text-align: center;">

<button type="button" class="btn btn-success" style="width: 80%" id="no">好</button>

</div>

<div class="col-md-6 col-xs-6" style="text-align: center;">

<button type="button" class="btn btn-danger" style="width: 80%" id="ok">不好</button>

</div>

</div>

<div class="col-md-12 col-xs-12 hide" id="success">

<img src="http://ozef40uqu.bkt.clouddn.com/666.jpg" alt="" style="width: 100%;">

</div>

</div>

<div class="row col-md-3"></div>

</div>

<script>

var i=1;

var ok=false;

$(document).ready(function(){

$("#no").click(function(){

alert("真的吗?你答应了?");

alert("给我发消息吧,爱你");

$(".question").addClass('hide');

$("#success").removeClass('hide');

ok=true;

});

$("#ok").click(function(){

switch(i){

case 1:

alert("工资上交");

break;

case 2:

alert("家务全包");

break;

case 3:

alert("房产证写你的名字");

break;

case 4:

alert("保大");

break;

case 5:

alert("我妈会游泳");

break;

case 6:

alert("不跟你吵架,会撒娇 会卖萌");

break;

default:

alert("答应我吧");

}

i++;

});

});

</script>

</body>

</html>

## 授权
[root@web01 ~]# chown -R  www.www /mm/

## nginx -t检查并重启
[root@web01 ~]# systemctl restart nginx
3.配置本地hosts
10.10.0.7  linux12.jc.com
# 4.被配置劫持的网站
1.配置文件
[root@lb01 ~]# vim /etc/nginx/conf.d/linux12.jc.com.conf
server {
    listen 80;
    server_name linux12.jc.com;

    location / {
        proxy_pass http://10.10.0.7:80;
        include proxy_params;
    }
}
2.授权并检查
## 授权
[root@web01 ~]# chown -R www.www /mm/
## nginx -t检查并重启
[root@web01 ~]# systemctl restart nginx	
3.配置本地hosts
1、篡改hosts测试
10.10.0.7 linux12.jc.com
4.篡改网站
[root@lb01 conf.d]# cat linux12.jc.com.conf 
server {
    listen 80;
    server_name linux12.jc.com;

    location / {
        proxy_pass http://10.10.0.7:80;
        include proxy_params;
    sub_filter '<title>LOVE YOU</title>' <title>霉霉</title> ;

    }
}

## nginx -t检查并重启
[root@web01 ~]# systemctl restart nginx
5.重启配置本地hosts
10.10.0.5 linux12.jc.com
6.HTTPS证书下发流程

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TLB4qoOf-1617875662917)(C:\Users\17155\Desktop\下载图片\1617800341441.png)]

7 HTTP 流程在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是Python代码实现: ```python import requests from bs4 import BeautifulSoup import time # 设置请求头 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} # 获取每一页的URL urls = [] for i in range(1, 224): # 总共223页 url = 'https://guba.eastmoney.com/list,603569_{}.html'.format(i) urls.append(url) # 遍历每一页,获取帖子信息 for url in urls: res = requests.get(url, headers=headers) res.encoding = 'utf-8' soup = BeautifulSoup(res.text, 'html.parser') # 获取帖子列表 posts = soup.select('.articleh') # 遍历每个帖子,获取信息 for post in posts: # 提取信息 title = post.select('a')[0].text link = 'https://guba.eastmoney.com' + post.select('a')[0]['href'] author = post.select('.l1')[0].text read_num = post.select('.l2')[0].text comment_num = post.select('.l3')[0].text time_str = post.select('.l5')[0].text # 时间格式化 time_array = time.strptime(time_str, "%Y-%m-%d %H:%M:%S") publish_time = time.strftime("%Y-%m-%d %H:%M:%S", time_array) # 输出结果到文件 with open('data_guba_cjwl.txt', 'a', encoding='utf-8') as f: f.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format(author, publish_time, read_num, comment_num, title, link)) ``` 代码解释: 1. 首先,我们设置请求头,避免被网站反爬虫机制拦截。 2. 然后,我们获取每一页的URL,一共有223页,存储在`urls`列表中。 3. 接着,我们遍历每一页,发起请求,获取帖子列表,使用BeautifulSoup解析HTML,获取每个帖子的信息。 4. 最后,我们提取帖子的标题、链接、作者、阅读量、评论数、发帖时间等信息,并将其写入文件中。 请注意,该代码执行时间较长,因为要抓取的页面较多,建议您在网络状况较好的情况下执行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FikL-09-19

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值