Skip to content

Instantly share code, notes, and snippets.

View dfang's full-sized avatar
🎯
Focusing

fang duan dfang

🎯
Focusing
View GitHub Profile
(cors) {
        @cors_preflight{args.0} method OPTIONS
        @cors{args.0} header Origin {args.0}
        # @cors{args.0} header Origin "{args.0} Vary Origin"
        # You should always append Vary: Origin header when you want to use multiple URLs, see: fetch.spec.whatwg.org/#cors-protoc ol-and-http-caches
        handle @cors_preflight{args.0} {
                header {
                        Access-Control-Allow-Origin "{args.0}"
                        Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
@dfang
dfang / proxy.md
Created June 29, 2023 15:24 — forked from yougg/proxy.md
complete ways to set http/socks/ssh proxy environment variables

set http or socks proxy environment variables

# set http proxy
export http_proxy=http://PROXYHOST:PROXYPORT

# set http proxy with user and password
export http_proxy=http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT

# set http proxy with user and password (with special characters)
@dfang
dfang / readme.md
Created June 13, 2023 10:23 — forked from SanariSan/readme.md
Telegram HTTP bot API via CURL | Send text, photos, documents, etc.

Here are some examples on how to use Telegram bot api via CURL

Prerequisites

For getting messages in private chat with bot

  • Create a bot using @BotFather, get it's token
  • Start conversation with bot
  • Run following curl command
curl https://api.telegram.org/bot/getUpdates | grep -Po '"from":{"id":.+?,'
@dfang
dfang / useradd.sh
Created June 13, 2023 03:37 — forked from igorvoltaic/useradd.sh
Create new user using command line in Mac OS X. Do not forget to set correct permissions for the file.
#!/bin/sh
if [[ `id -u` != 0 ]]; then
echo "Must be root to run script"
exit
fi
read -p "Enter user name and press [ENTER]: " UserName
if [[ $UserName == `dscl . -list /Users UniqueID | awk '{print $1}' | grep -w $UserName` ]]; then
@dfang
dfang / jd_auto_order.js
Created December 12, 2020 04:41
jd auto order
// ==UserScript==
// @name jd抢购
// @namespace http://violentmonkey.github.io/
// @version 0.1
// @description jd 自动下单
// @author dfang
// @match *://cart.jd.com/*
// @match *://item.jd.com/*
// @match *://trade.jd.com/*
// @grant none
@dfang
dfang / Traffic analysis survey.md
Created November 30, 2020 02:38 — forked from klzgrad/Traffic analysis survey.md
流量分类调研

为什么流量可以进行分类

这里的“流量”一般定义为中间人观测到的一组由(时间,方向,包大小)元数据组成的序列 [Cai2014]。其源头是应用层的读写操作,经过传输层协议的变换(分片、协议状态机、加密等),流量序列产生一定变化。但是这种变化非常有限,因为流量的发生过程本质是确定性的,随机因素较小,因此对于特定环境中的特定应用(浏览器访问 google.com)各种流量特征体现出相当大的一致性和独特性,这就使“从流量特征识别应用”的监督学习问题成为可能。虽然有若干不利因素使得确定性下降,例如多层次上软件多版本的排列组合爆炸、有状态的缓存、流水线和连接复用、用户随机行为,但是因为版本的幂律分布、应用层读写操作间的依赖关系、流量特征和检测算法的改进等原因,分类依然具有相当的可行性。

分类的对象:流量应用分类与网站指纹攻击

根据分类的对象产生了两个相近但是不同的研究领域。从流量特征中分类应用类型的被称为流量分类(traffic classification),从流量特征中分类所访问网站或者网页的被称为网站指纹(website fingerprinting)。以机器学习的方法而论前者是比后者更弱但本质相同的一个问题。

这两类攻击的威胁类型不同。流量分类威胁的是可用性,如果GFW检出流量是隧道应用然后进行封锁,则破坏了可用性。而网站指纹威胁的是匿名性和隐私,如果从隐秘流量中检出是谁在访问哪个网站,则破坏了匿名性,丝绸之路就是这样被FBI破获的。

@dfang
dfang / .gitlab-ci.yml
Created November 2, 2020 04:10 — forked from tvvignesh/.gitlab-ci.yml
Example on running Skaffold with GITLAB CI for Kubernetes in GKE (Make sure you modify it appropriately and set GCP_SERVICE_KEY and GCP_PROD_SERVICE_KEY variable in Gitlab with the service account json value)
services:
- docker:dind
stages:
- development
- production
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
@dfang
dfang / whoami.ingressroute.yaml
Created November 1, 2020 03:18
traefik IngressRoute
############
############
# REDIRECT TO HTTPS MIDDLEWARE
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirect-http-to-https
spec:
@dfang
dfang / harbor.sh
Last active October 31, 2020 11:00 — forked from kacole2/harbor.sh
Quick Start Harbor Installation Script on Ubuntu 18.04
#!/bin/bash
#Harbor on Ubuntu 18.04
#Prompt for the user to ask if the install should use the IP Address or Fully Qualified Domain Name of the Harbor Server
PS3='Would you like to install Harbor based on IP or FQDN? '
select option in IP FQDN
do
case $option in
IP)