curl
/etc/hosts 的な設定
--resolve <host:port:address>
コマンド
telnet で 25 接続
code:shell
$ curl -v telnet://10.0.12.10:25
basic 認証
code:shell
$ curl --basic --user id:password http://example.com
ダイジェスト認証の場合には、--digest となる
ホストヘッダーをつける
code:shell
$ curl -H 'HOST: wiki.renoretriever.net' 158.199.143.102
対応しているSSL暗号化スイートを確認する
RC4-MD5 は対応
code:shell
$ curl -kI https://example.net/wordpress/ --ciphers RC4-MD5
HTTP/1.1 200 OK
Date: Tue, 08 May 2018 02:29:54 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16
X-Powered-By: PHP/5.4.16
Set-Cookie: HttpOnly;Secure
Content-Type: text/html; charset=UTF-8
EXP-RC4-MD5 は未対応
code:shell
$ curl -I https://hb-training-local.net/wordpress/ --ciphers EXP-RC4-MD5
curl: (59) failed setting cipher list: EXP-RC4-MD5
curl オプション
ファイル test.txt を multipart/form-data としてファイルアップロード
code:shell
$ curl -F attachement-file@text.txt http://example.com/
-d オプションとは併用不可
404 などのエラーが発生した時に $? の値を取得したい
オプション無し
code:shell
$ curl 10.0.12.20/yrdy/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /yrdy/ was not found on this server.</p>
</body></html>
$ echo $status
0
オプションあり(-f)
code:shell
$ curl -f 10.0.12.20/yrdy/
curl: (22) The requested URL returned error: 404 Not Found
$ echo $status
22
証明証確認
code:shell
$ curl --cert-status https://www.google.co.jp/
TLS ネゴシエーション時に指定のバージョンでつなぐように強制(TLSv1.0 〜 1.3)
code:shell
$ curl --tlsv1.0 --tlsv1.1 --tlsv1.2 --tlsv1.3 https://www.google.co.jp/
サーバ側で SSL version3 を不許可にしているときの動作
code:shell
$ curl --sslv3 https://hoge.test.test -k
curl: (35) error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
チャンクサイズ指定
code:shell
$ curl -T test.txt -H "Transfer-Encoding: chunked" http://example.com
proxy 経由してのアクセス
code:shell
$ docker run -d -p 3128:3128 --name squid poklet/squid
接続
code:shell
$ curl --proxy http://localhost:3128 -v https://yahoo.com
http2 で送信
code:shell
$ curl --http2 -v https://www.google.co.jp -o /dev/null 2>&1 | grep "HTTP/2 200"
セッション情報のセット
code:shell
$ curl --cookie "SSID=user1" http://192.168.33.10/index.php
cookie を送信し、セッション情報を引き継ぐ
code:shell
$ curl -c cookie.txt -d "user=kuboon" -d "pass=password" "http://example.com/login"
$ curl -b cookie.txt "http://exapmle.com/admin/get_data"
外部通信における接続元 IP アドレスを知る方法
code:shell
$ curl httpbin.org/ip
X-Forwarded-Proto の設定
code:shell
$ curl --header 'X-Forwarded-Proto: https' --head http://localhost/
-w オプション
yahoo トップページのサイズ確認
code:shell
$ curl -L -s -o /dev/null http://yahoo.co.jp -w '%{size_download}\n'
19494
time_starttransfer
#Linux_Commands