rosieblue
article thumbnail
[๋“œ๋ฆผํ•ต(Dreamhack)] pathtraversal

#!/usr/bin/python3 from flask import Flask, request, render_template, abort from functools import wraps import requests import os, json users = { '0': { 'userid': 'guest', 'level': 1, 'password': 'guest' }, '1': { 'userid': 'admin', 'level': 9999, 'password': 'admin' } } def internal_api(func): @wraps(func) def decorated_view(*args, **kwargs): if request.remote_addr == '127.0.0.1': return func(*..

article thumbnail
[Web] URI, URL, URN ์ •๋ณตํ•˜๊ธฐ

URI URI(Uniform Resource Identifier)๋Š” ์ž์›์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋ฌธ์ž์—ด์ด๋‹ค. ์ž์›์€ ์›นํŽ˜์ด์ง€, ์‚ฌ์ง„์ด๋‚˜ html ํŒŒ์ผ, ๋™์˜์ƒ ๋“ฑ ์ธํ„ฐ๋„ท์—์„œ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐ ๋ฌด์—‡์ด๋“  ๋  ์ˆ˜ ์žˆ๋‹ค. URI๋Š” ์ด์ œ ๊ทธ ์ž์›์„ ๊ฐ€๋ฆฌํ‚ค๋Š” ์‹๋ณ„์ž์ด๋‹ค. ์ž์›์€ ์ด๋ฆ„์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜๋„ ์žˆ๊ณ  ๊ทธ ์ž์›์˜ ์œ„์น˜๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜๋„ ์žˆ๋‹ค. URI Syntex URI๋Š” scheme, authority(userinfo), path, query ๊ทธ๋ฆฌ๊ณ  fragment๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋‹ค. The generic URI syntax consists of a hierarchical sequence of components referred to as the scheme, authority, path, query, and fragment...

article thumbnail
[Web ์šฉ์–ด] - ์ธํ„ฐ๋„ท ํ†ต์‹  (IP,TCP/UDP, DNS, Port ๋“ฑ)

์ด ํฌ์ŠคํŠธ๋Š” ์ธํ”„๋Ÿฐ์˜ ๋ชจ๋“  ๊ฐœ๋ฐœ์ž๋ฅผ ์œ„ํ•œ HTTP ๊ธฐ๋ณธ ์ง€์‹์ด๋ผ๋Š” ๊ฐ•์˜๋ฅผ ์ฐธ๊ณ ๋กœ ์ž‘์„ฑํ•˜์˜€๋‹ค. ์—ฌ๊ธฐ์„œ ๋‹ค๋ฃจ๋Š” ๋‚ด์šฉ์€ ๊ต‰์žฅํžˆ ๊ธฐ์ดˆ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋Œ€์ถฉ ์›น์ด ์ด๋ ‡๊ฒŒ ํ˜๋Ÿฌ๊ฐ€๊ตฌ๋‚˜~๋ผ๋Š” ์ •๋„๋กœ ์ดํ•ดํ•˜๋ฉด๋œ๋‹ค. ์ธํ„ฐ๋„ท ํ†ต์‹  ์ธํ„ฐ๋„ท์—์„œ ์ปดํ“จํ„ฐ ๋‘˜์€ ์–ด๋–ป๊ฒŒ ํ†ต์‹ ํ• ๊นŒ? ์›น์—์„œ ์ปดํ“จํ„ฐ ๋‘๋Œ€๊ฐ€ ํ†ต์‹ ์„ ํ•œ๋‹ค๊ณ  ํ•˜์ž. ์˜ˆ๋ฅผ ๋“ค์–ด ์šฐ๋ฆฌ๊ฐ€ ์›นํฌํ„ธ์‚ฌ์ดํŠธ์— ์ ‘์†ํ•˜๋Š” ์ƒํ™ฉ์„ ๊ฐ€์ •ํ•ด๋ณด์ž. ์ด๋•Œ ํฌํ„ธ์‚ฌ์ดํŠธ์˜ ์ •๋ณด๋ฅผ ์š”์ฒญํ•˜๋Š” ์ปดํ“จํ„ฐ์™€ ํฌํ„ธ์‚ฌ์ดํŠธ ์ •๋ณด๋ฅผ ์šฐ๋ฆฌ์—๊ฒŒ ์ฃผ๋Š” ์ปดํ“จํ„ฐ ์ด๋ ‡๊ฒŒ ๋ถ„๋ฅ˜ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋‹ค. ์—ฌ๊ธฐ์„œ ์ •๋ณด๋ฅผ ์š”์ฒญํ•˜๋Š” ์ปดํ“จํ„ฐ๋ฅผ ํด๋ผ์ด์–ธํŠธ, ์ •๋ณด๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ์ปดํ“จํ„ฐ๋ฅผ ์„œ๋ฒ„๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์›น์—์„œ๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„์—๊ฒŒ HTTP ์š”์ฒญ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ณ  ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ HTTP ์‘๋‹ต ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ํ˜•์‹์œผ๋กœ ํ†ต์‹ ์ด ์ด๋ฃจ์–ด์ง„๋‹ค. ํ•˜์ง€๋งŒ ์„ธ์ƒ..

