生成一个ca证书
openssl pkcs12 -in test.p12 -out test.crt
使用证书访问
curl --cert test.p12:****** --cert-type P12 --cacert test.crt
--header content-type:'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT
6.1; WOW64; Trident/5.0)' https://url
linux curl是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称url为下载工具。
一,curl命令参数。
-a/--append 上传文件时,附加到目标文件
-A/--user-agent
- anyauth 可以使用“任何”身份验证方法
-b/--cookie
- basic 使用HTTP基本验证
-B/--use-ascii 使用ASCII /文本传输
-c/--cookie-jar
-C/--continue-at
-d/--data HTTP POST方式传送数据
--data-ascii 以ascii的方式post数据
--data-binary 以二进制的方式post数据
--negotiate 使用HTTP身份验证
--digest 使用数字身份验证
--disable-eprt 禁止使用EPRT或LPRT
--disable-epsv 禁止使用EPSV
-D/--dump-header
--egd-file
--tcp-nodelay 使用TCP_NODELAY选项
-e/--referer 来源网址
-E/--cert
--cert-type
--key
--key-type
--pass
--engine
--cacert
--capath
--ciphers SSL密码
--compressed 要求返回是压缩的形势(using deflate or gzip)
--connect-timeout
--create-dirs 建立本地目录的目录层次结构
--crlf 上传是把LF转变成CRLF
-f/--fail 连接失败时不显示http错误
--ftp-create-dirs 如果远程目录不存在,创建远程目录
--ftp-method [multicwd/nocwd/singlecwd] 控制CWD的使用
--ftp-pasv 使用PASV/EPSV 代替端口
--ftp-skip-pasv-ip 使用PASV的时候,忽略该IP地址
--ftp-ssl 尝试用SSL/TLS 来进行ftp数据传输
--ftp-ssl-reqd 要求用SSL/TLS 来进行ftp数据传输
-F/--form
-form-string
-g/--globoff 禁用网址序列和范围使用{}和[]
-G/--get 以get的方式来发送数据
-h/--help 帮助
-H/--header
--ignore-content-length 忽略的HTTP头信息的长度
-i/--include 输出时包括protocol头信息
-I/--head 只显示文档信息
从文件中读取-j/--junk-session-cookies忽略会话Cookie
- 界面
- krb4 <级别
>启用与指定的安全级别krb4
-j/--junk-session-cookies 读取文件进忽略session cookie
--interface
--krb4
-k/--insecure 允许不使用证书到SSL站点
-K/--config 指定的配置文件读取
-l/--list-only 列出ftp目录下的文件名称
--limit-rate
--local-port
-m/--max-time
--max-redirs
--max-filesize
-M/--manual 显示全手动
-n/--netrc 从netrc文件中读取用户名和密码
--netrc-optional 使用.netrc 或者URL来覆盖-n
--ntlm 使用HTTP NTLM 身份验证
-N/--no-buffer 禁用缓冲输出
-o/--output 把输出写到该文件中
-O/--remote-name 把输出写到该文件中,保留远程文件的文件名
-p/--proxytunnel 使用HTTP代理
--proxy-anyauth 选择任一代理身份验证方法
--proxy-basic 在代理上使用基本身份验证
--proxy-digest 在代理上使用数字身份验证
--proxy-ntlm 在代理上使用ntlm身份验证
-P/--ftp-port 使用端口地址,而不是使用PASV
-Q/--quote
-r/--range
--range-file 读取(SSL)的随机文件
-R/--remote-time 在本地生成文件时,保留远程文件时间
--retry
--retry-delay
--retry-max-time
-s/--silent静音模式。不输出任何东西
-S/--show-error 显示错误
--socks4
--socks5
--stderr
-t/--telnet-option
--trace
--trace-ascii
--trace-time 跟踪/详细输出时,添加时间戳
-T/--upload-file
--url
-u/--user
-U/--proxy-user
-v/--verbose
-V/--version 显示版本信息
-w/--write-out [format]什么输出完成后
-x/--proxy
-X/--request
-y/--speed-time 放弃限速所要的时间。默认为30
-Y/--speed-limit 停止传输速度的限制,速度时间'秒
-z/--time-cond 传送时间设置
-0/--http1.0 使用HTTP 1.0
-1/--tlsv1 使用TLSv1(SSL)
-2/--sslv2 使用SSLv2的(SSL)
-3/--sslv3 使用的SSLv3(SSL)
--3p-quote like -Q for the source URL for 3rd party transfer
--3p-url 使用url,进行第三方传送
--3p-user 使用用户名和密码,进行第三方传送
-4/--ipv4 使用IP4
-6/--ipv6 使用IP6
-#/--pr
ogress-bar 用进度条显示当前的传送状态 二,常用curl实例
1,抓取页面内容到一个文件中
curl -o home.html https://www.wendangku.net/doc/3717703734.html,
2,用-O(大写的),后面的url要具体到某个文件,不然抓不下来。我们还可以用正则来抓取东西
curl -O https://www.wendangku.net/doc/3717703734.html, /wp-content/uploads/2010/09/compare_varnish.jpg
curl -O https://www.wendangku.net/doc/3717703734.html, /wp-content/uploads/2010/[0-9][0-9]/aaaaa.jpg
3,模拟表单信息,模拟登录,保存cookie信息
curl -c ./cookie_c.txt -F log=aaaa -F pwd=****** https://www.wendangku.net/doc/3717703734.html, /wp-login.php
4,模拟表单信息,模拟登录,保存头信息
curl -D ./cookie_D.txt -F log=aaaa -F pwd=****** https://www.wendangku.net/doc/3717703734.html, /wp-login.php
-c(小写)产生的cookie和-D里面的cookie是不一样的。
5,使用cookie文件
curl -b ./cookie_c.txt https://www.wendangku.net/doc/3717703734.html, /wp-admin
6,断点续传,-C(大写的)
curl -C -O https://www.wendangku.net/doc/3717703734.html, /wp-content/uploads/2010/09/compare_varnish.jpg
7,传送数据,最好用登录页面测试,因为你传值过去后,curl回抓数据,你可以看到你传值有没有成功
curl -d log=aaaa https://www.wendangku.net/doc/3717703734.html, /wp-login.php
8,显示抓取错误,下面这个例子,很清楚的表明了。
curl -f https://www.wendangku.net/doc/3717703734.html, /asdf
curl: (22) The requested URL returned error: 404
curl https://www.wendangku.net/doc/3717703734.html, /asdf
/compare_varnish.jpg
13,显示下载进度条
curl -# -O https://www.wendangku.net/doc/3717703734.html, /wp-content/uploads/2010/09/compare_varnish.jpg
######################################################################## 100.0%
14,通过ftp下载文件
curl -u 用户名:密码-O https://www.wendangku.net/doc/3717703734.html, /demo/curtain/bbstudy_files/style.css
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
101 1934 101 1934 0 0 3184 0 --:--:-- --:--:-- --:--:-- 7136
或者用下面的方式
curl -O ftp://用户名:密码@ip:port/demo/curtain/bbstudy_files/style.css
15,通过ftp上传
curl -O ftp://用户名:密码@ip:port/demo/curtain/bbstudy_files/style.css
12,不会显示下载进度信息
curl -T test.sql ftp://用户名:密码@ip:port/demo/curtain/bbstudy_files