公告版位

目前分類:常用指令區 (4)

瀏覽方式: 標題列表 簡短摘要

直接使用javascript的話, 我們可以這樣寫:

window.location = "url_to_redirect";

這樣的結果類似滑鼠點擊連結, 會在瀏覽器的瀏覽歷史留下原網址的記錄.

也可以這麼寫:

window.location.href = "url_to_redirect";

如此與上例一樣類似滑鼠點擊連結.

另外, 也可以這麼寫:

Perry Wu 發表在 痞客邦 留言(0) 人氣()

* UDP Flooding - Dst

hping3 -I eth1 --udp --rand-source 192.168.1.100

* UDP Flooding - Src

hping3 -I eth1 --udp --rand-dest 192.168.1.100

* TCP SYN Flooding - Dst

hping3 -I eth1 --syn --rand-source 192.168.1.100

* TCP SYN Flooding - Src

hping3 -I eth1 --syn --rand-dest 192.168.1.100

* TCP SYN Flooding - Dst

hping3 -I eth1 --rand-source 192.168.1.100

* TCP SYN Flooding - Src

hping3 -I eth1 --rand-dest 192.168.1.100

文章標籤

Perry Wu 發表在 痞客邦 留言(0) 人氣()

  • 從remote複製整個git到local

    git clone --mirror git@[IP:/Path_to_git]

  • 在mirror的git repository 同步所有remote的修正

    git fetch -q --all -p

    git push

  • 將遠端的 branch checkout 回來並建立一個新的 local branch,加上 --track 表示你之後還要pull、push回去,所以請 Git 記住對應關係。

    git checkout --track -b foobar origin/foobar

  • 刪除local branch

    git branch -d local_branch

文章標籤

Perry Wu 發表在 痞客邦 留言(0) 人氣()

* 使用basic認證 帳號:密碼

curl --user user:password http://192.168.101.192/

* 告知存取 zh-tw 網頁

curl -H "Accept-Language: zh-tw"

* 取得網頁內容, 將cookie另存新檔 (參數 -D)

curl http://www.example.com -D savecookie.txt

* 使用指定的cookie來取得網頁內容 (參數 -b)

curl -b usecookie.txt http://www.example.com

* 指定使用POST method取得網頁內容 (參數 -d)

curl -d "user=xxx&password=1234" http://example.com/login.cgi

* 設置用戶代理

curl -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" http://www.example.com

* 跟隨並下載(Dropbox的資料夾分享下載,要將dl改成1)

curl -L -o ab.zip https://www.dropbox.com/sh/zls0quiliwzo82e/AAC_Co6-7dxl8M-vOFGTc_0ua?dl=1

* GET/POST/PUT/DELETE使用方式

X 後面加 http method,
curl -X GET "http://www.rest.com/api/users"
curl -X POST "http://www.rest.com/api/users"
curl -X PUT "http://www.rest.com/api/users"
curl -X DELETE "http://www.rest.com/api/users"

* HTTP Parameter

http參數可以直接加在url的query string,也可以用-d帶入參數間用&串接,或使用多個-d

# 使用`&`串接多個參數
curl -X POST -d "param1=value1¶m2=value2"
# 也可使用多個`-d`,效果同上
curl -X POST -d "param1=value1" -d "param2=value2"
curl -X POST -d "param1=a 0space"     
# "a space" url encode後空白字元會編碼成'%20'為"a%20space",編碼後的參數可以直接使用
curl -X POST -d "param1=a%20space"     

* post json 格式得資料

如同時需要傳送request parameter跟json,request parameter可以加在url後面,json資料則放入-d的參數,然後利用單引號將json資料含起來(如果json內容是用單引號,-d的參數則改用雙引號包覆),header要加入”Content-Type:application/json”跟”Accept:application/json”

curl http://www.example.com?modifier=kent -X PUT -i -H "Content-Type:application/json" -H "Accept:application/json" -d '{"boolean" : false, "foo" : "bar"}'
# 不加"Accept:application/json"也可以
curl http://www.example.com?modifier=kent -X PUT -i -H "Content-Type:application/json" -d '{"boolean" : false, "foo" : "bar"}'

參考

http://blog.kent-chiu.com/2013/08/14/testing-rest-with-curl-command.html


文章標籤

Perry Wu 發表在 痞客邦 留言(0) 人氣()