2020年12月1日 星期二

2020年1月8日 星期三

ebtable staudy


ebtables

默認有三個Table (filter,nat,broute)

filter 內建三個chain:INPUT/OUTPUT/FORWARD

nat 內建三個chain:PREROUTING/OUTPUT/POSTROUTING

broute內建一個chain : BROUTING



*顯示table

ebtables [-t filter] -L 顯示filter table的內容,默認也是顯示該table

ebtables -t broute -L 顯示broute table的內容

ebtables -t nat -L 顯示nat table的內容



增加一個chain

ebtables -t filter -N newChain -P ACCEPT



但此時不會有封包走到此chain,須將 chain 加到 linux 內建的 hook chain上

ebtables -t filter -A INPUT -j newChain 


ebtables -t filter -L

Bridge chain: INPUT, entries: 1, policy: ACCEPT

-j newChain 



ebtables [-t table ] -[ACDI] chain rule specification [match extensions] [watcher extensions] target    // append, delete, change-counters, insert

ebtables [-t table ] -P chain ACCEPT | DROP | RETURN                                                                      // policy, Set the policy for the chain to the given target

ebtables [-t table ] -F [chain]                                                                                                           // flush, Flush the selected chain

ebtables [-t table ] -Z [chain]                                                                                                           // zero, Set the counters of the selected chain to zero

ebtables [-t table ] -L [-Z] [chain] [ [--Ln] | [--Lx] ] [--Lc] [--Lmac2]                                                  // list, List all rules in the selected chain. If no chain is selected, all chains are listed.

                              // -L -Z , When both the -Z and -L commands are used together in this way, the rule counters are printed on the screen before they are set to zero.

                              // -L --Ln, Shows the counters at the end of each rule displayed by the -L command.

ebtables [-t table ] -N chain [-P ACCEPT | DROP | RETURN]                                                               // new-chain

ebtables [-t table ] -X [chain]                                                                                                           // delete-chain

ebtables [-t table ] -E old-chain-name new-chain-name                                                                    // rename-chain

ebtables [-t table ] --init-table                                                                                                         // Replace the current table data by the initial table data

ebtables [-t table ] [--atomic-file file] --atomic-commit

ebtables [-t table ] [--atomic-file file] --atomic-init

ebtables [-t table ] [--atomic-file file] --atomic-save





ebtables [-t table ] -[ACDI] chain rule specification [match extensions] [watcher extensions] target

ebtables [-t table ] -P chain ACCEPT | DROP | RETURN

ebtables [-t table ] -F [chain]

ebtables [-t table ] -Z [chain]

ebtables [-t table ] -L [-Z] [chain] [ [--Ln] | [--Lx] ] [--Lc] [--Lmac2]

ebtables [-t table ] -N chain [-P ACCEPT | DROP | RETURN]

ebtables [-t table ] -X [chain]

ebtables [-t table ] -E old-chain-name new-chain-name

ebtables [-t table ] --init-table

ebtables [-t table ] [--atomic-file file] --atomic-commit

ebtables [-t table ] [--atomic-file file] --atomic-init

ebtables [-t table ] [--atomic-file file] --atomic-save




2019年6月26日 星期三

Win10 快捷整理

切換窗口(不是新的,但任務切換介面改進):
Alt+Tab


WIN 鍵

Win10新增的功能快捷鍵:

*貼靠窗口(窗口可以變為 1/4 大小放置在螢幕 4 個角落)
Win+←:最大化窗口到左側的螢幕上(與開始螢幕應用無關)

Win + →:最大化窗口到右側的螢幕上(與開始螢幕應用無關)

Win+ ↑:最大化窗口(與開始螢幕應用無關)

Win+ ↓:最小化窗口(與開始螢幕應用無關)

Win+ SHIFT +↑:垂直拉伸窗口,寬度不變(與開始螢幕應用無關)

Win+ SHIFT +↓:垂直縮小窗口,寬度不變(與開始螢幕應用無關)

Win+SHIFT+←:將活動窗口移至左側顯示器 (與開始螢幕應用無關)

Win+SHIFT+→:將活動窗口移至右側顯示器(與開始螢幕應用無關)


*任務視圖(鬆開鍵盤介面不會消失):
Win+Tab


*創建新的虛擬桌面:
Win+Ctrl+D

*關閉當前虛擬桌面:
Win+Ctrl+F4

*切換虛擬桌面:
Win+Ctrl+左/右


Win+P:投影多螢幕設定

Win+ Home:最小化所有窗口,第二次鍵擊恢復窗口(不恢復開始螢幕應用)

Win+ 數字鍵:打開或切換位於任務欄指定位置的程序

Win+Shift+數字鍵:打開位於任務欄指定位置程序的新實例

