312-50V10 · Question #921
You start performing a penetration test against a specific website and have decided to start from grabbing all the links from the main page. What Is the best Linux pipe to achieve your milestone?
The correct answer is C. wget https://stte.com | grep "< a href=\*http" | grep "site.com". Fetching a webpage and piping its HTML through grep to filter anchor tags is the standard Linux command-line approach for extracting all hyperlinks from a target page.
Question
You start performing a penetration test against a specific website and have decided to start from grabbing all the links from the main page. What Is the best Linux pipe to achieve your milestone?
Options
- Adirb https://site.com | grep "site"
- Bcurl -s https://sile.com | grep `'< a href-'http" | grep "Site-com- | cut -d "V" -f 2
- Cwget https://stte.com | grep "< a href=*http" | grep "site.com"
- Dwgethttps://site.com | cut-d"http-
How the community answered
(23 responses)- A4% (1)
- B4% (1)
- C91% (21)
Why each option
Fetching a webpage and piping its HTML through grep to filter anchor tags is the standard Linux command-line approach for extracting all hyperlinks from a target page.
dirb is a web directory brute-force scanner that discovers hidden paths by testing a wordlist against a server - it does not parse or extract anchor tags from HTML.
Although curl outputs to stdout and pipes naturally to grep, the command in choice B contains multiple syntax errors including broken quoting and malformed grep patterns that would cause it to fail.
The wget command retrieves the full HTML of the target URL and its output can be piped into grep to pattern-match anchor tags such as 'a href' and isolate hyperlinks from the page source. Adding a second grep filter for the site's domain further narrows results to on-site links, completing the link-harvesting goal with a simple pipe chain.
The command in choice D is syntactically incomplete, with a broken cut invocation and no valid grep filter, making it non-functional for extracting links.
Concept tested: Linux CLI link harvesting with wget and grep pipe
Source: https://www.gnu.org/software/wget/manual/wget.html
Topics
Community Discussion
No community discussion yet for this question.