Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
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?
A.
wget https://site.com | grep ג€<a href=\ג€httpג€ | grep ג€site.comג€
I tried wget, but it simply downloaded webpage, its output wasn't piped to grep.
Then I tried curl with example.com:
curl -s https://example.com | grep "<a href=\"http" | grep "iana.org" | cut -d "\"" -f 2
Output:
https://www.iana.org/domains/example
Explanation:
curl -s = quiet/silent, no progress meter/error messages
grep "<a href=\"http" = grep lines with hyperlinks to URLs, quotation mark is escaped by backslash
grep "iana.org" = grep lines with iana.org domain
cut -d "\"" -f 2 = output only 2nd field in each grepped line, fields in grepped lines are delimited by quotation marks, quotation mark is escaped by backslash here too
wget saves index.html to a file, curl prints out the screen requested web resource, and with commands concatenated with pipes give links inside the web page. The answer is B. You should try in a shell of a linux system to see directly
By default wget will save page content to a file, so piping to grep will not work. Indeed wget can return page content to standard output, but it requires additional argument flag for that.
Even if we accept that wget will return to standard output, the grep command will return only URLs that contain specific domain - not all URLs.
Curl will return page to standard output, which can be piped to grep to list only URLs (href tag), and then strip the HTML tags to leave the URLs only
Answer is B.
`curl` outputs to stdout which makes it suitable to pipe to grep. `wget` just saves to a file (unless you use flag `-O -`)
Tested on Ubuntu 20.04
```
$ curl -s http://example.com/ | grep '<a href' | cut -d"\"" -f2
https://www.iana.org/domains/example
```
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ronxz
Highly Voted 1 year, 10 months agovictorfs
Most Recent 11 months, 3 weeks agovictorfs
11 months, 3 weeks agocrimson_18
1 year, 1 month agoflinux
1 year, 7 months agobsto
1 year, 8 months agojuan201061
1 year, 9 months agoSeaH0rse66
1 year, 11 months agocazzobsb
2 years agoGilo
2 years, 1 month agoUrltenm
2 years, 1 month agogokhansah1n
2 years, 2 months agoOliverotuns
2 years, 2 months agoSH_
2 years, 2 months agospydog
2 years, 2 months agoandreiiar
2 years, 3 months agoProveCert
2 years, 4 months ago