Skip to content

Instantly share code, notes, and snippets.

View dfang's full-sized avatar
🎯
Focusing

fang duan dfang

🎯
Focusing
View GitHub Profile
@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 / 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 / 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)
@dfang
dfang / rsync_from_server.md
Last active January 1, 2020 07:08 — forked from lgloege/rsync_from_server.md
Use rsync to copy from a server with bastion server between them. Does not require scp or ssh tunneling.

Setup keyless login

  1. On local make an RSA key if you haven't already (ssh-keygen)
  2. Copy that key into .ssh/authorized_keys on the first (i.e. bastion) server (ssh-copy-id user@bastion.server) 2b. Test that you can ssh user@bastion.server and connect without password
  3. ssh to bastion.server and create an RSA key on bastion.server if you haven't already (ssh-keygen)
  4. ssh-copy-id to the server you want to access (what I am calling real.server) 4b. test that you can ssh from bastion.server to real.server without entering a password

To copy from server to local

rsync -e "ssh user@bastion.server ssh" user@real.server:/path/to/file /path/to/local/dest

@dfang
dfang / curl.md
Created December 15, 2019 06:49 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dfang
dfang / psql_useful_stat_queries.sql
Created July 4, 2019 08:19 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables