forked from EdOverflow/hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/reddit
executable file
·34 lines (27 loc) · 1.3 KB
/reddit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Use reddit.com to find subdomains, links, and posts related to a target host.
# Variables
BOLD='\033[1m'
END='\033[0m'
if [[ $1 == "" ]]; then
echo "./reddit <host>";
exit 1;
fi
# Queries
site_results=$(curl -Ls "https://www.reddit.com/search?q=site%3A$1" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" | tidy -q 2> /dev/null | grep "search-link")
url_results=$(curl -Ls "https://www.reddit.com/search?q=url%3A$1" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" | tidy -q 2> /dev/null | grep "search-link")
self_results=$(curl -Ls "https://www.reddit.com/search?q=selftext%3A$1" -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" | grep "search-title")
# Output
echo
echo -e "${BOLD}Hosts:${END}"
echo "========================"
echo "$site_results" | grep -Po '.*?//\K.*?(?=/)' | sort | uniq
echo
echo -e "${BOLD}Links:${END}"
echo "========================"
echo "$site_results" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | sort | uniq
echo "$url_results" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | sort | uniq
echo
echo -e "${BOLD}Self-posts:${END}"
echo "========================"
echo "$self_results" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | grep "comments" | sort | uniq