cURL工具的使用技巧

栏目: 服务器 · 发布时间: 7年前

内容简介:cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。 – BaiduDICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTPRef

cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。 – Baidu

0x01 cURL支持的协议

DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP

Ref:https://ec.haxx.se/protocols-curl.html

0x02 常用选项

curl -v http://example.com
curl -L http://example.com
curl -d "username=Rvn0xsy" http://example.com
curl -o ~/Download/down.zip http://example.com/download.zip
curl -s -o ~/Download/down.zip http://example.com/download.zip
curl -O ~/Download/down.zip http://example.com/download.zip
curl http://example.com/ --limit-rate 200K
curl --max-filesize 100000 http://example.com/
curl --range 100-1099 http://example.com/download.zip
curl --data-urlencode "name=John Doe (Junior)" http://example.com
curl --data-urlencode user@contents.txt http://example.com #user的内容再contents.txt中
curl -G http://example.com
curl -H "Transfer-Encoding: chunked" http://example.com
curl --user-agent/-A/-H 'User-Agent: http://example.com'

0x03 认证

cURL支持四种认证:

-u <username:password>

0x04 任意HTTP方法

cURL -X <POST/GET/OPTIONS/PUT> http://example.com

0x04 上传文件

支持:FILE, FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, SCP, SFTP, SMB, SMBS, SMTP, SMTPS and TFTP.

HTTP: curl -T upload.zip http://example.com/ # PUT

FTP: curl -T upload.zip ftp://example.com/

SMTP: curl -T mail smtp://mail.example.com/ --mail-from user@example.com

0x05 网卡

curl --interface eth1 https://www.example.com/

curl --interface 192.168.0.2 https://www.example.com/

curl --interface machine2 https://www.example.com/

0x06 指定源端口

curl --local-port 4000-4200 https://example.com/

0x07 代理

支持代理:

  • http
  • socks
curl -x 192.168.0.1:8080 http:/example.com/
curl -x socks4://proxy.example.com http://www.example.com/
curl --socks4 proxy.example.com http://www.example.com/
curl --socks4a proxy.example.com http://www.example.com/
curl -x socks4a://proxy.example.com http://www.example.com/
curl -x socks5://proxy.example.com http://www.example.com/
curl --socks5 proxy.example.com http://www.example.com/
curl -x socks5h://proxy.example.com http://www.example.com/
curl --socks5-hostname proxy.example.com http://www.example.com/

代理认证

curl -U daniel:secr3t -x myproxy:80 http://example.com

0x08 HTML表单上传文件

<form action="submit.cgi" method="post" enctype="multipart/form-data">
   Name: <input type="text" name="person"><br>
   File: <input type="file" name="secret"><br>
   <input type="submit" value="Submit">
</form>

curl -F person=anonymous -F secret=@file.txt http://example.com/submit.cgi

0x09 COOKIE

读取cookie

curl -L -b cookies.txt http://example.com

将cookie写入文件

curl -c cookie-jar.txt http://example.com

REF

  • https://legacy.gitbook.com/book/bagder/everything-curl

以上所述就是小编给大家介绍的《cURL工具的使用技巧》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Cult of the Amateur

The Cult of the Amateur

Andrew Keen / Crown Business / 2007-6-5 / USD 22.95

Amateur hour has arrived, and the audience is running the show In a hard-hitting and provocative polemic, Silicon Valley insider and pundit Andrew Keen exposes the grave consequences of today’s......一起来看看 《The Cult of the Amateur》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具