[HTTP ํ—ค๋”] X-Forwarded-for ์™€ X-Forwarded-Proto

์›นํ•ดํ‚น์—์„œ๋„, NGINX ๊ณต๋ถ€ํ•  ๋•Œ๋„ ๋‘ ํ—ค๋”๊ฐ€ ์ข…์ข… ๋“ฑ์žฅํ•ด ์ •๋ฆฌํ•ด ๋ณด๊ณ ์ž ํ•œ๋‹ค. ์™œ X-Fowarded-for ํ—ค๋”์™€ X-Forwarded-Proto๋ฅผ ์“ธ๊นŒ? ๊ฐ„๋‹จํžˆ ๋งํ•ด์„œ ๋‘ ํ—ค๋”๋Š” ์„œ๋ฒ„๋กœ ์ ‘๊ทผํ•œ ์• ๋“ค์˜ ip์™€ ํ”„๋กœํ† ์ฝœ์„ ์•Œ๋ ค์ฃผ๋Š” ํ—ค๋”์ด๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์„œ๋ฒ„ ๋กœ๊ทธ์—๋„ ๋ถ„๋ช… ๋ˆ„๊ฐ€ ์–ด๋–ป๊ฒŒ ์ ‘๊ทผํ–ˆ๋Š”์ง€ ๋‚˜์˜ฌํ…๋ฐ ๊ตณ์ด ๋”ฐ๋กœ ํ—ค๋”๋ฅผ ๋งŒ๋“ค์–ด ๋ช…์‹œํ•ด์ฃผ๋Š” ์ด์œ ๋Š” ๋ญ˜๊นŒ? ๊ทธ ์ด์œ ๋Š” ๋งŒ์•ฝ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ํ”„๋ก์‹œ๋‚˜ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ๋“ฑ์„ ํ†ตํ•ด ์„œ๋ฒ„์— ์ ‘๊ทผํ•œ๋‹ค๋ฉด ์„œ๋ฒ„๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์•„๋‹Œ ํ”„๋ก์‹œ๋‚˜ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ์˜ ์ •๋ณด๋ฅผ ๊ธฐ๋กํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ๋‹ค์‹œ ๋งํ•ด ๋‘ ํ—ค๋”๋Š” ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ํ˜น์€ ํ”„๋ก์‹œ์— ์ ‘๊ทผํ•œ ํด๋ผ์ด์–ธํŠธ์˜ IP์ฃผ์†Œ(X-Forwarded-For)์™€ ํ”„๋กœํ† ์ฝœ(X-Forwarded-Proto)์„ ๋‚˜ํƒ€๋‚ธ๋‹ค. Syntex X-Forwarded-For:..