Win+B:光標移至通知區域

Win+D:顯示桌面,第二次鍵擊恢復桌面 (不恢復開始螢幕應用)

Win+E:打開我的電腦

Win+G:遊戲列

Win+L:鎖住電腦或切換用戶

Win+M:最小化所有窗口

Win+Shift+M:在桌面恢復所有最小化窗口(不恢復開始螢幕應用)

Win+R:打開「運行」對話框

Win+T:切換任務欄上的程序

Win+S:搜尋程式

Win+空格鍵:切換輸入語言和鍵盤布局

Win+,:臨時查看桌面

Win+I:打開設置欄

Win+K:打開無線連接顯示屏

Win+Tab:循環切換應用


Win+/:恢復默認輸入法

Win+J:顯示之前操作的應用

Win+X:快捷菜單


Ctrl+Shift+Esc:打開任務管理器(工作管理員)

Ctrl+A 全選

Ctrl+C(或 Ctrl+Insert) 複製選擇的項目

Ctrl+X 剪切選擇的項目

Ctrl+V(或 Shift+Insert) 粘貼選擇的項目

Ctrl+Z 撤消操作

Ctrl+Y 重新執行某項操作

Ctrl+向右鍵 將光標移動到下一個字詞的起始處

Ctrl+向左鍵 將光標移動到上一個字詞的起始處

Ctrl+向下鍵 將光標移動到下一個段落的起始處

Ctrl+向上鍵 將光標移動到上一個段落的起始處

Ctrl+Shift 加某個箭頭鍵 選擇一塊文本

Shift 加任意箭頭鍵 在窗口中或桌面上選擇多個項目,或者在文檔中選擇文本

Ctrl 加任意箭頭鍵+空格鍵 選擇窗口中或桌面上的多個單個項目

Ctrl+A 選擇文檔或窗口中的所有項目


Alt+F4 關閉活動項目或者退出活動程序

Alt+空格鍵 為活動窗口打開快捷方式菜單

Ctrl+F4 關閉活動文檔(在允許同時打開多個文檔的程序中)

Ctrl+Alt+Tab 使用箭頭鍵在打開的項目之間切換

Ctrl+滑鼠滾輪 更改桌面上的圖標大小

Win鍵 + Tab 使用 Aero Flip 3-D 循環切換任務欄上的程序

Ctrl + Win鍵 + Tab 通過 Aero Flip 3-D 使用箭頭鍵循環切換任務欄上的程序

Alt+Esc 以項目打開的順序循環切換項目

Win10常用Win快捷鍵:

Win鍵桌面與開始菜單切換按鍵

Ctrl+Alt+Del快速打開任務管理器

Alt+F4關機快捷鍵



Alt+Enter 顯示所選項的屬性

Alt+F4 關閉活動項目或者退出活動程序

Alt+空格鍵 為活動窗口打開快捷方法菜單

Ctrl+F4 關閉活動文檔(在允許同時打開多個文檔的程序中)


F5 刷新活動窗口


Esc 取消當前任務

Ctrl+Shift+Esc 打開任務管理器

插入 CD 時按住 Shift 阻止 CD 自動播放

文本類對話框類快捷鍵:

Ctrl+Tab 在選項卡上向後移動

Ctrl+Shift+Tab 在選項卡上向前移動

Tab 在選項上向前移動

Shift+Tab 在選項上向後移動

Alt+Tab 多任務窗口切換

Win + Tab 帶有3D效果的多任務窗口切換 (Win7旗艦版、專業版可用)

Win +Ctrl+ Tab 帶有3D效果的多任務窗口切換(Win7旗艦版、專業版可用)

Alt+加下劃線的字母 執行與該字母匹配的命令(或選擇選項)

Enter 對於許多選定命令代替單擊滑鼠

空格鍵 如果活動選項是複選框,則選中或清除該複選框

箭頭鍵 如果活動選項是一組選項按鈕,則選擇某個按鈕

2018年8月28日 星期二

安裝 shadowsock server

Synology DSM6.21

#介紹
https://zh.wikipedia.org/wiki/Shadowsocks

#git位置 shadowsock python
https://github.com/dgkang/shadowsocks-python


1.先安裝 python2 or python3皆可

2.安裝 python套件包 pip  (ubuntu:apt-get install python-pip)
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
https://bootstrap.pypa.io/

3.pip 安裝 shadowsocks
pip install shadowsocks

4.
vi /etc/shadowsocks.json

{

    "local_address": "127.0.0.1",
    "local_port":1080,
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
    "timeout":600,
    "method":"aes-256-cfb",
    "fast_open":false
}

其中
    "port_password":{
    "6655":"nguguest",
    "8080":"nguguest"
    },
