我以为user=user&password=password
会在请求正文中,但我找不到它。它在哪里?是否-v
显示完整的请求,包括正文?谢谢。
$ curl --data "user=user&password=password" -v http://google.com/
* Trying 172.217.3.110...
* TCP_NODELAY set
* Connected to google.com (172.217.3.110) port 80 (#0)
> POST / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Length: 27
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 27 out of 27 bytes
< HTTP/1.1 405 Method Not Allowed
< Allow: GET, HEAD
< Date: Wed, 30 Jan 2019 14:01:40 GMT
< Content-Type: text/html; charset=UTF-8
< Server: gws
< Content-Length: 1589
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
<
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 405 (Method Not Allowed)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>405.</b> <ins>That’s an error.</ins>
<p>The request method <code>POST</code> is inappropriate for the URL <code>/</code>. <ins>That’s all we know.</ins>
* Connection #0 to host google.com left intact
答案1
curl
的选项的描述-v
说
-v
,--verbose
使卷曲在操作过程中变得冗长。对于调试和查看“幕后”发生的情况很有用。以“>”开头的行表示curl发送的“标头数据”,“<”表示curl接收到的“标头数据”,在正常情况下是隐藏的,以“*”开头的行表示curl提供的附加信息。
如果您只想在输出中包含 HTTP 标头,则
-i
,--include
可能是您正在寻找的选项。如果您认为此选项仍然无法提供足够的详细信息,请考虑使用
--trace
or--trace-ascii
代替。
因此-v
显示标头(除了响应正文之外,curl
无论如何都会显示),并且您需要--trace
查看正文:
curl --data "user=user&password=password" --trace google.log http://google.com/
将输出详细日志google.log
。
答案2
我认为你应该在curl中添加以下参数:
--trace-ascii -
完整的 CURL 请求将是:
curl 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=fgfgkg' -H 'Content-Type: application/json' --data-binary '{"token":"[CUSTOM_TOKEN]","returnSecureToken":true}' --trace-ascii -
SSL 握手后,这将返回由 CURL 伪造的请求的所有 HTTP 标头和 HTTP 正文。
因此,您可以看到 POST 请求正文中实际发送的内容。在下面示例的底部,您可以看到在请求的 HTTP 正文中发送的 JSON 对象。通常,运行常规的curl命令后它不会出现。
0000: {"token":"[CUSTOM_TOKEN]","returnSecureToken":true}
“-”有助于打印到屏幕而不是文件。以下示例已被修剪。我没有粘贴完整的回复以使其更短。
jojo@royan:~$ curl 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=fgfgkg' -H 'Content-Type: application/json' --data-binary '{"token":"[CUSTOM_TOKEN]","returnSecureToken":true}' --trace-ascii -
== Info: Trying 142.250.178.170:443...
== Info: Connected to identitytoolkit.googleapis.com (142.250.178.170) port 443 (#0)
== Info: ALPN, offering h2
== Info: ALPN, offering http/1.1
== Info: successfully set certificate verify locations:
== Info: CAfile: /etc/ssl/certs/ca-certificates.crt
== Info: CApath: /etc/ssl/certs
=> Send SSL data, 5 bytes (0x5)
0000: .....
== Info: TLSv1.3 (OUT), TLS handshake, Client hello (1):
=> Send SSL data, 512 bytes (0x200)
0000: .......`7.=..F pJ}.`..<:.YD...\.1_v... .q.q2;c..nt...'T1}.A.P.+.
0040: Px..T...>.......,.0.........+./...$.(.k.#.'.g.....9.....3.....=.
0080: <.5./.....u...#.!...identitytoolkit.googleapis.com..............
00c0: ..........3t.........h2.http/1.1.........1.....*.(..............
0100: ...........................+........-.....3.&.$... .j....C7AO...
0140: .I....G...:....J^?R.............................................
0180: ................................................................
01c0: ................................................................
<= Recv SSL data, 5 bytes (0x5)
0000: ....z
== Info: TLSv1.3 (IN), TLS handshake, Server hello (2):
<= Recv SSL data, 122 bytes (0x7a)
0000: ...v.....H........x.g3..$.mE.3%m...... .q.q2;c..nt...'T1}.A.P.+.
0040: Px..T........3.$... ..n4X.......1....J......1r,.5n}\.+....
<= Recv SSL data, 5 bytes (0x5)
0000: .....
<= Recv SSL data, 5 bytes (0x5)
0000: .....
<= Recv SSL data, 1 bytes (0x1)
0000: .
== Info: TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
<= Recv SSL data, 15 bytes (0xf)
0000: .............h2
== Info: TLSv1.3 (IN), TLS handshake, Certificate (11):
<= Recv SSL data, 4396 bytes (0x112c)
0000: ...(...$...0...0............i...f........6V0...*.H........0F1.0.
0040: ..U....US1"0 ..U....Google Trust Services LLC1.0...U....GTS CA 1
0080: C30...211018095256Z..220110095255Z0"1 0...U....upload.video.goog
00c0: le.com0Y0...*.H.=....*.H.=....B...D.1.U.aJ......z.{C.,f....:R*..
0100: .*.R..*........+.sq....`......y......0...0...U...........0...U.%
0140: ..0...+.......0...U.......0.0...U.......a..sP...q..3/_.8...0...U
0180: .#..0....t......=...F..q5.'0j..+........^0\0'..+.....0...http:/
01c0: /ocsp.pki.goog/gts1c301..+.....0..%http://pki.goog/repo/certs/gt
0200: s1c3.der0.....U......0.....upload.video.google.com..*.clients.go
0240: ogle.com..*.docs.google.com..*.drive.google.com..*.gdata.youtube
0280: .com..*.googleapis.com..*.photos.google.com..*.youtube-3rd-party
02c0: .com..upload.google.com..*.upload.google.com..upload.youtube.com
0300: ..*.upload.youtube.com..uploads.stage.gdata.youtube.com..bg-call
0340: -donation.goog..bg-call-donation-alpha.goog..bg-call-donation-ca
0380: nary.goog..bg-call-donation-dev.goog0!..U. ..0.0...g.....0...+..
03c0: ...y...0<..U...50301./.-.+http://crls.pki.goog/gts1c3/QqFxbi9M48
0400: c.crl0.....+.....y............v.F.U.u.. 0...i..}.,At..I.....p.mG
0440: ...|..{......G0E. Qd..V.3QE...O...^.Z.h3OW...q.MAp.!....T..iY>..
0480: ...$.Q.3...n .....Ptv.u.A...."FJ...:.B.^N1.....K.h..b......|..|.
04c0: .....F0D. |.....ye..t..M..t..F.L<......... R&..M...9Y.8It..s..J
0500: ...#[-.....r0...*.H...............-.....*...?..dh ...7/;ZP..x...
0540: .-........T.O...j.d.AL.:.Cj........Q9..n.Pr9..3.....5O......C..7
0580: S.......7.yI{.lS..T..DC..q?..j~R...g3..+e!.......x......b...t.)
05c0: ... x.+a.....<+..e-...!..?e$...Y...^u.x9A......~0.....n......|.3
0600: Kh....M...I....2...............h.....0...0..~..........SYk4....P
0640: f0...*.H........0G1.0...U....US1"0 ..U....Google Trust Services
0680: LLC1.0...U....GTS Root R10...200813000042Z..270930000042Z0F1.0..
06c0: .U....US1"0 ..U....Google Trust Services LLC1.0...U....GTS CA 1C
0700: 30.."0...*.H.............0............b..7.7B.l...e.%...k..m.Z#
0740: .........|....B.^V$.z3....i..t.WLfh.w7US.9.M.4._%w7;...<......C.
0780: ..G..D.c..A..A0H......E.!..B...+eV4.&....}....H|7M?.....u..yW\.W
07c0: n.........%..,...*....c.<PI...._.+Y.....Q..w....O.pI.\m .......
0800: w.-...k....+........'....Q.................0..|0...U...........0
0840: ...U.%..0...+.........+.......0...U.......0.......0...U.......t
0880: ......=...F..q5.'0...U.#..0.....+&q.+H'./Rf,....q>0h..+........\
08c0: 0Z0&..+.....0...http://ocsp.pki.goog/gtsr100..+.....0..$http://p
0900: ki.goog/repo/certs/gtsr1.der04..U...-0+0).'.%.#http://crl.pki.go
0940: og/gtsr1/gtsr1.crl0W..U. .P0N08..+.....y...0*0(..+.........https
0980: ://pki.goog/repository/0...g.....0...g.....0...*.H..............
09c0: }. \.<[email protected]...$..Pq"...n..jo......_.l.......
0a00: b....[.f.........i>z.FI_F.A...Me4...?O.lI..SA..!.....D[*P..M.S6
0a40: .B..T..wS.d8'...X..|9-[..........S$....y.&.a.SR.B..f+?..........
0a80: .q.5($.....-.H.=Y.Q.t..|...[..4..........."....q....s$.7S...?..\
0ac0: .6..;.)...:b;lc...Yq.c'.L....s..*....l2.3...Qq.4...].QX......Y.q
0b00: ..M(..m......F...k.w.....#.........D..u#.4.. ..^...RF.....!pQ...
0b40: ..U.+.3w.KB..w..s.....7?..*f.s.2.2l2....#.[}Mep.+.=...m.2.....c.
0b80: ..]...q^*..."..e:...e.....[.Y.G.-.$:...&....7..o....Q......Q...
0bc0: ...f0..b0..J.......w..l.6...!...X..0...*.H........0W1.0...U....B
0c00: E1.0...U....GlobalSign nv-sa1.0...U....Root CA1.0...U....GlobalS
0c40: ign Root CA0...200619000042Z..280128000042Z0G1.0...U....US1"0 ..
0c80: U....Google Trust Services LLC1.0...U....GTS Root R10.."0...*.H.
0cc0: ............0...............w.;...>...@<....}2..q.......j.....K
0d00: .+...................^..R..#'....c...~..^.h...ZG.M.3.N.....lK...
0d40: ...d)%#....=.`.......H.M..z.....Y........1.......ml....~&.E.=.y.
0d80: .(..&......<h.S..:.+.....z..u....Vd..Oh.=......@..\....5l..P..
0dc0: L... .3.R..2.).%*.H.r..d...........8f..c...x.{\w.v......y.W..&..
0e00: ............U.....K)...2%N*.eD.....I...|..@{.C..l..}...L......K.
0e40: ....E.v..@+.S....;......1..w.o{>...".....2..c.Qr.]....)h3.:f...&
0e80: ...Wex'.^I......!............lH<@.~.Z.V<.....K.9K..?.U.n$..q...
0ec0: .......A...=:..z.7...........80..40...U...........0...U.......0.
0f00: ...0...U........+&q.+H'./Rf,....q>0...U.#..0...`{f.E....P/}..4..
0f40: ..K0`..+........T0R0%..+.....0...http://ocsp.pki.goog/gsr10)..+.
0f80: ....0...http://pki.goog/gsr1/gsr1.crt02..U...+0)0'.%.#.!http://c
0fc0: rl.pki.goog/gsr1/gsr1.crl0;..U. .4020...g.....0...g.....0...+...
1000: ..y....0...+.....y....0...*.H.............4...(...v..1z!..R>..t.
1040: A..=5......\_...|......W.&o[..Fh.7okz...7.%Q..h...I.Z...#...+...
1080: ..Ij.u.......XHW.5.....o..o.......*..Ni..-.h..+s....".7..f.I..U.
10c0: g.2..&.p.=.gm=|.4..2..n.jo.....K.;..7..D.~.l..F.....!.f...Ul.)..
1100: .f[.wIH(....3rS..5.b..$...9..~*A.R.......?..
== Info: TLSv1.3 (IN), TLS handshake, CERT verify (15):
<= Recv SSL data, 79 bytes (0x4f)
0000: ...K...G0E.!........IIE.[......j .......2q.... {F=.0...........)
0040: ..n(.x.......&.
== Info: TLSv1.3 (IN), TLS handshake, Finished (20):
<= Recv SSL data, 52 bytes (0x34)
0000: ...0...Z.....n.Z;...Q.PZ}%-N.Kn.....X....Wt....L...
=> Send SSL data, 5 bytes (0x5)
0000: .....
== Info: TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
=> Send SSL data, 1 bytes (0x1)
0000: .
=> Send SSL data, 5 bytes (0x5)
0000: ....E
=> Send SSL data, 1 bytes (0x1)
0000: .
== Info: TLSv1.3 (OUT), TLS handshake, Finished (20):
=> Send SSL data, 52 bytes (0x34)
0000: ...0Io#r...a......i6....d'..K.Br=.....B.k.B.......@.
== Info: SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
== Info: ALPN, server accepted to use h2
== Info: Server certificate:
== Info: subject: CN=upload.video.google.com
== Info: start date: Oct 18 09:52:56 2021 GMT
== Info: expire date: Jan 10 09:52:55 2022 GMT
== Info: subjectAltName: host "identitytoolkit.googleapis.com" matched cert's "*.googleapis.com"
== Info: issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1C3
== Info: SSL certificate verify ok.
== Info: Using HTTP2, server supports multi-use
== Info: Connection state changed (HTTP/2 confirmed)
== Info: Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
=> Send SSL data, 5 bytes (0x5)
0000: ....)
=> Send SSL data, 1 bytes (0x1)
0000: .
=> Send SSL data, 5 bytes (0x5)
0000: ....,
=> Send SSL data, 1 bytes (0x1)
0000: .
=> Send SSL data, 5 bytes (0x5)
0000: .....
=> Send SSL data, 1 bytes (0x1)
0000: .
== Info: Using Stream ID: 1 (easy handle 0x7fffd59e9560)
=> Send SSL data, 5 bytes (0x5)
0000: ....x
=> Send SSL data, 1 bytes (0x1)
0000: .
=> Send header, 189 bytes (0xbd)
0000: POST /v1/accounts:signInWithCustomToken?key=fgfgkg HTTP/2
003b: Host: identitytoolkit.googleapis.com
0061: user-agent: curl/7.74.0
007a: accept: */*
0087: content-type: application/json
00a7: content-length: 51
00bb:
=> Send SSL data, 5 bytes (0x5)
0000: ....M
=> Send SSL data, 1 bytes (0x1)
0000: .
=> Send data, 51 bytes (0x33)
0000: {"token":"[CUSTOM_TOKEN]","returnSecureToken":true}
== Info: We are completely uploaded and fine