Automate Google Dorks Commands with a Linux Bash Script
Google dorks, also known as Google hacking or Google dorking, involves using advanced search operators to refine search queries on Google in order to find specific information that may not be easily accessible through conventional searches. Google dorking is used by cybersecurity professionals, researchers, journalist, and much more. Some of the key uses are penetration testing, security auditing, and information gathering.
Let me give you a breakdown of what this script does and then after, I will give a detailed breakdown of how you can use this.
Below is whats called a Linux Bash Script. When you run this script, linux will prompt you in the command line to input what you’d like to search.
Make your search query inside of quotation marks “”
After hitting enter, you will see 10 new tabs open with your requested searches.
Why is this useful?
I oftentimes found myself having to refer to my notes for each google dork command (as I don’t have them memorized) and sometimes I just want to search a name or subject and have mass results, quickly. I used 5 basic google commands and then added 5 others, but keep in mind, you’ll be able to customize whatever commands you want for your searches! As many tabs as you can have open at a time!
Take a look at this script, and after I will give you instructions for installation.
# Function to open a search query in a new tab
search_google() {
local query="$1"
local search_command="https://www.google.com/search?q="
# Construct the Google search URL
local search_url="$search_command$query"
# Check if xdg-open is available
if command -v xdg-open &>/dev/null; then
# Open the search URL in a new tab
xdg-open "$search_url"
else
echo "Error: xdg-open is not installed. Please install it to proceed with the Google searches."
exit 1
fi
}
# Main script
read -p "Enter your search query: " search_query
# Basic Google dork commands
google_dorks=(
"site:$search_query"
"intitle:$search_query"
"inurl:$search_query"
"filetype:pdf $search_query"
"related:$search_query"
)
# Advanced Google dork commands
advanced_google_dorks=(
"allinurl:$search_query"
"allintext:$search_query"
"cache:$search_query"
"link:$search_query"
"info:$search_query"
)
# Combine basic and advanced dorks
all_google_dorks=("${google_dorks[@]}" "${advanced_google_dorks[@]}")
# Iterate over each Google dork command and open in a new tab
for dork in "${all_google_dorks[@]}"; do
search_google "$dork"
done
Initially the code was much shorter, but I kept running into an issue. I was missing a key ingredient. ‘xdg-open’ was not installed.
‘xdg-open’ is a required command-line utility before this will run. It is used to open files or URLs using the default application associated with the file type or URL scheme. When you run xdg-open it detects the user’s desktop environment and then delegates the task of opening the file or URL to the appropriate application handler based on the desktop environment’s configuration.
To make this script more user-friendly I added in a section that will check to see if xdg-open is installed. If not, it will return “Error: xdg-open is not installed. Please install it to proceed with the Google searches.” I hope this saves you time!
How to Install
Before running the code, type the command into your linux terminal below
‘sudo apt update
sudo apt install xdg-utils’
After installation, you’ll want to save the script above into a text editor. The name you save it as will be the name of the script so keep that in mind. I named mine ‘google_dorks’ for example.
Clear your terminal.
Next type in chmod +x ‘insert_your_script’
This will allow the script to be executable. Remember to use the name of your saved script.
Next, we want to run the script. Type in ./insert_your_script
After you hit enter your terminal will prompt you to input a search!
It should look like this below ..
Because I saved mine as google_dorks anytime I want to run this script, I just have to type in ./google_dorks into my linux terminal!
Think of all the possibilities!
Enjoy,
@Therealcybergod