是設定server port 對應的 password
這邊沒有設定serverIP 因為不需要

5.

*ssserver -c /etc/shadowsocks.json遇到error
RuntimeError: can not find library crypto 
自行修改/usr/lib/python2.7/ctypes/util.py
拿個發行版的來取代

*遇到Exception: libcrypto(OpenSSL) not found
參考https://ningselect.com/2018/05/01/synologyshadowsocks
修改 註解掉以下紅色四行
sudo vi /usr/lib/python2.7/site-packages/shadowsocks/crypto/util.py
 56     for name in lib_names:
 57         if os.name == "nt":
 58             paths.extend(find_library_nt(name))
 59 #        else:
 60 #            path = ctypes.util.find_library(name)
 61 #            if path:
 62 #                paths.append(path)

*
2020 update
最近重裝遇到另一個新error
TypeError: find_library() takes exactly 1 argument (3 given)
  File "/usr/lib/python2.7/site-packages/shadowsocks/crypto/openssl.py", line 41, in load_openssl
    raise Exception('libcrypto(OpenSSL) not found')
Exception: libcrypto(OpenSSL) not found

sudo -i 後進入root即可
ssserver -c /etc/shadowsocks.json -d start
(我直接sudo 不能,應該是lib path 的問題,沒有繼續trace)

6.連線試試 後臺啟動
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
ssserver -c /etc/shadowsocks.json -d restart


2018年6月7日 星期四

svn 舊版安裝 (非 root)

ref.https://superuser.com/questions/929965/subversion-1-8-13-installation-without-root

http://www.cnblogs.com/xlmeng1988/p/3431321.html

cd $HOME
mkdir custom_installed
cd custom_installed
# Install apr
wget ftp://mirror.switch.ch/mirror/apache/dist//apr/apr-1.5.2.tar.gz
tar xvfz apr-1.5.2.tar.gz
cd apr-1.5.2
./configure —prefix=$HOME/custom_installed
make
make test
make install
cd ..

# Install apu
wget ftp://mirror.switch.ch/mirror/apache/dist//apr/apr-util-1.5.4.tar.gz
tar xvfz apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed
make
make test
make install
cd ..


wget http://apache.claz.org/subversion/subversion-1.8.13.tar.gz
tar xvfz subversion-1.8.13.tar.gz
cd subversion-1.8.13
wget http://www.sqlite.org/sqlite-amalgamation-3071501.zip
unzip sqlite-amalgamation-3071501.zip
mv sqlite-amalgamation-3071501 sqlite-amalgamation
./configure --prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed --with-apr-util=$HOME/custom_installed
make

make clean
./configure —prefix=$HOME/custom_installed --with-apr=$HOME/custom_installed/bin/apr-1-config --with-apr-util=$HOME/custom_installed/bin/apu-1-config



2018年2月13日 星期二

ftrace

https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace1/
https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace2/
https://www.ibm.com/developerworks/cn/linux/l-cn-ftrace3/index.html


http://blog.csdn.net/scarecrow_byr/article/details/17741809

https://zhuanlan.zhihu.com/p/22130013


#先關閉tracing
echo 0 > tracing_on
#清除trace
echo  1 > trace
#啟用function_graph
echo function_graph  > current_tracer
echo function1 funtion2 > set_graph_function
#開啟tracing
echo 1 > tracing_on
#不確定要不要開
echo 1 > /proc/sys/kernel/stack_tracer_enabled
echo 1 > /proc/sys/kernel/ftrace_enabled

執行function

#查看執行結果和所花費時間
cat trace

#關閉tracing
echo 0 > tracing_on

2018年1月10日 星期三

linux kernel printk

https://www.kernel.org/doc/Documentation/printk-formats.txt

16進位e自動顯示0x
pintk( " %#x " ,hex);

常用
int %d or %x
unsigned int %u or %x
long %ld or %lx
unsigned long %lu or %lx
long long %lld or %llx
unsigned long long %llu or %llx
size_t %zu or %zx
ssize_t %zd or %zx
s32 %d or %x
u32 %u or %x
s64 %lld or %llx
u64 %llu or %llx


MAC
%pM 00:01:02:03:04:05
%pMF 00-01-02-03-04-05

IPv4
%pI4 1.2.3.4
%pi4 001.002.003.004
%p[Ii]4[hnbl]
The additional ``h``, ``n``, ``b``, and ``l`` specifiers are used to specify
host, network, big or little endian order addresses respectively. Where
no specifier is provided the default network/big endian order is used.

IPv6
%pI6 0001:0002:0003:0004:0005:0006:0007:0008
%pi6 00010002000300040005000600070008
%pI6c 1:2:3:4:5:6:7:8