Luv{Flag}
반응형

URL globbing

curl 을 사용할때 다음과 같은 오류를 겪어본 적이 있을 수 있다.

 

  • url: (3) [globbing] error: bad range specification after pos 30
  • curl: (3) bad range in URL position 30

 

구글링 해보면 이에 대한 해결책으로 -g 나 -globoff 옵션을 사용하라고 하는데 이는 globbing 기능을 비활성화 하는 것이다. 

 

curl 은 비슷하고도 다양한 url 을 한번에, 쉽게 지정하기 위해 globbing을 제시한다.

예약 문자 [ ]  와  { } 를 사용하며 출력변수를 지정하고, 범위를 지정할 수 있다.

 

  • curl "http://example.com/section[a-z].html"
  • curl "http://example.com/{one,two,three,alpha}.html"

 

 

Bypass WAF

curl 에 의해 취약점이 발생할때 문자열 필터링을 우회할 수 있는 방법으로 제시할 수 있다. 

response = subprocess.run(
	["curl", f"{url}"], capture_output=True, text=True, timeout=1
)

 

 

위 코드에서 사용자 입력값(url) 에 대해 SSRF를 시도할때 

if (url[0:4] != "http") or (url[7:17] != "domain.com/"):
	return render_template("admin.html", msg="Not allowed URL")
    
if (".." in url) or ("%" in url):
	return render_template("main.html", msg="Do not try path traversal :(")

if url.endswith("flag") or ("," in url):
	return render_template("main.html", msg="Not allowed string or character")

 

위와같이 사용자 입력값에 대해 검증하는 과정이 존재한다면 curl 이 제공하는 globbing 을 사용할 수 있다.

 

다음의 실행 결과는 같다.

curl "http://example.com/{one,two}.html"  
curl "http://example.com/one.html" "http://example.com/two.html"

 

 

이를 이용하여 path traversal 을 시도하기위해 

  • ../  => {.}./    
  • flag => fla{g}  또는 fla[g-g] 등으로 우회 할 수 있다.

 

 

따라서 SSRF 를 시도하는 payload 는 다음과 같이 구성될 수 있다.

http@0/domain.com/{.}./fla{g}

 

 

 


 

 

 

아래에는 URL globbing에 대한 자세한 설명과, 이를 이용한 CTF write up 이다.

 

https://everything.curl.dev/cmdline/globbing

 

URL globbing - Everything curl

You can use several globs in the same URL which then will make curl iterate over those, too. To download the images of Ben, Alice and Frank, in both the resolutions 100 x 100 and 1000 x 1000, a command line could look like:

everything.curl.dev

 

- SECCON CTF write-up

https://blog.arkark.dev/2022/11/18/seccon-en/#web-easylfi

 

SECCON CTF 2022 Quals writeup - English | XS-Spin Blog

Writeups for my challenges (skipinx, easylfi, bffcalc, piyosay, denobox, spanote, latexipy, txtchecker, and noiseccon) in SECCON CTF 2022 Quals.

blog.arkark.dev

 

반응형

검색 태그

loading