This webpage provides an overview of a Bash script designed for performing web searches and processing links. The script performs the following tasks:
#!/bin/bash
# Define the list of search keywords
keywords=(
"IT" "ICT" "OT" "IIOT" "IOT" "network" "cybersecurity" "AI" "machine+learning" "data+science"
"cloud+computing" "blockchain" "automation" "digital+transformation" "IoT" "big+data"
"analytics" "software+development" "IT+consulting" "networking" "virtualization"
"system+integration" "tech+trends" "IT+strategy" "smart+devices" "enterprise+IT"
"cyber+defense" "data+protection" "IT+infrastructure" "technology+solutions"
"security+services" "cloud+storage" "IT+support" "tech+innovation" "software+engineering"
"information+security" "IT+management" "digital+marketing" "IT+services" "enterprise+solutions"
"IT+architecture" "IT+operations" "mobile+computing" "IT+project+management" "IT+training"
"tech+consulting" "network+security" "IT+systems" "data+analytics" "IT+compliance"
"IT+governance" "IT+trends" "IT+support+services" "IT+outsourcing" "technology+consulting"
"TCP/IP" "UDP" "HTTP" "HTTPS" "FTP" "SFTP" "SSH" "Telnet" "DNS" "DHCP"
"NAT" "SNMP" "ICMP" "ARP" "OSPF" "BGP" "VLAN" "VPN" "Firewall" "Intrusion+Detection+System"
"Intrusion+Prevention+System" "SIEM" "SIEM+tools" "Access+Control" "Network+Monitoring"
"Network+Forensics" "Incident+Response" "Vulnerability+Assessment" "Penetration+Testing"
"Cryptography" "Public+Key+Infrastructure" "Digital+Certificates" "Network+Segmentation"
"Security+Policies" "Data+Loss+Prevention" "Threat+Hunting" "Zero+Trust+Security"
"Endpoint+Security" "Security+Incident+and+Event+Management" "Network+Access+Control"
"Security+Information+and+Event+Management" "Network+Traffic+Analysis" "Wireless+Security"
"Cloud+Security" "Application+Security" "Identity+and+Access+Management"
)
# Define the list of realistic Referer URLs
referer_list=(
"https://www.google.com/search?q=%s"
"https://www.bing.com/search?q=%s"
"https://search.yahoo.com/search?p=%s"
"https://duckduckgo.com/?q=%s"
"https://www.baidu.com/s?wd=%s"
"https://yandex.com/search/?text=%s"
"https://www.ask.com/web?q=%s"
)
# Function to generate a random IPv4 address
generate_random_ipv4() {
echo "$((RANDOM % 256)).$((RANDOM % 256)).$((RANDOM % 256)).$((RANDOM % 256))"
}
# Function to generate a random IPv6 address
generate_random_ipv6() {
echo "$(printf '%x:%x:%x:%x:%x:%x:%x:%x' $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)) $(($RANDOM % 0xffff)))"
}
# Function to generate a random User-Agent string
generate_random_user_agent() {
local user_agents=(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/91.0.864.48 Safari/537.36"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/90.0"
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0"
)
echo "${user_agents[$RANDOM % ${#user_agents[@]}]}"
}
# Function to get a random keyword from the list
get_random_keyword() {
echo "${keywords[$RANDOM % ${#keywords[@]}]}"
}
# Function to get a random Referer URL with a placeholder for the query
get_random_referer() {
local referer_template="${referer_list[$RANDOM % ${#referer_list[@]}]}"
local keyword=$(get_random_keyword)
echo "$(printf "$referer_template" "$keyword")"
}
# Function to perform a search and process links on Bing
perform_search_and_process_links() {
local keyword="$1"
local search_url="https://www.bing.com/search?q=${keyword}+site:miralishahidi.ir"
# Randomly select HTTP version (1.1 or 2)
local http_version=$(( RANDOM % 2 + 1 ))
local http_version_flag="--http1.1"
if [ "$http_version" -eq 2 ]; then
http_version_flag="--http2"
fi
# Randomly select Referer
local referer=$(get_random_referer)
echo "Fetching page content from: $search_url with HTTP version: $http_version_flag and Referer: $referer"
# Randomly generate User-Agent and IP
local user_agent=$(generate_random_user_agent)
local ip_version=$(( RANDOM % 2 ))
local forwarded_ip
if [ "$ip_version" -eq 0 ]; then
forwarded_ip=$(generate_random_ipv4)
else
forwarded_ip=$(generate_random_ipv6)
fi
echo "Using X-Forwarded-For IP: $forwarded_ip"
# Fetch the page content with random headers
page_content=$(curl -s -A "$user_agent" -H "X-Forwarded-For: $forwarded_ip" -H "Referer: $referer" $http_version_flag "$search_url")
# Extract and clean up links
echo "Extracting and cleaning up links..."
echo "$page_content" | grep -oP '(?<=<a href=")[^"]*' | \
sed 's/&/&/g' | \
sed 's/%3A/:/g; s/%2F/\//g; s/%3F/?/g; s/%26/&/g; s/%2C/,/g; s/%2B/+/g; s/%20/ /g' | \
awk -F'&' '{print $1}' | \
sed 's/%20/ /g; s/%21/!/g; s/%2A/*/g; s/%28/(/g; s/%29/)/g; s/%7E/~/g; s/%2D/-/g' | \
grep '\.html$' | while IFS= read -r link; do
echo "Extracted link: $link"
# Fetch the link content and measure time taken
echo "Fetching content from: $link with HTTP version: $http_version_flag"
start_time=$(date +%s.%N)
response=$(curl -s -A "$user_agent" -H "X-Forwarded-For: $forwarded_ip" -H "Referer: $referer" $http_version_flag -w "%{http_code}" -o /tmp/link_content.html "$link")
end_time=$(date +%s.%N)
http_status=$(echo "$response" | tail -n 1)
time_taken=$(echo "$end_time - $start_time" | bc)
echo "HTTP Status Code: $http_status"
echo "Time Taken: $time_taken seconds"
echo "Link content preview:"
head -n 10 /tmp/link_content.html
echo "----------------------------------------"
sleep $((RANDOM % 3 + 1)) # Random delay between clicks (1 to 3 seconds)
done
echo "Link processing complete for keyword: $keyword"
}
# Main script execution
# Number of searches to perform
num_searches=5
# Perform searches and process links
echo "Starting Bing searches and link processing..."
while true; do
keyword=$(get_random_keyword)
perform_search_and_process_links "$keyword"
sleep 2 # Delay between searches
done
echo "All tasks completed."
Here is how you can set up and use the script on Linux and Termux:
sudo apt update
sudo apt install curl grep sed awk bc
search_script.sh
and paste the provided script into it:
nano search_script.sh
chmod +x search_script.sh
./search_script.sh
pkg update
pkg install curl grep sed gawk bc
search_script.sh
and paste the provided script into it:
nano search_script.sh
chmod +x search_script.sh
./search_script.sh
chmod +x search_script.sh
.