← Back to Writeups
HTBEasyMisc

Primed for Action

D3v0o0Nu119/2/20262 min read
#misc#htb#easy#primality_test

Primed for Action

Platform: HackTheBox | Category: Misc | Type: Challenge | Difficulty: Easy | OS: NA | Author: D3v0o0Nu11 | Date: 2026-01-26 | Status: Solved Techniques: primality_test

Summary

Task: Find two prime numbers in a list and output their product. Solution: Implement primality check and multiply the two primes found.

Recon

Port scan

bash
nmap -p- -sV -sC <TARGET> --min-rate 1000 -Pn
PortServiceVersionNotes
<PORT><SVC><VER><notes>

Enumeration highlights

  • Event: hackthebox | ID: 20260126_htb_primed_for_action
  • Tags: python, coding, primality
  • Indicators: find two primes, output product
  • Source: 20260126_htb_primed_for_action.md

Foothold

Vulnerability / Misconfiguration

  1. primality_test
bash
<command>

Exploitation

  • See original writeup content for detailed exploitation.

Privilege Escalation

Enumeration

bash
sudo -l
find / -perm -4000 2>/dev/null
getcap -r / 2>/dev/null
cat /etc/crontab
ps aux

Exploitation

  1. N/A for challenge-type writeup; see exploitation above.
  2. Flag obtained via challenge solve.
bash
<command>

Flags

FlagLocationValue
flagREDACTED

Key Takeaways / Lessons

  • primality_test
  • Tags: python, coding, primality

Original Writeup

<details><summary>Click to expand original content</summary>

Description

The task provided a web interface with a code editor. The goal was to write a script that reads a list of numbers from stdin, identifies the two prime numbers in the list, and outputs their product.

Analysis

This is a classic coding challenge. We are given a list of numbers, among which we need to find exactly two prime numbers and multiply them. The main difficulty lies in correctly implementing the primality check and handling the input data.

Solution

python
#!/usr/bin/env python3
import sys

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def solve():
    try:
        # Read all input data
        input_data = sys.stdin.read().split()
        numbers = [int(x) for x in input_data]
        
        primes = []
        for num in numbers:
            if is_prime(num):
                primes.append(num)
        
        if len(primes) == 2:
            print(primes[0] * primes[1])
        else:
            # If there are not exactly 2 primes, output something or nothing
            pass
    except Exception as e:
        pass

if __name__ == "__main__":
    solve()

The script is submitted to the /run endpoint via a POST request (or through the editor interface on the website), after which the server executes it on test data and returns the flag.

</details>

signed by XESXOR