명령줄에서 잘못된 HTTPS 요청을 생성하는 방법은 무엇입니까?

명령줄에서 잘못된 HTTPS 요청을 생성하는 방법은 무엇입니까?

그래서 저는 관심이 있습니다. Linux의 명령줄을 통해 잘못된 HTTPS 요청을 보내 서버에서 "오류 400" 페이지를 받을 수 있습니까?
"telnet"을 사용하여 포트 80의 서버에 연결하고 잘못된 HTTP 요청을 입력하도록 지시하여 잘못된 HTTP 요청을 생성할 수 있습니다(예: HTTP/1.1을 지원하지만 호스트 헤더를 제공하지 않는다고 주장).
하지만 HTTPS로도 같은 일을 할 수 있나요? 내가 아는 한, "wget"은 항상 구문적으로 유효한 HTTP 또는 HTTPS 요청을 생성해야 하기 때문에 "wget"을 통해 이 작업을 수행할 수 없습니다. SSH 프로토콜은 HTTPS와 다르기 때문에 "ssh"를 통해 이 작업을 수행할 수 없으며 "400 잘못된 요청" 대신 "연결 재설정" 오류로 거부됩니다. 그렇다면 이를 수행할 수 있는 방법이 있습니까?

답변1

이를 사용하여 curlHTTP(S) 요청을 보낼 수 있습니다.

사용자 정의 헤더를 제거하거나 가지려면 -H이 옵션을 사용할 수 있습니다.

빈 헤더를 보내려면 다음을 수행할 수 있습니다.

curl URL -H 'Host:'

예:

$ curl https://fedoramagazine.org/ -H 'Host:'

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

응답 헤더만 가져오기:

$ curl -s -o /dev/null -D - https://www.imdb.com/ -H 'Host:' 

HTTP/2 400 
server: CloudFront
date: Fri, 24 Apr 2020 15:52:42 GMT
content-type: text/html
content-length: 915
x-cache: Error from cloudfront

답변2

어쨌든 나는 그것을 스스로 알아 냈습니다. 다음은 github.com에 잘못된 요청을 생성하는 명령입니다(예:
openssl s_client -servername github.com -connect github.com:443
거기에 잘못된 구문이 포함된 HTTP 요청을 입력하면 다음과 같은 결과가 나타납니다).

<html>
  <head>
    <meta content="origin" name="referrer">
    <title>Bad request &middot; GitHub</title>
    <meta name="viewport" content="width=device-width">
    <style type="text/css" media="screen">
      body {
        background-color: #f6f8fa;
        color: rgba(0, 0, 0, 0.5);
        font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
        font-size: 14px;
        line-height: 1.5;
      }
      .c { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; }
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      h1 { color: #24292e; line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; }
      p { margin: 20px 0 40px; }
      #s { margin-top: 35px; }
      #s a {
        color: #666666;
        font-weight: 200;
        font-size: 14px;
        margin: 0 10px;
      }
    </style>
  </head>
  <body>
    <div class="c">
      <h1>Whoa there!</h1>
      <p>You have sent an invalid request. <br><br>
        Please do not send this request again.
      </p>
      <div id="s">
        <a href="https://support.github.com">Contact Support</a> &mdash;
        <a href="https://githubstatus.com">GitHub Status</a> &mdash;
        <a href="https://twitter.com/githubstatus">@githubstatus</a>
      </div>
    </div>
  </body>
</html>

관련 정보