#!/bin/sh
# Queries google for specific search with links -dump,
# And saves answers in $l_dir works for maximum of 1000 pages
# ( Queries Google limit Sorry :[ )
# Written to work in combination of bb-mass.sh
# This shall fetch the needed files for bb-mass.sh
# This is a PoC code for automated exploiter of the phpBB RUSH 
# Vulnerability. Use it for testing purposes. Don't abuse ppl.
# This script comes with ABSOLUTELY WARRANTIES! Use at your own risk.
# Under GPL 2.0 and >.
# Check it out on http://gnu.org/licenses/gpl.txt
# Written by hip0

# Dir where fetched files should reside.
l_dir="$PWD/logs";
# Gotta change some stuff here for different queries in google.
google_search_arg1="site:com";
google_base_u1="http://www.google.com/search?q="
google_search_arg2="inurl:viewtopic.php?=";
google_base_u2="+$google_search_arg2%3Ft%3D&hl=en&lr=&start=";
google_base_u3="&sa=N"
wg=/usr/bin/links;
get_cnt=10;
fetch_sleep_time=3;

# Check for $l_dir if it doesn't exist create it
chk_dir_ex () {
if [[ ! -d "$l_dir" ]]; then
mkdir "$l_dir";
fi
}

banner () {
echo "_------------------------------------_";
echo "  |Google Fetch| 0.2 by hip0,";
echo "Greetings Fly out to the pc-freak crew";
echo '_------------------------------------_';
}
# Uses and variables defined in the header to generate proper links.
loop_threw () {
search_res=0;
counter=0;
for i in `seq 1 $get_cnt`; do
counter=$(($counter+10));
((search_res++));
sleep $fetch_sleep_time;
$wg -dump "$google_base_u1$google_search_arg1$google_base_u2$counter$google_base_u3" >$l_dir/search$search_res;
echo "Fetching Page [$search_res] for search: \"$google_base_u1$google_search_arg1$google_base_u2$counter$google_base_u3
\"";
done
}

# Main func
main () {
chk_dir_ex;
banner;
loop_threw;
}
main;
