-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMisCORS.sh
134 lines (106 loc) Β· 3.15 KB
/
MisCORS.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
#!/bin/bash
N='\033[0m'
R='\033[0;31m'
G='\033[0;32m'
O='\033[0;33m'
B='\033[0;34m'
C='\033[0;36m'
W='\033[0;37m'
print_banner() {
local banner=(
"******************************************"
"* MisCORS *"
"* CORS Hunter / Vulnerability Tool *"
"* v1.2.1 *"
"* ---------------------------- *"
"* by @ImKKingshuk *"
"* Github- https://github.com/ImKKingshuk *"
"******************************************"
)
local width=$(tput cols)
for line in "${banner[@]}"; do
printf "%*s\n" $(((${#line} + width) / 2)) "$line"
done
echo
}
check_internet() {
echo -e "${O}[+] Checking Internet Connectivity\n"
sleep 2
if ! ping -c 1 8.8.8.8 &> /dev/null; then
echo "No Internet Connection"
exit 1
else
echo "Internet is present"
sleep 2
fi
}
cors_check_advanced() {
local site="$1"
local output_format="$2"
local output_file="output.$output_format"
local timeout=5
echo -e "${C}\n[+] Searching For CORS Misconfiguration on $site\n"
local response=$(curl -s --max-time "$timeout" -Iv "$site" -H "Origin: evil.com" 2>&1)
case $output_format in
"json")
echo -e "{ \"url\": \"$site\", \"result\": {" > "$output_file"
;;
*)
echo -e "\nURL: $site" > "$output_file"
;;
esac
echo "$response" >> "$output_file"
if grep -q "evil.com" <<< "$response"; then
echo -e "${R}URL: $site [Vulnerable]\n"
grep -e "evil.com" -e "access-control-allow-credentials:" "$output_file"
else
echo -e "${G}URL: $site [Not Vulnerable]\n"
fi
case $output_format in
"json")
echo -e "}}" >> "$output_file"
;;
esac
}
interactive_mode() {
local option
echo -e "${O}[+] Interactive Mode"
echo -e "${O}[+] Options:"
echo -e "${O}[1] Perform CORS check"
echo -e "${O}[2] Exit"
read -r -p "[?] Choose an option: " option
case $option in
1)
read -r -p "${C}\n[+] Enter Site (e.g https://site-url.com): " site
echo -e "${O}[+] Choose Output Format:"
echo -e "${O}[1] Normal text"
echo -e "${O}[2] JSON"
read -r -p "[?] Choose an option: " output_option
case $output_option in
1) output_format="txt" ;;
2) output_format="json" ;;
*)
echo -e "${R}[!] Invalid output format option. Defaulting to normal text."
output_format="txt"
;;
esac
cors_check_advanced "$site" "$output_format"
;;
2)
echo -e "${O}[+] Exiting..."
exit 0
;;
*)
echo -e "${R}[!] Invalid option. Exiting..."
exit 1
;;
esac
}
trap 'printf "\e[1;77m \n Ctrl+C was pressed, exiting...\n\n \e[0m"; exit 0' 2
print_banner
check_internet
clear
print_banner
while true; do
interactive_mode
done