-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathht
669 lines (648 loc) · 34.1 KB
/
ht
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
#!/bin/bash
#do not modify this file if you do not understand it
#create https://github.com/ahmadqsyaa
ipmodem="192.168.8.1"
pass="admin"
login() {
data=$(curl -s http://$ipmodem/api/webserver/SesTokInfo -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7")
sesi=$(echo "$data" | grep "SessionID=" | cut -b 10-147)
token=$(echo "$data" | grep "TokInfo" | cut -b 10-41)
check=$(curl -s http://$ipmodem/api/user/state-login -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
state=$(echo $check | awk -F "<State>" '{print $2}' | awk -F "</State>" '{print $1}')
type=$(echo $check | awk -F "<password_type>" '{print $2}' | awk -F "</password_type>" '{print $1}')
if [ $state = "0" ]; then
ok=true
else
if [ $type = "4" ]; then
pass1=$(echo -n "$pass" | sha256sum | head -c 64 | base64 -w 0)
pass1=$(echo -n "admin$pass1$token" | sha256sum | head -c 64 | base64 -w 0)
pass1=$(echo -n "$pass1</Password><password_type>4</password_type>")
else
pass1=$(echo -n "$pass" | base64 -w 0)
pass1=$(echo -n "$pass1</Password>")
fi
login=$(curl -s -D- -o/dev/null -X POST http://$ipmodem/api/user/login -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Username>admin</Username><Password>'$pass1'</request>')
scoki=$(echo "$login" | grep [Ss]et-[Cc]ookie | cut -d':' -f2 | cut -b 1-138)
if [ ! -n "$scoki" ]; then
scoki=$(echo "$login" | grep '__RequestVerificationToken:' | cut -d ':' -f 2 | tr -d ' ')
elif [ ! -n "$scoki" ]; then
echo -e "\e[31mLogin failed, please enter the IP address and password\e[0m"
read -r -p "enter the IP address or [Y/y] default (192.168.8.1): " ipads
if [[ "$ipads" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "ip default: \e[36m192.168.8.1\e[0m"
elif [ ! -n "$ipads" ]; then
echo -e "\e[1;31minput should not be empty\e[0m"
exit 1
else
sed -i "6s/.*/ipmodem=\"$ipads\"/" /usr/bin/ht
echo -e "\e[1;32mip address successfully changed to\e[0m \e[1;31m$ipads\e[0m"
fi
read -r -p "Enter the modem password or [Y/y] default admin: " pswd
if [[ "$pswd" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "password default: \e[36madmin\e[0m"
elif [ ! -n "$ipads" ]; then
echo -e "\e[1;31minput should not be empty\e[0m"
exit 1
else
sed -i "7s/.*/pass=\"$pswd\"/" /usr/bin/ht
echo -e "\e[1;32mpassword successfully changed to\e[0m \e[1;31m$pswd\e[0m"
fi
fi
fi
}
choki() {
data=$(curl -s http://$ipmodem/api/webserver/SesTokInfo -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $scoki")
sesi=$(echo "$data" | grep "SessionID=" | cut -b 10-147)
token=$(echo "$data" | grep "TokInfo" | cut -b 10-41)
}
function reboot() {
login
choki
res=$(curl -s -X POST http://$ipmodem/api/device/control -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Control>1</Control></request>')
ress=$(echo $res | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ "$ress" = "OK" ]; then
echo "\e[1;32mrebooting...\e[0m"
else
echo -e "\e[1;31mfailed rebooting\e[0m"
fi
}
# function for get sms
function format() {
if [ ! -n "$countsms" ]; then
echo -e "\e[1;31mfailed to read SMS or SMS 0\e[0m"
else
if [ "$1" = "1" ]; then
echo -e "Read in \e[1;31m$countsms\e[0m SMS"
elif [ "$1" = "2" ]; then
echo -e "Found \e[1;31m$countsms\e[0m SMS Inbox"
else
echo -e "Found \e[1;31m$countsms\e[0m SMS Outbox"
fi
while read -r message; do
smstat=$(echo "$message" | awk -F '<Smstat>' '{print $2}' | awk -F '</Smstat>' '{print $1}')
index=$(echo "$message" | awk -F '<Index>' '{print $2}' | awk -F '</Index>' '{print $1}')
phone=$(echo "$message" | awk -F '<Phone>' '{print $2}' | awk -F '</Phone>' '{print $1}')
content=$(echo "$message" | awk -F '<Content>' '{print $2}' | awk -F '</Content>' '{print $1}')
date=$(echo "$message" | awk -F '<Date>' '{print $2}' | awk -F '</Date>' '{print $1}')
if [ -n "$smstat" ]; then
if [ "$smstat" = "0" ]; then
status="\e[1;31munread\e[0m"
else
status="\e[1;32mread\e[0m"
fi
echo "---------------------------------------------------------"
echo -e "Status: $status"
echo ""
fi
if [ -n "$index" ]; then
echo "Id: $index"
echo ""
fi
if [ -n "$phone" ]; then
echo "From: $phone"
echo ""
fi
if [ -n "$content" ]; then
echo "Message: $content"
echo ""
fi
if [ -n "$date" ]; then
echo "Date: $date"
echo ""
echo "---------------------------------------------------------"
fi
done <<<"$messages"
fi
}
function getSMS() {
login
choki
if [[ "$1" =~ ^\+?[0-9]+$ ]]; then
if (($1 < 51)); then
cn=$1
if [ ! -n "${2}" ]; then
bk=1
elif [ "$2" = "1" ]; then
bk=1
elif [ "$2" = "2" ]; then
bk=2
fi
get=$(curl -s -X POST http://$ipmodem/api/sms/sms-list -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><PageIndex>1</PageIndex><ReadCount>'"$cn"'</ReadCount><BoxType>'"$bk"'</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>true</UnreadPreferred></request>')
messages=$(echo "$get" | awk -F '</Message>' '{ for(i=1; i<=NF; i++) print $i "</Message>"}')
countsms=$(echo $get | awk -F "<Count>" '{print $2}' | awk -F "</Count>" '{print $1}')
echo "---------------------------------------------------------"
format 1
echo "---------------------------------------------------------"
else
echo -e "\e[31minput can't be more entries should not be more than 50\e[0m"
fi
elif [ "$1" = "outbox" ]; then
login
choki
get=$(curl -s -X POST http://$ipmodem/api/sms/sms-list -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><PageIndex>1</PageIndex><ReadCount>50</ReadCount><BoxType>2</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>true</UnreadPreferred></request>')
messages=$(echo "$get" | awk -F '</Message>' '{ for(i=1; i<=NF; i++) print $i "</Message>"}')
countsms=$(echo $get | awk -F "<Count>" '{print $2}' | awk -F "</Count>" '{print $1}')
echo "---------------------------------------------------------"
format 3
echo "---------------------------------------------------------"
else
cnn=$(curl -s -X GET http://$ipmodem/api/sms/sms-count -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
cn1=$(echo $cnn | awk -F "<LocalInbox>" '{print $2}' | awk -F "</LocalInbox>" '{print $1}')
if (($cn1 < 51)); then
cn=$(echo $cn1)
else
cn="50"
fi
get=$(curl -s -X POST http://$ipmodem/api/sms/sms-list -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><PageIndex>1</PageIndex><ReadCount>'"$cn"'</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>true</UnreadPreferred></request>')
messages=$(echo "$get" | awk -F '</Message>' '{ for(i=1; i<=NF; i++) print $i "</Message>"}')
countsms=$(echo $get | awk -F "<Count>" '{print $2}' | awk -F "</Count>" '{print $1}')
echo "---------------------------------------------------------"
format 2
echo "---------------------------------------------------------"
fi
}
function sendSMS() {
login
to="${1}"
if [[ ! "$to" =~ ^\+?[0-9]+$ ]]; then
echo -e "\e[31mPlease provide the receiver number (08xxxx or +628xxx)\e[0m"
exit 1
fi
message="${@:2}"
if [ -z "$message" ]; then
echo -e "\e[31mPlease provide the message\e[0m"
exit 1
fi
choki
dates=$(date +"%Y-%m-%d %H:%M:%S")
lengh=$(echo -n "$message" | wc -c)
send=$(curl -s -X POST http://$ipmodem/api/sms/send-sms -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Index>-1</Index><Phones><Phone>'"$to"'</Phone></Phones><Sca></Sca><Content>'"$message"'</Content><Length>'"$lengh"'</Length><Reserved>1</Reserved><Date>$dates</Date></request>')
sendd=$(echo $send | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
#echo $sendd
if [ "$sendd" = "OK" ]; then
echo -e "\e[1;32msuccess\e[0m Send SMS to \e[32m$to\e[0m message \e[33m$message\e[0m"
else
echo -e "\e[1;31mfailed send SMS\e[0m"
fi
}
function deletedSMS() {
login
choki
if [ -n "${1}" ]; then
del=$(curl -s -X POST http://$ipmodem/api/sms/delete-sms -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Index>'"$1"'</Index></request>')
dell=$(echo $del | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ "$dell" = "OK" ]; then
echo -e "\e[1;32msuccess delete id\e[0m \e[31m $1\e[0m"
else
echo -e "\e[1;31mfailed, id not found\e[0m"
fi
else
#echo -e "\e[1;36mid require\e[0m"
read -r -p "ꐦ are you sure you want to delete all sms (maximum deleted sms 50) enter [Y/y] if you agree: " aggre
if [[ "$aggre" =~ ^([yY][eE][sS]|[yY])$ ]]; then
get=$(curl -s -X POST http://$ipmodem/api/sms/sms-list -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><PageIndex>1</PageIndex><ReadCount>50</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>true</UnreadPreferred></request>')
cn=$(echo $get | awk -F "<Count>" '{print $2}' | awk -F "</Count>" '{print $1}')
if [ "$cn" == 0 ]; then
echo -e "\e[1;31mfailed to deleted all SMS or SMS 0\e[0m"
else
messages=$(echo "$get" | awk -F '</Message>' '{ for(i=1; i<=NF; i++) print $i "</Message>"}')
login
while read -r message; do
index=$(echo "$message" | awk -F '<Index>' '{print $2}' | awk -F '</Index>' '{print $1}')
if [ -n "$index" ]; then
choki
dellal=$(curl -s -X POST http://$ipmodem/api/sms/delete-sms -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Index>'"$index"'</Index></request>')
dells=$(echo $dellal | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ ! -n "$dells" ]; then
echo -e "\e[1;31mfailed\e[0m"
fi
fi
done <<<"$messages"
if [ ! -n "$index" ]; then
echo -e "\e[1;32msuccessfully deleted all sms\e[0m"
fi
fi
else
echo -e "\e[1;31minput invalid, cancell\e[0m"
exit 1
fi
fi
}
function countSMS() {
login
choki
count=$(curl -s -X GET http://$ipmodem/api/sms/sms-count -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
unread=$(echo $count | awk -F "<LocalUnread>" '{print $2}' | awk -F "</LocalUnread>" '{print $1}')
inbox=$(echo $count | awk -F "<LocalInbox>" '{print $2}' | awk -F "</LocalInbox>" '{print $1}')
outbox=$(echo $count | awk -F "<LocalOutbox>" '{print $2}' | awk -F "</LocalOutbox>" '{print $1}')
draf=$(echo $count | awk -F "<LocalDraft>" '{print $2}' | awk -F "</LocalDraft>" '{print $1}')
deleted=$(echo $count | awk -F "<LocalDeleted>" '{print $2}' | awk -F "</LocalDeleted>" '{print $1}')
echo "--------------------"
echo -e "- unread \e[1;31m$unread\e[0m sms"
echo -e "- inbox \e[1;31m$inbox\e[0m sms"
echo -e "- outbox \e[1;31m$outbox\e[0m sms"
echo -e "- draf \e[1;31m$draf\e[0m sms"
echo -e "- deleted \e[1;31m$deleted\e[0m sms"
echo "--------------------"
}
function readSMS() {
login
choki
if [ -n "${1}" ]; then
read=$(curl -s -X POST http://$ipmodem/api/sms/set-read -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><Index>'"$1"'</Index></request>')
readd=$(echo $read | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ "$readd" = "OK" ]; then
echo -e "\e[1;32msuccessfully changed the unread status to read with id\e[0m \e[33m$1\e[0m"
else
echo -e "\e[1;31mfailed, id not found\e[0m"
fi
else
echo -e "\e[1;36mid require\e[0m"
fi
}
#test
bandsett() {
local freq="$1"
case "$freq" in
"2100") echo 1 ;;
"1900") echo 2 ;;
"1800") echo 4 ;;
"2300") echo 8000000000 ;;
"2600") echo 2000000000 ;;
"850") echo 2000000 ;;
"900") echo 80 ;;
"auto") echo 7FFFFFFFFFFFFFFF ;;
esac
}
function bandSET() {
login
choki
if [ -n "${1}" ]; then
netband=$(bandsett "$1")
setb=$(curl -s -X POST http://$ipmodem/api/net/net-mode -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><NetworkMode>00</NetworkMode><NetworkBand>3FFFFFFF</NetworkBand><LTEBand>'"$netband"'</LTEBand></request>')
settb=$(echo $setb | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ "$settb" = "OK" ]; then
echo -e "\e[1;32msuccess\e[0m"
else
echo -e "\e[1;31mfailed\e[0m"
fi
else
echo -e "\e[1;36mchoose band \e[0m"
echo -e "\e[1;33mauto|850|900|1800|1900|2100|2300|2600\e[0m"
echo -e "\e[1;36mexample: ht -bs 1800\e[0m"
fi
}
function dataSET() {
login
choki
if [ -n "${1}" ]; then
set=$(curl -s -X POST http://$ipmodem/api/dialup/mobile-dataswitch -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi" -d '<?xml version="1.0" encoding="UTF-8"?><request><dataswitch>'"$1"'</dataswitch></request>')
sett=$(echo $set | awk -F "<response>" '{print $2}' | awk -F "</response>" '{print $1}')
if [ "$sett" = "OK" ]; then
echo -e "\e[1;32msuccess\e[0m"
dataSTATUS
else
echo -e "\e[1;31mfailed, select 1 and 0\e[0m"
fi
else
echo -e "\e[1;36mchoose 0/1\e[0m"
fi
}
function dataSTATUS() {
login
choki
datas=$(curl -s -X GET http://$ipmodem/api/dialup/mobile-dataswitch -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
#echo $datas
datass=$(echo $datas | awk -F "<dataswitch>" '{print $2}' | awk -F "</dataswitch>" '{print $1}')
#echo $datass
if [ "$datass" == 1 ]; then
echo -e "\e[1;32mDATA ON\e[0m"
else
echo -e "\e[1;31mDATA OFF\e[0m"
fi
}
# info modem
human_print() {
while read B dummy; do
[ $B -lt 1024 ] && echo ${B} B && break
KB=$(((B + 512) / 1024))
[ $KB -lt 1024 ] && echo ${KB} KB && break
MB=$(((KB + 512) / 1024))
[ $MB -lt 1024 ] && echo ${MB} MB && break
GB=$(((MB + 512) / 1024))
[ $GB -lt 1024 ] && echo ${GB} GB && break
echo $(((GB + 512) / 1024)) terabytes
done
}
bands() {
case $1 in
"1")
echo -e '2100 MHz'
;;
"3")
echo -e '1800 MHz'
;;
"8")
echo -e '900 MHz'
;;
"40")
echo -e '2300 MHz'
;;
esac
}
network() {
case $1 in
"0")
echo -e 'No service'
;;
"1")
echo -e 'GSM (2G)'
;;
"2")
echo -e 'GPRS (2G)'
;;
"3")
echo -e 'EDGE (2G)'
;;
"21")
echo -e 'IS95A'
;;
"22")
echo -e 'IS95B'
;;
"23")
echo -e 'CDMA 1X'
;;
"24")
echo -e 'EVDO rev.0'
;;
"25")
echo -e 'EVDO rev.A'
;;
"26")
echo -e 'EVDO rev.B'
;;
"27")
echo -e 'HYBRID CDMA 1X'
;;
"28")
echo -e 'HYBRID EVDO rev.0'
;;
"29")
echo -e 'HYBRID EVDO rev.A'
;;
"30")
echo -e 'HYBRID EVDO rev.B'
;;
"31")
echo -e 'eHRPD rel.0'
;;
"32")
echo -e 'eHRPD rel.A'
;;
"33")
echo -e 'eHRPD rel.B'
;;
"34")
echo -e 'HYBRID eHRPD rel.0'
;;
"35")
echo -e 'HYBRID eHRPD rel.A'
;;
"36")
echo -e 'HYBRID eHRPD rel.B'
;;
"41")
echo -e 'UMTS (3G)'
;;
"42")
echo -e 'HSDPA (3G)'
;;
"43")
echo -e 'HSUPA (3G)'
;;
"44")
echo -e 'HSPA (3G)'
;;
"45")
echo -e 'HSPA+ (3.5G)'
;;
"46")
echo -e 'DC-HSPA+ (3.5G)'
;;
"61")
echo -e 'TD-SCDMA (3G)'
;;
"62")
echo -e 'TD-HSDPA (3G)'
;;
"63")
echo -e 'TD-HSUPA (3G)'
;;
"64")
echo -e 'TD-HSPA (3G)'
;;
"65")
echo -e 'TD-HSPA+ (3.5G)'
;;
"81")
echo -e '802.16E'
;;
"101")
echo -e 'LTE (4G)'
;;
"1011")
echo -e 'LTE CA (4G+)'
;;
"111")
echo -e 'NR (5G)'
;;
esac
}
function info() {
login
choki
oper=$(curl -s http://$ipmodem/api/net/current-plmn -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
ip=$(curl -s http://$ipmodem/api/device/information -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
dns=$(curl -s http://$ipmodem/api/monitoring/status -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
td=$(curl -s http://$ipmodem/api/monitoring/traffic-statistics -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
dvi=$(curl -s http://$ipmodem/api/device/signal -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
par=$(curl -s http://$ipmodem/config/deviceinformation/add_param.xml -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
operator=$(echo $oper | awk -F "<FullName>" '{print $2}' | awk -F "</FullName>" '{print $1}')
ipp=$(echo $ip | awk -F "<WanIPAddress>" '{print $2}' | awk -F "</WanIPAddress>" '{print $1}')
tp=$(echo $ip | awk -F "<DeviceName>" '{print $2}' | awk -F "</DeviceName>" '{print $1}')
dns1=$(echo $dns | awk -F "<PrimaryDns>" '{print $2}' | awk -F "</PrimaryDns>" '{print $1}')
dns2=$(echo $dns | awk -F "<SecondaryDns>" '{print $2}' | awk -F "</SecondaryDns>" '{print $1}')
net=$(echo $dns | awk -F "<CurrentNetworkTypeEx>" '{print $2}' | awk -F "</CurrentNetworkTypeEx>" '{print $1}')
tup=$(echo $td | awk -F "<TotalUpload>" '{print $2}' | awk -F "</TotalUpload>" '{print $1}' | human_print)
tdd=$(echo $td | awk -F "<TotalDownload>" '{print $2}' | awk -F "</TotalDownload>" '{print $1}' | human_print)
band=$(echo $par | awk -F "<band>" '{print $2}' | awk -F "</band>" '{print $1}')
dlfreq=$(echo $par | awk -F "<freq1>" '{print $2}' | awk -F "</freq1>" '{print $1}')
upfreq=$(echo $par | awk -F "<freq2>" '{print $2}' | awk -F "</freq2>" '{print $1}')
pci=$(echo $dvi | awk -F "<pci>" '{print $2}' | awk -F "</pci>" '{print $1}')
cellid=$(echo $dvi | awk -F "<cell_id>" '{print $2}' | awk -F "</cell_id>" '{print $1}')
rsrp=$(echo $dvi | awk -F "<rsrp>" '{print $2}' | awk -F "</rsrp>" '{print $1}')
rssi=$(echo $dvi | awk -F "<rssi>" '{print $2}' | awk -F "</rssi>" '{print $1}')
rsrq=$(echo $dvi | awk -F "<rsrq>" '{print $2}' | awk -F "</rsrq>" '{print $1}')
sinr=$(echo $dvi | awk -F "<sinr>" '{print $2}' | awk -F "</sinr>" '{print $1}')
}
function usage() {
info
echo "╔════════❖══════════❖════════╗"
echo -e "| \e[35mHuawei Tools Script v2\e[0m |"
echo "| Created by Rick Qsyaerick |"
echo "╚════════❖═════|════❖════════╝"
echo "╔════════❖═════|════❖════════╗"
echo -e "➥ 𝙾𝚙𝚎𝚛𝚊𝚝𝚘𝚛 : \e[1;34m$operator\e[0m"
echo -e "➥ 𝙳𝚎𝚟𝚒𝚌𝚎 : \e[1;34m$tp\e[0m"
echo -e "➥ 𝚆𝚊𝚗 𝙸𝙿 : \e[32m$ipp\e[0m"
echo "╚════════❖═════|════❖════════╝"
echo "-------------------------------------------------------"
echo "| < USAGE > |"
echo "-------------------------------------------------------"
echo -e "|• \e[33m-r\e[0m get all sms inbox (default) |"
echo -e "|• \e[33m-r outbox\e[0m get all sms outbox |"
echo -e "|• \e[33m-r [1-50] [id-box]\e[0m get sms with count |"
echo -e "|• \e[33m-s [nophone] [message]\e[0m send sms |"
echo -e "|• \e[33m-d\e[0m \e[31mdeleted all sms\e[0m |"
echo -e "|• \e[33m-d [id sms]\e[0m deleted sms with id |"
echo -e "|• \e[33m-c\e[0m get the sms count on each box |"
echo -e "|• \e[33m-b [id sms]\e[0m set the sms status to read |"
echo -e "|• \e[33m-m [1/0]\e[0m change mobile data |"
echo -e "|• \e[33m-ms\e[0m view the mobile data status |"
echo -e "|• \e[33m-o\e[0m reboot the modem |"
echo -e "|• \e[33m-i\e[0m net info & modem info |"
echo -e "|• \e[33m-a\e[0m renew wan ip address |"
echo -e "|• \e[33m-u\e[0m update script or reinstall script |"
echo -e "|• \e[33m-rf\e[0m \e[31m[danger zona] uninstall script \e[0m |"
echo -e "|\e[32mINFO\e[0m |"
echo -e "| \e[33m[id-box]\e[0m 1 = inbox, 2 = outbox (opsional default 1) |"
echo -e "| \e[33m[1/0]\e[0m \e[31m0 = OFF\e[0m \e[32m1 = ON\e[0m |"
echo -e "-------------------------------------------------------"
}
function informasi() {
info
echo "╔════════❖══════════❖════════╗"
echo "➥ 𝙾𝚙𝚎𝚛𝚊𝚝𝚘𝚛 : $operator"
echo "➥ 𝙳𝚎𝚟𝚒𝚌𝚎 : $tp"
echo "➥ 𝚆𝚊𝚗 𝙸𝙿 : $ipp"
echo "➥ 𝙳𝙽𝚂 1 : $dns1"
echo "➥ 𝙳𝙽𝚂 2 : $dns2"
echo "➥ $(
echo -ne "𝙽𝚎𝚝𝚠𝚘𝚛𝚔 : "
network $net
)"
echo "➥ 𝚃𝚘𝚝𝚊𝚕 𝚄𝚙𝚕𝚘𝚊𝚍 : $tup"
echo "➥ 𝚃𝚘𝚝𝚊𝚕 𝙳𝚘𝚠𝚗𝚕𝚘𝚊𝚍 : $tdd"
echo "➥ $(
echo -ne "𝙱𝚊𝚗𝚍 : "
bands $band
) $(echo -ne "("$band")")"
echo "➥ 𝙿𝙲𝙸 : $pci"
echo "➥ 𝙲𝚎𝚕𝚕 𝙸𝙳 : $cellid"
echo "➥ 𝙳𝙻 𝙵𝚛𝚎𝚚𝚞𝚎𝚗𝚌𝚢 : $dlfreq"
echo "➥ 𝚄𝙿 𝙵𝚛𝚎𝚚𝚞𝚎𝚗𝚌𝚢 : $upfreq"
echo "➥ 𝚁𝚜𝚛𝚙 : $rsrp"
echo "➥ 𝚁𝚜𝚜𝚒 : $rssi"
echo "➥ 𝚁𝚜𝚛𝚚 : $rsrq"
echo "➥ 𝚂𝚒𝚗𝚛 : $sinr"
echo "╚════════❖══════════❖════════╝"
}
function restart() {
start_time=$(date +%s)
choki
info
echo -e "\e[1;32mbefore WAN IP: $ipp\e[0m"
echo -e "\e[1;33mplease wait ...\e[0m"
res=$(curl -s -X GET http://$ipmodem/api/net/plmn-list -H "Host: $ipmodem" -H "Connection: keep-alive" -H "Accept: */*" -H "Origin: http://$ipmodem" -H "X-Requested-With: XMLHttpRequest" -H "__RequestVerificationToken: $token" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Referer: http://$ipmodem/html/home.html" -H "Accept-Encoding: gzib, deflate" -H "Accept-Language: id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7" -H "Cookie: $sesi")
#echo $res
if [ -n "$res" ]; then
sleep 5
echo -e "\033[1A\033[K"
info
end_time=$(date +%s)
duration=$((end_time - start_time))
echo -e "\e[1;32mafter WAN IP: $ipp\e[0m"
echo -e "\e[1;36mcompleted in time $duration s\e[0m"
fi
}
function update() {
bckip=$(sed -n '6p' /usr/bin/ht)
bckpw=$(sed -n '7p' /usr/bin/ht)
echo "backup ip address & password"
wget -q -O /usr/bin/ht-update https://raw.githubusercontent.com/ahmadqsyaa/hw-tools-script/main/ht
if [ $? -ne 0 ]; then
echo -e "\e[1;31mUpdate/reinstall failed please try again and make sure your internet is good\e[0m"
exit 1
else
chmod +x /usr/bin/ht-update
sed -i "6s/.*/$bckip/" /usr/bin/ht-update
sed -i "7s/.*/$bckpw/" /usr/bin/ht-update
echo -e "\e[1;36msuccessfully update/reinstall\e[0m"
sleep 1
rm -rf /usr/bin/ht
mv /usr/bin/ht-update /usr/bin/ht
fi
}
function uninstall() {
read -r -p "Are you sure you want to uninstall? [Y/y] or [N/n]: " yn
if [[ "$yn" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "thanks for using huawei tools script :)"
sleep 1
rm -rf /usr/bin/ht
else
echo "uninstall canceled"
exit
fi
}
# end info modem
case "${1}" in
-r)
shift
getSMS "${@}"
;;
-s)
shift
sendSMS "${@}"
;;
-d)
shift
deletedSMS "${@}"
;;
-c)
countSMS
;;
-b)
shift
readSMS "${@}"
;;
-bs)
shift
bandSET "${@}"
;;
-m)
shift
dataSET "${@}"
;;
-ms)
dataSTATUS
;;
-o)
reboot
;;
-i)
informasi
;;
-a)
restart
;;
-u)
update
;;
-rf)
uninstall
;;
*)
usage
;;
esac