Code Duplication    Length = 10-11 lines in 31 locations

src/ScriptedAgentDetector.php 31 locations

@@ 93-102 (lines=10) @@
90
     *
91
     * @return bool
92
     */
93
    public static function checkRobotwkHTMLtoPDF()
94
    {
95
        if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) {
96
            self::$scriptedAgent->setName(ScriptedAgent::WKHTMLTOPDF);
97
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
98
            self::$scriptedAgent->setInfoURL("https://wkhtmltopdf.org/");
99
            return true;
100
        }
101
        return false;
102
    }
103
104
    /**
105
     * Determine if the browser is the ICQ preview.
@@ 170-180 (lines=11) @@
167
     *
168
     * @return bool
169
     */
170
    public static function checkRobotBaidu()
171
    {
172
        if (stripos(self::$userAgentString, "Baiduspider") !== false)
173
        {
174
            self::$scriptedAgent->setName(ScriptedAgent::BAIDU);
175
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
176
            self::$scriptedAgent->setInfoURL("https://support.google.com/webmasters/answer/1061943?hl=en");
177
            return true;
178
        }
179
        return false;
180
    }
181
182
    /**
183
     * Determine if the agent is the Facebook preview bot.
@@ 187-197 (lines=11) @@
184
     *
185
     * @return bool
186
     */
187
    public static function checkRobotFacebook()
188
    {
189
        if (stripos(self::$userAgentString, "facebookexternalhit") !== false)
190
        {
191
            self::$scriptedAgent->setName(ScriptedAgent::FACEBOOK);
192
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
193
            self::$scriptedAgent->setInfoURL("https://www.facebook.com/externalhit_uatext.php");
194
            return true;
195
        }
196
        return false;
197
    }
198
199
    /**
200
     * Determine if the agent is the bing spider, bing preview bot, or MSN bot
@@ 244-254 (lines=11) @@
241
     * @return bool
242
     *
243
     */
244
    public static function checkRobotSlurp()
245
    {
246
        if (stripos(self::$userAgentString, "Yahoo! Slurp") !== false)
247
        {
248
            self::$scriptedAgent->setName(ScriptedAgent::SLURP);
249
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
250
            self::$scriptedAgent->setInfoURL("https://help.yahoo.com/kb/SLN22600.html");
251
            return true;
252
        }
253
        return false;
254
    }
255
256
    /**
257
     * Determine if the agent is the twitter preview bot.
@@ 261-271 (lines=11) @@
258
     *
259
     * @return bool
260
     */
261
    public static function checkRobotTwitter()
262
    {
263
        if (stripos(self::$userAgentString, "Twitterbot/") !== false)
264
        {
265
            self::$scriptedAgent->setName(ScriptedAgent::TWITTER);
266
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
267
            self::$scriptedAgent->setInfoURL("http://stackoverflow.com/questions/22362215/twitter-user-agent-on-sharing");
268
            return true;
269
        }
270
        return false;
271
    }
272
273
    /**
274
     * Determine if the agent is the skype preview bot.
@@ 278-288 (lines=11) @@
275
     *
276
     * @return bool
277
     */
278
    public static function checkRobotSkype()
279
    {
280
        if (stripos(self::$userAgentString, "SkypeUriPreview") !== false)
281
        {
282
            self::$scriptedAgent->setName(ScriptedAgent::SKYPE);
283
            self::$scriptedAgent->setType(ScriptedAgent::PREVIEW);
284
            self::$scriptedAgent->setInfoURL("http://www.skype.com");
285
            return true;
286
        }
287
        return false;
288
    }
289
290
    /**
291
     * Determine if the agent is the W3C Validator tool.
@@ 327-337 (lines=11) @@
324
     *
325
     * @return bool
326
     */
327
    public static function checkRobotYandex()
328
    {
329
        if (stripos(self::$userAgentString, "YandexBot/") !== false)
330
        {
331
            self::$scriptedAgent->setName(ScriptedAgent::YANDEX);
332
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
333
            self::$scriptedAgent->setInfoURL("http://yandex.com/bots");
334
            return true;
335
        }
336
        return false;
337
    }
338
339
    /**
340
     * Determine if the agent is the AppleBot
@@ 344-354 (lines=11) @@
341
     *
342
     * @return bool
343
     */
344
    public static function checkRobotApple()
345
    {
346
        if (stripos(self::$userAgentString, "AppleBot/") !== false)
347
        {
348
            self::$scriptedAgent->setName(ScriptedAgent::APPLEBOT);
349
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
350
            self::$scriptedAgent->setInfoURL("https://support.apple.com/en-gb/HT204683");
351
            return true;
352
        }
353
        return false;
354
    }
