-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurl-SMS.sh
130 lines (109 loc) · 4.31 KB
/
Curl-SMS.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
#/bin/bash
# INIT
log=/dev/null;
tmp=/tmp/;
cookies="$tmp""cookies";
err="For more details, you can consult the log file \"""$tmp""Curl-SMS.log\" (if -l used)";
# REMOVE PREVIOUS FILES
rm "$tmp""Curl-SMS.log" 2> $log;
rm "$cookies" 2> $log;
# USAGE
usage() {
echo "
Usage : Curl-SMS -u <login> -p <password> -d <recipient> -m <message> [-l]
-d recipient phone number, use with country code (+33601020304)
-m message, special characters must be escaped (\\)
-p account password
-u account login (0601020304 or user@mail.com)
-l (optional) log \""$tmp"Curl-SMS.log\"
Exemples :
Curl-SMS -u user@mail.com -p p@ssword -d +33601020304 -m \"Message...\"
Curl-SMS -u \"0601020304\" -p \"p@ss\" -d \"+33601020304\" -m \"First line. \nSecond line...\" -l
";
exit 1;
};
# INIT WITH ARGUMENTS
while getopts "d:m:p:u:l" option; do
case "${option}" in
d)
dest=${OPTARG};
;;
m)
mess=${OPTARG};
# REPLACE SPACES BY NBSP (UTF-8)
mess=$(echo $mess | sed "s/ /\xC2\xA0/g");
;;
l)
log="/tmp/Curl-SMS.log";
;;
p)
pass=${OPTARG};
;;
u)
user=${OPTARG};
;;
*)
usage;
;;
esac
done;
# CHECK ARGUMENTS # $#
if [[ $# -lt 8 || -z "$dest" || -z "$mess" || -z "$pass" || -z "$user" ]]; then
usage;
fi;
# CHECK NETWORK
if ! [[ $(ping 1.1.1.1 -c 1 | grep -i ttl) ]]; then
echo " Error : Check your internet connection";
exit 1;
fi;
# JSON PARSE
user='{"login":"'$user'","params":{}}';
pass='{"password":"'$pass'","remember":false}';
mess='{"content":"'$mess'","recipients":["'$dest'"],"replyType":"mobile","messageId":"0"}';
# PARAMETERS
UserA="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0";
Accept="Accept: application/json, text/plain";
AcceptL="Accept-Language: en-US,en;q=0.5";
AcceptE="Accept-Encoding: gzip, deflate, br";
Conn="Connection: keep-alive";
ContT="content-type: application/json";
# GET SESSION # SET COOKIES
echo " GET : SESSION";
curl -Is 'https://login.orange.fr' -c $cookies -H "$Accept" -H "$AcceptE" -H "$Conn" > $log;
# POST LOGIN # SET COOKIES
echo " POST : LOGIN";
curl -s 'https://login.orange.fr/api/login' -X POST -c $cookies -b $cookies -H "$ContT" -H "$Accept" -H "$AcceptL" -H "$AcceptE" -H "$UserA" -H "$Conn" -H 'Referer: https://login.orange.fr/' -H 'Origin: https://login.orange.fr' -H 'DNT: 1' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' --data-raw $user >> $log;
# POST PASSWORD # SET COOKIES
echo " POST : SECRET";
curl -s 'https://login.orange.fr/api/password' -X POST -c $cookies -b $cookies -H "$ContT" -H "$UserA" -H "$Accept" -H "$AcceptL" -H "$AcceptE" -H "$Conn" -H 'Referer: https://login.orange.fr/' -H 'Origin: https://login.orange.fr' -H 'DNT: 1' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' --data-raw $pass >> $log;
# GET TOKEN
echo " GET : TOKEN";
token=$(curl -s 'https://api.webxms.orange.fr/api/v8/token' -b $cookies -H "$ContT" -H "$UserA" -H "$Accept" -H "$AcceptL" -H "$AcceptE" -H "$Conn" -H 'x-xms-service-id: OMI' -H 'cache-control: no-cache' -H 'Pragma: no-cache' -H 'if-none-match: 0' -H 'Origin: https://smsmms.orange.fr' -H 'DNT: 1' -H 'Referer: https://smsmms.orange.fr/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'TE: trailers');
if [[ "$token" == *"\"token\":"* ]]; then
token="authorization: Bearer "$(echo $token | cut -f8 -d\");
else
echo "
ERROR : TOKKEN
MESSAGE : NOT SENT
""$err";
rm $cookies;
exit 1;
fi;
# POST MESSAGE # RETURN JSON
echo " TRY SEND :" $dest;
result=$(curl -s 'https://api.webxms.orange.fr/api/v8/users/me/messages' -X POST -b $cookies -H "$token" -H "$ContT" -H "$Accept" -H "$AcceptL" -H "$AcceptE" -H "$Conn" -H 'x-xms-service-id: OMI' -H 'cache-control: no-cache' -H 'Pragma: no-cache' -H 'if-none-match: 0' -H 'Origin: https://smsmms.orange.fr' -H 'Referer: https://smsmms.orange.fr/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'TE: trailers' --data-raw $mess);
# DELETE TMP FILES
rm $cookies;
# VERIFY RETURN # JSON
if [[ "$result" == *"\"status\":\"sent\","* ]]; then
echo " MESSAGE : SENT";
echo $result > $log;
exit 0;
fi;
# RETURN JSON RESULT / IF STATUS NOT SENT
echo "
ERROR : MESSAGE NOT SENT
""$result""
""$err""
";
exit 1;