0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

秒でWebページ~EC2~

Last updated at Posted at 2022-07-23

事前準備
セキュリティグループで10280ポートフルオープンで空けとく
ディレクトリ移動しないでね

sudo yum -y install nmap-ncat
sudo vi index.html.sh
-----以下の点線内ををそのまま貼ってね------

#!/bin/bash
echo -e "HTTP/1.1 200 OK\r\n$(date)\r\nContent-Type: text/html; charset=utf-8\r\n\r\n"
echo "<html><body><p>Hello world</p></body></html>"


----------------------------------------
sudo chmod 777 index.html.sh
nc -l 10280 -k -e index.html.sh

ハイ終了^^

ブラウザで以下入力してアクセス

サーバーのIP:10280

image.png

秒でしょ?

より早いの

sudo yum -y install nmap-ncat
(echo "HTTP/1.1 200 OK\r\n$(date)\r\nContent-Type: text/html; charset=utf-8\r\n\r\n";echo;echo "<html><body><p>Hello world</p></body></html>") | nc -lk 12080

失敗するとサーバ側にこれしか出ない

GET / HTTP/1.1
Host: ホストのIP:12080
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: ja

成功すると

Host: ホストのIP:12080
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: ja

GET /favicon.ico HTTP/1.1
Host: ホストのIP:12080
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
Referer: http://3.115.5.128:12080/
Accept-Encoding: gzip, deflate
Accept-Language: ja

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?