355
356
    /**
357
     * Determine if the agent is the Paper.li bot.
@@ 361-371 (lines=11) @@
358
     *
359
     * @return bool
360
     */
361
    public static function checkRobotPaperli()
362
    {
363
        if (stripos(self::$userAgentString, "PaperLiBot/") !== false)
364
        {
365
            self::$scriptedAgent->setName(ScriptedAgent::PAPERLI);
366
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
367
            self::$scriptedAgent->setInfoURL("https://support.paper.li/hc/en-us/articles/204105253-What-is-Paper-li-");
368
            return true;
369
        }
370
        return false;
371
    }
372
373
    /**
374
     * Determine if the agent is the Ahrefs survey.
@@ 378-388 (lines=11) @@
375
     *
376
     * @return bool
377
     */
378
    public static function checkRobotAhrefs()
379
    {
380
        if (stripos(self::$userAgentString, "AhrefsBot/") !== false)
381
        {
382
            self::$scriptedAgent->setName(ScriptedAgent::AHREFS);
383
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
384
            self::$scriptedAgent->setInfoURL("https://ahrefs.com/robot");
385
            return true;
386
        }
387
        return false;
388
    }
389
390
    /**
391
     * Determine if the agent is the Majestic 12 spider.
@@ 395-405 (lines=11) @@
392
     *
393
     * @return bool
394
     */
395
    public static function checkRobotMJ12()
396
    {
397
        if (stripos(self::$userAgentString, "MJ12Bot/") !== false)
398
        {
399
            self::$scriptedAgent->setName(ScriptedAgent::MJ12);
400
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
401
            self::$scriptedAgent->setInfoURL("http://www.majestic12.co.uk/projects/dsearch/mj12bot.php");
402
            return true;
403
        }
404
        return false;
405
    }
406
407
    /**
408
     * Determine if the agent is the LiveLap spider.
@@ 412-422 (lines=11) @@
409
     *
410
     * @return bool
411
     */
412
    public static function checkRobotLiveLap()
413
    {
414
        if (stripos(self::$userAgentString, "LivelapBot/") !== false)
415
        {
416
            self::$scriptedAgent->setName(ScriptedAgent::LIVELAP);
417
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
418
            self::$scriptedAgent->setInfoURL("http://site.livelap.com/crawler.html");
419
            return true;
420
        }
421
        return false;
422
    }
423
424
    /**
425
     * Determine if the agent is a Web Distributed Authoring and Versioning client. Usually unexpected WebDAV requests are hack attempts.
@@ 447-457 (lines=11) @@
444
     *
445
     * @return bool
446
     */
447
    public static function checkRobotMetaURI()
448
    {
449
        if (stripos(self::$userAgentString, "MetaURI API/") !== false)
450
        {
451
            self::$scriptedAgent->setName(ScriptedAgent::METAURI);
452
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
453
            self::$scriptedAgent->setInfoURL("https://github.com/stateless-systems/uri-meta");
454
            return true;
455
        }
456
        return false;
457
    }
458
459
    /**
460
     * Determine if the agent is the TLSProbe tool.
@@ 464-474 (lines=11) @@
461
     *
462
     * @return bool
463
     */
464
    public static function checkRobotTLSProbe()
465
    {
466
        if (stripos(self::$userAgentString, "TLSProbe/") !== false)
467
        {
468
            self::$scriptedAgent->setName(ScriptedAgent::TLSPROBE);
469
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
470
            self::$scriptedAgent->setInfoURL("https://bitbucket.org/marco-bellaccini/tlsprobe");
471
            return true;
472
        }
473
        return false;
474
    }
475
476
    /**
477
     * Determine if the agent is the scoop.it bots.
@@ 499-509 (lines=11) @@
496
     *
497
     * @return bool
498
     */
499
    public static function checkRobotNetcraft()
500
    {
501
        if (stripos(self::$userAgentString, "Netcraft SSL Server Survey") !== false)
502
        {
503
            self::$scriptedAgent->setName(ScriptedAgent::NETCRAFT);
504
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
505
            self::$scriptedAgent->setInfoURL("https://www.netcraft.com/internet-data-mining/ssl-survey/");
506
            return true;
507
        }
508
        return false;
509
    }
510
511
    /**
512
     * Determine if the agent is the curl library/cli tool.
@@ 516-526 (lines=11) @@
513
     *
514
     * @return bool
515
     */
516
    public static function checkRobotCurl()
