Skip to content

Commit

Permalink
add draft
Browse files Browse the repository at this point in the history
  • Loading branch information
rectcircle committed Jun 5, 2021
1 parent 50e807f commit fe66b2d
Show file tree
Hide file tree
Showing 43 changed files with 622 additions and 27 deletions.
9 changes: 9 additions & 0 deletions content/posts/convergence.md
@@ -0,0 +1,9 @@
---
title: "Convergence"
date: 2021-05-22T12:10:09+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---
37 changes: 37 additions & 0 deletions content/posts/cookies-all-in-this.md
@@ -0,0 +1,37 @@
---
title: "Cookies 技术详解"
date: 2021-02-06T18:26:45+08:00
draft: true
toc: true
comments: true
tags:
- web
---

## 基本情况

* TODO
* 交互流程
* 属性和含义
* 前端设置 cookie

// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
cookieString = jwtTokenKey + "=" + jwtToken + ";path=/;max-age=" + 59 * 60
if (location.protocol === "https:") {
cookieString += ";SameSite=None;Secure"
}

## Cookie 的 应用

* 鉴权,用户登录身份Token
* 广告追踪

## Cookie 与 跨域

> [阮一峰:同源策略](http://www.ruanyifeng.com/blog/2016/04/same-origin-policy.html)
## Cookie 与 安全

## Cookie 技术未来变化

> https://zhuanlan.zhihu.com/p/131256002
11 changes: 11 additions & 0 deletions content/posts/data-security-storage.md
@@ -0,0 +1,11 @@
---
title: "数据端到端安全存储"
date: 2021-05-22T18:35:20+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---

https://github.com/minio/sio
14 changes: 14 additions & 0 deletions content/posts/design-and-scheme.md
@@ -0,0 +1,14 @@
---
title: "方案与设计"
date: 2021-03-17T11:10:07+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---

* 向前兼容/向后兼容
* 可测试性、组合与依赖注入
* 可重入:重启可重入,幂等
* 不要自己预测未来可能的需求而写无用的代码
4 changes: 2 additions & 2 deletions content/posts/flink.md
Expand Up @@ -343,7 +343,7 @@ public class SocketWindowWordCount {
**使用 nc 创建 Socket Server**

```bash
nc -l 9000
nc -lv -p 6787
```

**调试运行**
Expand Down Expand Up @@ -466,7 +466,7 @@ object SocketWindowWordCount {
**使用 nc 创建 Socket Server**

```bash
nc -l 9000
nc -lv -p 6787
```

**提交任务**
Expand Down
4 changes: 2 additions & 2 deletions content/posts/fq备忘.md
Expand Up @@ -31,9 +31,9 @@ mac homebrew-v2ray `vim /usr/local/etc/v2ray/config.json`

```bash
# 手动运行查看问题
cat /usr/local/opt/v2ray-core/homebrew.mxcl.v2ray-core.plist
cat /usr/local/opt/v2ray/homebrew.mxcl.v2ray-core.plist
# 重启
brew services restart v2ray-core
brew services restart v2ray
```

### cloudflare(CDN)+ws+tls
Expand Down
70 changes: 66 additions & 4 deletions content/posts/http-csrf.md
Expand Up @@ -8,10 +8,72 @@ tags:
- 安全
---

> http://www.ruanyifeng.com/blog/2016/04/cors.html
## 理解 HTML 的 Form 和 JavaScript 的 Ajax

一般出现在传统的Form表单的网页交互方式中,因为Form表单的交互不受同源策略(`CORS`)控制
1998 年前后几年,HTML4.01 和 Ajax 相继出现

因此钓鱼网站可以利用此特性进行攻击
在 2005 左右 Ajax 才成为一种比较主流的技术。在此之前,主流网站的交互式大多数是通过 Form 表单来实现。

现代网站使用Ajax交互的情况下一般不会存在`CSRF`攻击,因为有 `CORS` 策略
Web 交互主要是依靠这两种技术进行的。下面介绍下 Web 交互的技术演进

### Web 交互技术演进

#### 原始 Form

Form 是 HTML 的一个特殊的标签,在用户点击了 Form 表单内部的 submit 按钮后,浏览器会,并将 Form 用户输入的值作为参数,发起一次 HTTP 请求。

Server 端接收到请求后,根据情况返回新的 HTML 页面即可,浏览器会自动渲染页面。

此时阶段的技术特点是

* 以页面为粒度进行开发
* 采用模板引擎技术

#### Form Ajax 混合模式

由于 Form 表单存在的固有问题,每次交互都需要刷新页面,重新渲染整个页面,对于复杂交互的系统,基本无法实现。

因此 许多复杂 系统开始逐渐采用 Ajax 技术,动态请求数据。但是由于旧开发模式的历史惯性和并没有真正意义上的前端开发人员,所以此阶段的技术特点是

* 仍以页面为粒度进行开发
* 采用模板引擎技术
* 页面上部分功能采用 Ajax 技术

#### Web APP 模式

随着 Web 技术的演进,现在复杂 Web 系统的架构均采用前后端分离的模式,纯粹以 Ajax 技术进行交互。此时的技术特点为

* 后端以接口/API粒度进行开发
* 仅需要返回数据而不用返回 HTML
* 完全使用 Ajax 技术

### Ajax 请求 和 Form 请求的关系

* Form 支持的请求称为 **简单请求**
* Ajax 和 Form 存在交集,交集的部分为:**简单请求**,为了兼容,Ajax 的简单请求和 Form 基本一致
* Ajax 支持更复杂的请求类型,其行为是 JavaScript 标准
* Form 请求行为是 HTML 标准

## Form 表单中的 CSRF 漏洞

参见:[阮一峰博客](http://www.ruanyifeng.com/blog/2016/04/cors.html)

几个要点

* 因为 Ajax 可以理解为 Form

才漏洞主要场景是:钓鱼网站,恶意链接

## 额外说明

以上描述的 Web APP 模式下,完全使用 Ajax 交互技术的站点中,如果满足如下条件,则不会出现 CSRF 问题:

* 不使用 GET 操纵数据
* 其他方法不接受,`Content-Type``application/x-www-form-urlencoded``multipart/form-data``text/plain` 的请求(即不允许使用简单请求)
* `CORS` 没有向恶意站点开启

## CORS

CORS 和 CSRF 存在一定的相关性。

冠以 CORS,参见:[阮一峰博客](http://www.ruanyifeng.com/blog/2016/04/cors.html)
2 changes: 1 addition & 1 deletion content/posts/java远程调试.md
Expand Up @@ -169,7 +169,7 @@ cd tomcat目录/bin

```bash
# docker 创建 一个 TCP Server
nc -l -p 15005
nc -lv -p 15005
# 本地连接测试
telnet docker_ip docker暴露端口
nc -vz -w 2 docker_ip docker暴露端口
Expand Down
9 changes: 9 additions & 0 deletions content/posts/linux-ssh-x11-forwarding.md
@@ -0,0 +1,9 @@
---
title: "Linux Ssh X11 Forwarding"
date: 2021-03-13T18:49:11+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---
2 changes: 2 additions & 0 deletions content/posts/linux速查.md
Expand Up @@ -735,6 +735,8 @@ nmtui #配置,似乎不需要重启网络服务,可配置多个,激活一
#### (13)`tcpdump -i eth0 -nnX port 80` 抓包
#### (14) `nc -lv -p $PORT` 监听 TCP 端口
### 2、网络相关配置文件
#### (1)网卡信息文件`/etc/sysconfig/network-scripts/ifcfg-网卡名`
Expand Down
9 changes: 9 additions & 0 deletions content/posts/netcat-and-http-chunked-invaild.md
@@ -0,0 +1,9 @@
---
title: "netcat 使用:一次失败的 HTTP chunked 上传文件 Debug"
date: 2021-06-03T17:37:16+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---
17 changes: 15 additions & 2 deletions content/posts/shell编程.md
Expand Up @@ -920,10 +920,11 @@ esac
### 如果字符串不存在则添加到文件中

```bash
# grep -F 表示原样字符串
# 添加到文件尾部
grep -q '[[ -r /etc/profile ]] && . /etc/profile' ~/.bashrc || echo '[[ -r /etc/profile ]] && . /etc/profile' >> ~/.bashrc
grep -q -F '[[ -r /etc/profile ]] && . /etc/profile' ~/.bashrc || echo '[[ -r /etc/profile ]] && . /etc/profile' >> ~/.bashrc
# 添加到文件首部
grep -q '[[ -r ~/.bashrc ]] && . ~/.bashrc' ~/.zshrc || printf '%s\n%s\n' '[[ -r ~/.bashrc ]] && . ~/.bashrc' "$(cat ~/.zshrc)" > ~/.zshrc
grep -q -F '[[ -r ~/.bashrc ]] && . ~/.bashrc' ~/.zshrc || printf '%s\n%s\n' '[[ -r ~/.bashrc ]] && . ~/.bashrc' "$(cat ~/.zshrc)" > ~/.zshrc
```

### 网络请求和json解析
Expand Down Expand Up @@ -955,6 +956,18 @@ curl -fsSL <url> -o <写入文件>
curl -fsSL https://get.docker.com | sudo sh
```

### 字符串输出到没权限的文件

```bash
echo "abc" | sudo tee filepath
```

### apt 脚本中使用(非交互)

```bash
DEBIAN_FRONTEND=noninteractive apt-get install -q -y xxx
```

## 八、zsh

### 0、安装配置参见
Expand Down
9 changes: 9 additions & 0 deletions content/posts/socket.io.md
@@ -0,0 +1,9 @@
---
title: "Socket io"
date: 2021-05-22T12:09:48+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---
13 changes: 13 additions & 0 deletions content/posts/unix-non-privileged-user-exec-as-root.md
@@ -0,0 +1,13 @@
---
title: "Unix程序让普通用户以Root权限执行的实现方法"
date: 2021-04-04T19:41:35+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---

https://www.jianshu.com/p/be7d77068b44

https://www.anquanke.com/post/id/86979
26 changes: 26 additions & 0 deletions content/posts/web-secure.md
@@ -0,0 +1,26 @@
---
title: "Web 安全"
date: 2021-02-06T18:57:39+08:00
draft: true
toc: true
comments: true
tags:
- 安全
---

## 如何思考 Web 安全问题

首先,要明确的一点,**世界上没有绝对的安全**。所有的安全都是有前提条件的。

因此一般而言,在思考 Web 安全问题时,一定要预设限制条件。

* 比如我们的网络连接不会被监听(因为我们开启了 HTTPS)
* 不考虑用户设备被黑客操纵的情况

另外,安全问题就是一场分防守者和攻击者的博弈游戏。

作为防守者最重要的不是防止攻击的手段,而是要理解攻击的原理,只要理解了攻击原理,防范手段自然就可以得到。

## 常见的难以避免的 Web 攻击方式

* 钓鱼网站
28 changes: 28 additions & 0 deletions content/posts/websocket.md
@@ -0,0 +1,28 @@
---
title: "Websocket"
date: 2021-05-22T12:09:22+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---

https://datatracker.ietf.org/doc/html/rfc6455
https://www.infoq.cn/article/deep-in-websocket-protocol

## 介绍

### 是什么

### 适用场景及优点

### 其他技术对比

### 缺点

## 样例

## 模型与编程接口

## 原理与协议
17 changes: 1 addition & 16 deletions content/posts/备忘小技巧.md
Expand Up @@ -65,24 +65,9 @@ npm 全局安装最好使用`--unsafe-perm`选项

#### SSH直接执行脚本环境变量的问题

> [博客1](https://www.cnblogs.com/zhenyuyaodidiao/p/9287497.html)
> [博客2](http://feihu.me/blog/2014/env-problem-when-ssh-executing-command-on-remote/)
Hadoop Spark这种通过SSH启动集群的分布式系统可能出现的问题

SSH直接执行远程命令和脚本,此时模式为:non-interactive + non-login shell

* 将会执行`~/.bashrc`文件
* 如果存在`BASH_ENV` 环境变量,将会执行该环境变量指向的值

最佳实践

将全局环境变脸写在`/etc/profile`
`~/.bashrc`中添加如下内容

```bash
export BASH_ENV=/etc/profile
```
参见 [Linux Shell 初始化文件 —— 环境变量写在哪里?](/posts/linux-shell-initialization-files/)

#### mac 自动挂载NTFS U盘

Expand Down
8 changes: 8 additions & 0 deletions content/series/cloud-service-provider/_index.md
@@ -0,0 +1,8 @@
---
title: "云服务提供商产品探索"
date: 2021-04-10T10:47:00+08:00
draft: false
type: series
---

探索各大云服务厂商的各种产品能提供的能力、使用场景、价格、底层原理
9 changes: 9 additions & 0 deletions content/series/cloud-service-provider/app-vm.md
@@ -0,0 +1,9 @@
---
title: "应用服务器(轻量级应用服务器)"
date: 2021-04-10T11:01:55+08:00
draft: true
toc: true
comments: true
weight: 200
summary: 摘要
---
9 changes: 9 additions & 0 deletions content/series/cloud-service-provider/container-instance.md
@@ -0,0 +1,9 @@
---
title: "云厂商——容器实例"
date: 2021-04-10T10:56:10+08:00
draft: true
toc: true
comments: true
weight: 400
summary: 摘要
---
9 changes: 9 additions & 0 deletions content/series/cloud-service-provider/physical-machine.md
@@ -0,0 +1,9 @@
---
title: "物理机(裸金属)"
date: 2021-04-10T10:56:10+08:00
draft: true
toc: true
comments: true
weight: 300
summary: 摘要
---

0 comments on commit fe66b2d

Please sign in to comment.