-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nbp.sh
729 lines (540 loc) · 25.9 KB
/
nbp.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
#!/bin/bash
# by Osaroprime/Dr. Osaro Harriott (PhD)
# GENERAL CONSULTING ABC 123 BY OSAROPRIME
# NATION BUILDER PRO ™
# MAGNETRON TECHNOLOGY ™ RESEARCH INSTALLATION SCRIPT.
# Nation Builder Pro ™
# color
# Reset
clear='\033[0m' # Text Reset
clr='\033[0m'
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
# Bold
BBlack='\033[1;30m' # Black
BRed='\033[1;31m' # Red
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
BBlue='\033[1;34m' # Blue
BPurple='\033[1;35m' # Purple
BCyan='\033[1;36m' # Cyan
BWhite='\033[1;37m' # White
# Underline
UBlack='\033[4;30m' # Black
URed='\033[4;31m' # Red
UGreen='\033[4;32m' # Green
UYellow='\033[4;33m' # Yellow
UBlue='\033[4;34m' # Blue
UPurple='\033[4;35m' # Purple
UCyan='\033[4;36m' # Cyan
UWhite='\033[4;37m' # White
# NATION BUILDER PRO ™ VERSION NUMBER
version=1.1
# NATION BUILDER PRO: GEO-LOCATION ™ VERSION NUMBER
sversion=1.0
# Define the number of lines in the banner (important for locking it at the top)
BANNER_LINES=23 # Increased for more space after the banner
# Show the static banner
show_banner() {
tput cup 0 0
echo -e "${clr}\n"
printf "${BBlue} ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n"
printf "${BRed} ███╗ ██╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗\n"
printf "${BRed} ████╗ ██║██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║\n"
printf "${BRed} ██╔██╗ ██║███████║ ██║ ██║██║ ██║██╔██╗ ██║\n"
printf "${BRed} ██║╚██╗██║██╔══██║ ██║ ██║██║ ██║██║╚██╗██║\n"
printf "${BRed} ██║ ╚████║██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║\n"
printf "${BRed} ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝\n"
printf "${BBlue}██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗ ${BRed}██████╗ ██████╗ ██████╗ \n"
printf "${BBlue}██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗${BRed}██╔══██╗██╔══██╗██╔═══██╗\n"
printf "${BBlue}██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝${BRed}██████╔╝██████╔╝██║ ██║\n"
printf "${BBlue}██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗${BRed}██╔═══╝ ██╔══██╗██║ ██║\n"
printf "${BBlue}██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║${BRed}██║ ██║ ██║╚██████╔╝\n"
printf "${BBlue}╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝${BRed}╚═╝ ╚═╝ ╚═╝ ╚═════╝ version $version \n"
printf "${BRed}ImportError: ${BBlue}No module named 'SHIVA'\n"
printf "=========================================================================================\n"
printf "${White}by: ${BGreen}Osaroprime☢\n"
printf "${White}by: ${BGreen}GENERAL CONSULTING ABC 123 BY OSAROPRIME ™ ☢\n"
printf "${White}id: ${BGreen}MAGNETRON TECHNOLOGY ™ RESEARCH: LUCI-4 ☢\n"
printf "${BGreen}Version ${BRed}$version \n"
printf "${BRed} ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n"
echo ""
}
# Initialize the terminal for a static banner
init_static_banner() {
clear
show_banner
tput cup $BANNER_LINES 0
}
NC='\033[0m'
RED='\033[1;38;5;196m'
GREEN='\033[1;38;5;040m'
ORANGE='\033[1;38;5;202m'
BLUE='\033[1;38;5;012m'
BLUE2='\033[1;38;5;032m'
PINK='\033[1;38;5;013m'
GRAY='\033[1;38;5;004m'
NEW='\033[1;38;5;154m'
YELLOW='\033[1;38;5;214m'
CG='\033[1;38;5;087m'
CP='\033[1;38;5;221m'
CPO='\033[1;38;5;205m'
CN='\033[1;38;5;247m'
CNC='\033[1;38;5;051m'
# GEO-LOCATION BANNER
function banner(){
echo -e "${RED}################################################################################################"
echo -e "${BLUE2} ██████ ███████ ██████ ██ ██████ ██████ █████ ████████ ██ ██████ ███ ██ "
echo -e "${BLUE2} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ "
echo -e "${BLUE2} ██ ███ █████ ██ ██ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██ "
echo -e "${BLUE} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ "
echo -e "${BLUE} ██████ ███████ ██████ ███████ ██████ ██████ ██ ██ ██ ██ ██████ ██ ████ "
echo -e "${CP} "
echo -e "${GREEN} Nation Builder Pro ™ "
echo -e "${RED} IP GEOLOCATION (APPROXIMATE) "
echo -e "${RED} Coded By: Dr Osaro Harriott (PhD) "
echo -e "${CNC} https://github.com/sponsors/GCABC123 "
echo -e "${GREEN} https://linktr.ee/ABC123USA "
echo -e "${GREEN} version $sversion "
echo -e "${GREEN} MAGNETRON TECHNOLOGY ™ RESEARCH: LUCI-4 ™ "
echo -e "${RED}################################################################################################"
}
# Function to validate IP address format (IPv4 and IPv6)
function validate_ip() {
local ip="$1"
if [[ $ip =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] || [[ $ip =~ ^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$ ]]; then
return 0
else
return 1
fi
}
# Prompt for API Key
get_credentials() {
echo "Enter your Shodan API key (stored securely):"
read -p "Shodan API Key: " shodan_key
echo
# Encrypt and store key (example using OpenSSL)
echo "$shodan_key" | openssl enc -aes-256-cbc -e -out ./credentials/shodan.enc
}
# Function to decrypt and load Shodan credentials
load_credentials() {
shodan_key=$(openssl enc -aes-256-cbc -d -in ./credentials/shodan.enc)
}
# Error handling function for Shodan API key issues
check_credentials() {
if [[ -z "$shodan_key" ]]; then
echo "Error: Missing Shodan API credential. Re-enter credential."
get_credentials
fi
}
# Function to prompt for IP and make Shodan query
function geo_ping() {
while true; do
echo -e -n "${GREEN}[*] Enter Target IP (or type 'back' to return to the main menu): ${RESET}"
read ip
# Check if the user wants to go back to the main menu
if [[ "$ip" == "back" ]]; then
break
fi
# Validate IP address
if validate_ip "$ip"; then
# Query Shodan Geo-Ping API and format output with jq
response=$(curl -s "https://geonet.shodan.io/api/geoping/$ip" | jq)
if [[ $? -eq 0 ]]; then
echo -e "${CYAN}Results for IP: $ip${RESET}"
echo "$response"
python3 ./resources/scripts/generate_map.py "$ip" "$response"
else
echo -e "${CYAN}[!] Error: Failed to retrieve data for $ip.${RESET}"
fi
else
echo -e "${CYAN}[!] Invalid IP address format. Please enter a valid IPv4 or IPv6 address.${RESET}"
fi
done
}
# FUNCTION FOR IP ADDRESS INFO
function ip_info(){
while true; do
banner
echo -e "${CP}\n[*] Enter 1 to enter an IP address"
echo -e "${CP}\n[*] Enter 2 to return to the Main Menu"
echo -e -n "${CP}\n[*] Choice: "
read choice
case $choice in
1)
# Proceed with the IP info retrieval process
fetch_ip_info "$ip"
;;
2)
echo -e "${GREEN}\n[*] Returning to the Main Menu..."
return
;;
*)
echo -e "${RED}\n[!] Invalid choice, please try again."
;;
esac
done
}
# Shodan API Key
API_KEY="YOUR_SHODAN_API_KEY"
# Function to query Shodan API for webcams by geo location
function search_webcams() {
# Prompt user for geo location (latitude and longitude)
read -p "Enter latitude: " latitude
read -p "Enter longitude: " longitude
read -p "Enter search radius (km): " radius
# Define the search query
query="webcam"
# Make the API request with curl
echo "Searching for webcams near ($latitude, $longitude) with a $radius km radius..."
curl -s -G "https://api.shodan.io/shodan/host/search" \
--data-urlencode "query=$query geo:$latitude,$longitude,$radius" \
--data-urlencode "key=$API_KEY"
}
# FUNCTION FOR FETCHING IP ADDRESS INFO
function fetch_ip_info(){
while true; do
echo -e -n "${CP}\n[*] Enter Target IP: "
read ip
# Display the available language codes
echo -e -n "${CP}\n[*] LANGUAGE CODES"
echo -e -n "${CP}\n[*] en English (default)"
echo -e -n "${CP}\n[*] de Deutsch (German)"
echo -e -n "${CP}\n[*] es Español (Spanish)"
echo -e -n "${CP}\n[*] pt-BR Português - Brasil (Portuguese)"
echo -e -n "${CP}\n[*] fr Français (French)"
echo -e -n "${CP}\n[*] ja 日本語 (Japanese)"
echo -e -n "${CP}\n[*] zh-CN 中国 (Chinese)"
echo -e -n "${CP}\n[*] ru Русский (Russian)"
echo -e -n "${CP}\n[*] ENTER LANGUAGE CODE: "
read language
# Convert input to lowercase and validate
language=$(echo "$language" | tr '[:upper:]' '[:lower:]')
# List of valid languages
valid_languages=("en" "de" "es" "pt-br" "fr" "ja" "zh-cn" "ru")
# Check if input is in the valid languages
if [[ ! " ${valid_languages[@]} " =~ " ${language} " ]]; then
echo -e "${RED}\n[!] Invalid language code. Defaulting to English (en).\n"
language="en"
fi
dest="http://ip-api.com/json/"
echo -e -n "${RED}\n[ 🌐 ] [VICTIM IP]: $ip \n"
# Fetch and store results in a variable
results=$(curl -s "$dest$ip?lang=$language&fields=66846719")
# Display parsed results using jq for each field
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [STATUS]: $(echo "$results" | jq -r '.status') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [CONTINENT 🌎]: $(echo "$results" | jq -r '.continent') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [CONTINENT CODE 🌎]: $(echo "$results" | jq -r '.continentCode') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [COUNTRY 🌎]: $(echo "$results" | jq -r '.country') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [REGION-NAME 🌎]: $(echo "$results" | jq -r '.regionName') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [CITY 🌎]: $(echo "$results" | jq -r '.city') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [DISTRICT]: $(echo "$results" | jq -r '.district') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [ZIPCODE]: $(echo "$results" | jq -r '.zip') ✔ \n"
echo -e -n "${RED}\n[ 🌐 ] ➟ [LATITUDE]: $(echo "$results" | jq -r '.lat') ✔ \n"
echo -e -n "${RED}\n[ 🌐 ] ➟ [LONGITUDE]: $(echo "$results" | jq -r '.lon') ✔ \n"
echo -e -n "${ORANGE}\n[ 🌐 ] ➟ [ISP]: $(echo "$results" | jq -r '.isp') ✔ \n"
echo -e -n "${ORANGE}\n[ 🌐 ] ➟ [ORGANIZATION]: $(echo "$results" | jq -r '.org') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [AS]: $(echo "$results" | jq -r '.as') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [ASNAME]: $(echo "$results" | jq -r '.asname') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [TIMEZONE]: $(echo "$results" | jq -r '.timezone') ✔ \n"
echo -e -n "${BLUE}\n[ 🌐 ] ➟ [OFFSET]: $(echo "$results" | jq -r '.offset') ✔ \n"
echo -e -n "${YELLOW}\n[ 🌐 ] ➟ [CURRENCY]: $(echo "$results" | jq -r '.currency') ✔ \n"
echo -e -n "${GREEN}\n[ 🌐 ] ➟ [REVERSE DNS]: $(echo "$results" | jq -r '.reverse') ✔ \n"
echo -e -n "${GREEN}\n[ 🌐 ] ➟ [MOBILE 📲]: $(echo "$results" | jq -r '.mobile') ✔ \n"
echo -e -n "${GREEN}\n[ 🌐 ] ➟ [PROXY, VPN, TOR exit address]: $(echo "$results" | jq -r '.proxy') ✔ \n"
echo -e -n "${GREEN}\n[ 🌐 ] ➟ [HOSTING, COLOCATED OR DATA CENTER]: $(echo "$results" | jq -r '.hosting') ✔ \n"
sleep 1
echo -e -n "${RED}\n<-------- Thanks For Using NATION BUILDER PRO ™ IP Geo-Location --------->\n"
# Ask user if they want to look up IP adress info on a map...
echo -e -n "${CP}[*] Do you want to get show the IP Address GEO-LOCATION INFORMATION on a map? (y/n): "
read sagain
if [[ "$sagain" = "y" ]]; then
python3 ./resources/scripts/generate_map.py "$latitude" "$longitude" "location" "$ip"
fi
# Ask user if they want to look up another IP
echo -e -n "${CP}[*] Do you want to get GEO-LOCATION INFORMATION for another IP Address? (y/n): "
read again
if [[ "$again" != "y" ]]; then
break
fi
done
# After exiting the loop, return to the main menu
echo -e "${GREEN}\n[*] Returning to the Main Menu..."
}
function check_for_upgrades(){
# Path to the requirements.txt file in the same directory as this script
REQUIREMENTS_FILE="./requirements.txt"
# Check if requirements.txt exists
if [[ ! -f "$REQUIREMENTS_FILE" ]]; then
echo "Error: requirements.txt not found!"
exit 1
fi
# Loop through each line in requirements.txt
while IFS= read -r package; do
if [[ ! -z "$package" && ! "$package" =~ ^# ]]; then
# Echo message before installing/upgrading each package
echo "upgrading $package..."
# Check if the package is already installed
if ! brew list --formula | grep -q "^$package\$"; then
# upgrade required packages to the latest version
brew upgrade "$package"
fi
fi
done < "$REQUIREMENTS_FILE"
echo "All specified packages upgraded."
}
# Function to exit the script
function exit_script() {
echo "Exiting..."
exit 0
}
# Function to search for open ports in a country
function search_ports_in_country() {
read -p "Enter country code: " COUNTRY_CODE
read -p "Enter IP version (ipv4/ipv6): " IP_VERSION
read -p "Enter maximum number of scans (default $MAX_SCANS): " input_scans
# Use input value if provided, otherwise use default MAX_SCANS
if [[ -n $input_scans ]]; then
MAX_SCANS=$input_scans
fi
perform_scan "$COUNTRY_CODE" "$IP_VERSION" $MAX_SCANS
# After scanning, prompt the user to either scan again or return to the main menu
read -p "Scan complete. Would you like to perform another scan? (y/n): " choice
if [[ "$choice" == "y" || "$choice" == "Y" ]]; then
search_ports_in_country
else
show_menu # Return to the main menu after the scan
fi
}
TARGET_DIR="./resources/countries/cidr"
TARGET_DIR2="./resources/countries/ip"
# Function to download or update the CIDR database
update_cidr(){
if [ -d "$TARGET_DIR" ]; then
echo "Directory already exists: $TARGET_DIR"
else
mkdir -p "$TARGET_DIR"
echo "Directory structure created at: $TARGET_DIR"
fi
if [ -d "$TARGET_DIR2" ]; then
echo "Directory already exists: $TARGET_DIR2"
else
mkdir -p "$TARGET_DIR2"
echo "Directory structure created at: $TARGET_DIR2"
fi
git clone https://github.com/herrbischoff/country-ip-blocks.git /tmp/country-ip-blocks
rsync -av --progress /tmp/country-ip-blocks/ipv4 "$TARGET_DIR"
rsync -av --progress /tmp/country-ip-blocks/ipv6 "$TARGET_DIR"
find "$TARGET_DIR/ipv4" -name "*.cidr" -exec bash -c 'mv "$0" "${0%.cidr}.txt"' {} \;
find "$TARGET_DIR/ipv6" -name "*.cidr" -exec bash -c 'mv "$0" "${0%.cidr}.txt"' {} \;
# After cloning, check if files exist for the specified country
if [[ ! -f "$TARGET_DIR/ipv4/tt.txt" ]]; then
echo "CIDR file for 'tt' not found. Please ensure the CIDR database is properly updated."
fi
rm -rf /tmp/country-ip-blocks
echo "Update complete! Assets are saved in $TARGET_DIR"
}
generate_ips_from_cidr() {
local cidr_block=$1
local output_file=$2
local max_scans=$3
echo "Generating IPs for CIDR block: $cidr_block using nmap..."
# Use nmap to list all IPs in the CIDR block
nmap -n -sL "$cidr_block" | awk '/Nmap scan report/{print $NF}' | gshuf | head -n "$max_scans" > "$output_file"
local total_ips=$(wc -l < "$output_file")
echo "Generated $total_ips IPs from CIDR block $cidr_block saved to $output_file"
}
# Other functions...
# Fix in perform_scan function
perform_scan() {
local COUNTRY_CODE=$1
local IP_VERSION=$2
local MAX_SCANS=$3
local CIDR_FILE="$TARGET_DIR/$IP_VERSION/$COUNTRY_CODE.txt"
if [[ ! -f "$CIDR_FILE" ]]; then
echo "Error: No CIDR file found for country code '$COUNTRY_CODE' in $IP_VERSION."
return
fi
mkdir -p "./resources/logs"
DATE=$(date +"%Y%m%d_%H%M%S")
LOG_FILE="./resources/logs/${COUNTRY_CODE}_${DATE}.txt"
SCAN_COUNT=0
echo "Performing nmap scan on $IP_VERSION addresses in $COUNTRY_CODE..."
echo "CIDR file found at: $CIDR_FILE"
# Shuffle the CIDR blocks and iterate through them
gshuf "$CIDR_FILE" | while read -r cidr_block; do
echo "Processing CIDR block: $cidr_block"
generate_ips_from_cidr "$COUNTRY_CODE" "$IP_VERSION" $MAX_SCANS
local SANITIZED_CIDR_BLOCK=$(echo "$cidr_block" | sed 's/\//_/g')
echo "Sanitized CIDR block: $SANITIZED_CIDR_BLOCK"
local IP_FILE_PATH="$TARGET_DIR2/$IP_VERSION/$COUNTRY_CODE/${COUNTRY_CODE}_$SANITIZED_CIDR_BLOCK.txt"
echo "Looking for IP file at: $IP_FILE_PATH"
if [[ ! -f "$IP_FILE_PATH" ]]; then
echo "Error: No IP file found for CIDR block $cidr_block in $COUNTRY_CODE for $IP_VERSION."
continue
fi
# Shuffle and scan the IPs
gshuf "$IP_FILE_PATH" | while read -r ip_address; do
if [[ $MAX_SCANS -ne 0 && $SCAN_COUNT -ge $MAX_SCANS ]]; then
break 2
fi
echo "Scanning IP: $ip_address" | tee -a "$LOG_FILE"
sudo proxychains4 nmap -sC -sS -sV --script vuln --open "$ip_address" | tee -a "$LOG_FILE"
((SCAN_COUNT++))
done
done
echo "Scan Results saved in $LOG_FILE"
}
# Request sudo password once
if sudo -v; then
# Keep sudo alive for the duration of the script
while true; do sudo -n true; sleep 60; done 2>/dev/null &
else
echo "Sudo access is required. Exiting..."
exit 1
fi
# Trap to kill background process keeping sudo alive
trap 'kill $(jobs -p)' EXIT
# Start the processes
echo "Updating resources..."
# Start the update tasks, suppressing output
check_for_upgrades > /dev/null 2>&1 &
CHECK_UPGRADES_PID=$! # Save the PID of check_for_upgrades
#update CIDR database
update_cidr > /dev/null 2>&1 &
# Play audio in the background, loop the music infinitely with -loop 0
ffplay -v 0 -nodisp -loop 0 ./resources/audio/audio.mp3 &
FFPLAY_PID=$! # Save the PID of ffplay
# Trap EXIT signal to ensure ffplay process is terminated when the session exits
trap "kill -9 $FFPLAY_PID" EXIT
# Start cmatrix
cmatrix -bs
CMATRIX_PID=$! # Save the PID of cmatrix
trap "kill -9 $CMATRIX_PID" EXIT
# Wait for both tasks to complete
wait $CHECK_UPGRADES_PID
# Output the success message
echo "Resources updated successfully!"
#Setup Proxy Chain
sudo chmod +rwx ./resources/proxy/proxy.sh
sudo ./resources/proxy/proxy.sh
echo "Nation Builder Pro ™ Proxy Server Setup is complete!"
# Check if tor service is running
if ! sudo brew services list | grep -q "tor.*started"; then
echo "Tor service is not running. Waiting for 10 seconds..."
sleep 10
echo "Exiting script."
exit 1
fi
# If Tor is running, continue to execute the rest of the code
echo "Tor service is running. Proceeding with script execution."
trap "sudo brew services stop tor" EXIT
# Stop cmatrix and ffplay after the updates finish
kill -9 $CMATRIX_PID
kill -9 $FFPLAY_PID &
echo "Tasks completed and cmatrix/ffplay stopped."
# Get/Load Credentials
if [[ ! -d "./credentials" ]]; then
mkdir ./credentials
get_credentials
else
load_credentials
check_credentials
fi
# Display the banner only after all installs are completed
init_static_banner
MAX_SCANS=100 # Default value for MAX_SCANS
# MAX_SCANS=0 scans indefinitely
# Main script begins here
while true; do
clear
# Display the banner only after all installs are completed
init_static_banner
echo "MENU:"
echo "1) Search for open ports in a country"
echo "2) IP ADDRESS GEO-LOCATION"
echo "3) GeoPing-Pro ™"
echo "4) GeoCam Pro ™"
echo "5) Trace route to target IP address
echo "6) Exit"
read -p "Choose an option: " option
case $option in
1)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
read -p "Enter country code: " country_code
read -p "Enter IP version (ipv4/ipv6): " ip_version
read -p "Enter maximum number of scans (default 100): " max_scans
# Set defaults if necessary
max_scans=${max_scans:-100}
# Path to CIDR file (this is where your CIDR blocks are stored)
cidr_file="./resources/countries/cidr/$ip_version/$country_code.txt"
# Check if the CIDR file exists
if [[ ! -f "$cidr_file" ]]; then
echo "Error: CIDR file for $country_code and $ip_version not found."
continue
fi
scan_count=0 # Initialize the scan counter
# Read the CIDR block (assuming one CIDR block per line)
while read -r cidr_block && [[ $scan_count -lt $max_scans ]]; do # Stop if max_scans is reached
echo "Processing CIDR block: $cidr_block"
# Path to store generated IPs
output_file="./resources/countries/ip/$ip_version/$country_code/${country_code}_${cidr_block//\//_}.txt"
# Generate IPs for this CIDR block using nmap
generate_ips_from_cidr "$cidr_block" "$output_file" "$max_scans"
# Run the nmap scan on the generated IP addresses
if [[ -f "$output_file" ]]; then
echo "Performing nmap scan on IP addresses in $output_file..."
# Iterate through each IP address in the file
while IFS= read -r ip && [[ $scan_count -lt $max_scans ]]; do
echo "Scanning IP address: $ip"
# Run nmap on the current IP
sudo proxychains4 nmap -sS -sV -O --script vuln --open -Pn "$ip" -oN ./resources/logs/${country_code}_$(date +%Y%m%d_%H%M%S)_${ip}.txt
((scan_count++)) # Increment the scan count
done < "$output_file"
else
echo "Error: No IPs were generated."
fi
done < "$cidr_file"
;;
2)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
clear
ip_info
;;
3)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
clear
echo "Running GeoPing-Pro ™..."
geo_ping
;;
4)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
clear
echo "Running GeoCam-Pro ™..."
search_webcams
break
;;
5)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
echo "Tracing route to target IP address..."
read -p "Enter IP address (ipv4/ipv6): " ip_adress_trace
traceroute ip_adress_trace
break
;;
6)
ffplay -nodisp -autoexit ./resources/audio/audio2.mp3 &>/dev/null &
echo "Exiting..."
break
;;
*)
echo "Invalid option, please try again."
;;
esac
done