517
    {
518
        if (stripos(self::$userAgentString, "curl/") !== false)
519
        {
520
            self::$scriptedAgent->setName(ScriptedAgent::CURL);
521
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
522
            self::$scriptedAgent->setInfoURL("https://curl.haxx.se/");
523
            return true;
524
        }
525
        return false;
526
    }
527
528
    /**
529
     * Determine if the agent is the python programming language.
@@ 551-561 (lines=11) @@
548
     *
549
     * @return bool
550
     */
551
    public static function checkRobotGoLang()
552
    {
553
        if (stripos(self::$userAgentString, "Go-http-client") !== false)
554
        {
555
            self::$scriptedAgent->setName(ScriptedAgent::GOLANG);
556
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
557
            self::$scriptedAgent->setInfoURL("https://golang.org/");
558
            return true;
559
        }
560
        return false;
561
    }
562
563
    /**
564
     * Determine if the agent is the perl programming language.
@@ 568-578 (lines=11) @@
565
     *
566
     * @return bool
567
     */
568
    public static function checkRobotPerl()
569
    {
570
        if (stripos(self::$userAgentString, "libwww-perl/") !== false)
571
        {
572
            self::$scriptedAgent->setName(ScriptedAgent::PERL);
573
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
574
            self::$scriptedAgent->setInfoURL("https://www.perl.org/");
575
            return true;
576
        }
577
        return false;
578
    }
579
580
    /**
581
     * Determine if the agent is the wget tool.
@@ 585-595 (lines=11) @@
582
     *
583
     * @return bool
584
     */
585
    public static function checkRobotWget()
586
    {
587
        if (stripos(self::$userAgentString, "Wget/") !== false)
588
        {
589
            self::$scriptedAgent->setName(ScriptedAgent::WGET);
590
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
591
            self::$scriptedAgent->setInfoURL("https://www.gnu.org/software/wget/");
592
            return true;
593
        }
594
        return false;
595
    }
596
597
    /**
598
     * Determine if the agent is the zgrab TLS banner tool.
@@ 602-612 (lines=11) @@
599
     *
600
     * @return bool
601
     */
602
    public static function checkRobotZGrab()
603
    {
604
        if (stripos(self::$userAgentString, "zgrab/") !== false)
605
        {
606
            self::$scriptedAgent->setName(ScriptedAgent::ZGRAB);
607
            self::$scriptedAgent->setType(ScriptedAgent::TOOL);
608
            self::$scriptedAgent->setInfoURL("https://github.com/zmap/zgrab");
609
            return true;
610
        }
611
        return false;
612
    }
613
614
    /**
615
     * Determine if the agent is the Java programming language.
@@ 619-629 (lines=11) @@
616
     *
617
     * @return bool
618
     */
619
    public static function checkRobotJava()
620
    {
621
        if (stripos(self::$userAgentString, "Java/") !== false)
622
        {
623
            self::$scriptedAgent->setName(ScriptedAgent::JAVA);
624
            self::$scriptedAgent->setType(ScriptedAgent::GENERIC);
625
            self::$scriptedAgent->setInfoURL("https://www.java.com/en/");
626
            return true;
627
        }
628
        return false;
629
    }
630
631
    /**
632
     * Determine if the agent is the ShellShock exploit.
@@ 636-646 (lines=11) @@
633
     *
634
     * @return bool
635
     */
636
    public static function checkRobotShellshock()
637
    {
638
        if (stripos(self::$userAgentString, "() { :;}; /bin/bash -c") !== false)
639
        {
640
            self::$scriptedAgent->setName(ScriptedAgent::SHELLSHOCK);
641
            self::$scriptedAgent->setType(ScriptedAgent::EXPLOIT);
642
            self::$scriptedAgent->setInfoURL("https://blog.cloudflare.com/inside-shellshock/");
643
            return true;
644
        }
645
        return false;
646
    }
647
648
    /**
649
     * Determine if the agent is the browsershots testing tool.
@@ 653-663 (lines=11) @@
650
     *
651
     * @return bool
652
     */
653
    public static function checkRobotBrowershots()
654
    {
655
        if (stripos(self::$userAgentString, "Browsershots") !== false)
656
        {
657
            self::$scriptedAgent->setName(ScriptedAgent::BROWSERSHOTS);
658
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
659
            self::$scriptedAgent->setInfoURL("http://browsershots.org/");
660
            return true;
661
        }
662
        return false;
663
    }
664
665
    /**
666
     * Determine if the agent is the who.is spider.
@@ 670-680 (lines=11) @@
667
     *
668
     * @return bool
669
     */
670
    public static function checkRobotWhois()
671
    {
672
        if (stripos(self::$userAgentString, "who.is bot") !== false)
673
        {
674
            self::$scriptedAgent->setName(ScriptedAgent::WHOIS);
675
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
676
            self::$scriptedAgent->setInfoURL("http://www.who.is/");
677
            return true;
678
        }
679
        return false;
680
    }
681
682
    /**
683
     * Determine if the agent is the MageReport exploit survey.
@@ 687-697 (lines=11) @@
684
     *
685
     * @return bool
686
     */
687
    public static function checkRobotMageReport()
688
    {
689
        if (stripos(self::$userAgentString, "MageReport") !== false)
690
        {
691
            self::$scriptedAgent->setName(ScriptedAgent::MAGEREPORT);
692
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
693
            self::$scriptedAgent->setInfoURL("https://www.magereport.com/");
694
            return true;
695
        }
696
        return false;
697
    }
698
699
    /**
700
     * Determine if the agent is the AdBeat advertising survey.
@@ 704-714 (lines=11) @@
701
     *
702
     * @return bool
703
     */
704
    public static function checkRobotAdbeat()
705
    {
706
        if (stripos(self::$userAgentString, "adbeat.com") !== false)
707
        {
708
            self::$scriptedAgent->setName(ScriptedAgent::ADBEAT);
709
            self::$scriptedAgent->setType(ScriptedAgent::ADVERTISING);
710
            self::$scriptedAgent->setInfoURL("https://www.adbeat.com/operation_policy");
711
            return true;
712
        }
713
        return false;
714
    }
715
716
    /**
717
     * Determine if the agent is the SocialRankIO crawler.
@@ 721-731 (lines=11) @@
718
     *
719
     * @return bool
720
     */
721
    public static function checkRobotSocialrank()
722
    {
723
        if (stripos(self::$userAgentString, "SocialRankIOBot") !== false)
724
        {
725
            self::$scriptedAgent->setName(ScriptedAgent::SOCIALRANK);
726
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
727
            self::$scriptedAgent->setInfoURL("http://socialrank.io/about");
728
            return true;
729
        }
730
        return false;
731
    }
732
733
    /**
734
     * Determine if the agent is the Gluten Free crawler.
@@ 738-748 (lines=11) @@
735
     *
736
     * @return bool
737
     */
738
    public static function checkRobotGlutenFree()
739
    {
740
        if (stripos(self::$userAgentString, "Gluten Free Crawler/") !== false)
741
        {
742
            self::$scriptedAgent->setName(ScriptedAgent::GLUTENFREE);
743
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
744
            self::$scriptedAgent->setInfoURL("http://glutenfreepleasure.com/");
745
            return true;
746
        }
747
        return false;
748
    }
749
750
    /**
751
     * Determine if the agent is the Proximic spider.
@@ 755-765 (lines=11) @@
752
     *
753
     * @return bool
754
     */
755
    public static function checkRobotProximic()
756
    {
757
        if (stripos(self::$userAgentString, "proximic;") !== false)
758
        {
759
            self::$scriptedAgent->setName(ScriptedAgent::PROXIMIC);
760
            self::$scriptedAgent->setType(ScriptedAgent::SPIDER);
761
            self::$scriptedAgent->setInfoURL("http://www.proximic.com/info/spider.php");
762
            return true;
763
        }
764
        return false;
765
    }
766
767
    /**
768
     * Determine if the agent is the Ubermetrics survey.
@@ 772-782 (lines=11) @@
769
     *
770
     * @return bool
771
     */
772
    public static function checkRobotUbermetrics()
773
    {
774
        if (stripos(self::$userAgentString, "@ubermetrics-technologies.com") !== false)
775
        {
776
            self::$scriptedAgent->setName(ScriptedAgent::UBERMETRICS);
777
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
778
            self::$scriptedAgent->setInfoURL("https://www.ubermetrics-technologies.com/");
779
            return true;
780
        }
781
        return false;
782
    }
783
784
    /**
785
     * Determine if the agent is the Verisign ips-agent.
@@ 789-799 (lines=11) @@
786
     *
787
     * @return bool
788
     */
789
    public static function checkRobotVerisign()
790
    {
791
        if (stripos(self::$userAgentString, "ips-agent") !== false)
792
        {
793
            self::$scriptedAgent->setName(ScriptedAgent::VERISIGN);
794
            self::$scriptedAgent->setType(ScriptedAgent::SURVEY);
795
            self::$scriptedAgent->setInfoURL("http://www.spambotsecurity.com/forum/viewtopic.php?f=7&t=1453");
796
            return true;
797
        }
798
        return false;
799
    }
800
}