This repository was archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
3135 lines (2987 loc) · 153 KB
/
index.js
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
const Alexa = require('alexa-sdk');
const makePlainText = Alexa.utils.TextUtils.makePlainText;
const makeRichText = Alexa.utils.TextUtils.makeRichText;
const makeImage = Alexa.utils.ImageUtils.makeImage;
const cheerio = require('cheerio');
const request = require('request');
const rp = require('request-promise');
const Bluebird = require('bluebird');
const _ = require('lodash')
const alexaLists = require('@blazingedge/alexa-lists');
var states = {
SEARCHMODE: '_SEARCHMODE'
};
var appName = "Bug Browser";
var numberOfResults = 5;
var welcomeMessage = "Welcome to " + appName + ". You can ask me to check if you have been hacked, for a cybersecurity news flash briefing, a list of recent breaches, security tips, lessons about hacking, active HackerOne bounties, and active BugCrowd bounties. You can also learn about more commands by saying help. What will it be?";
var welcomeReprompt = "You can ask me for the latest hacking news, a list of recent hacks, a security check, security recommendations, lessons about hacking, active HackerOne bounties, active BugCrowd programs, or ask for help. What will it be?";
var overview = "Bug bounty platforms such as BugCrowd and HackerOne connect organizations to a global crowd of trusted security researchers. Bug Bounty programs allow the developers to discover and resolve bugs before the general public is aware of them, preventing incidents of widespread abuse.";
var HelpMessage = "Here are some things you can say: Give me a flash briefing on hacks. Teach me how to hack. Tell me what bug bounty platforms are. Tell me about the VRT. Tell me some active BugCrowd programs. Tell me some active HackerOne bounties. What would you like to do?";
var moreInformation = "See your Alexa app for more information.";
var tryAgainMessage = "Please try again.";
var moreInfoProgram = " You can tell me a program number for more information. For example, open number one. What program would you like more information on?";
var getMoreInfoRepromptMessage = "what vulnerability would you like to hear more about?";
var hearMoreMessage = " Would you like to hear about another active bounty? You can tell me a program number for more information. For example, open number two.";
var noProgramErrorMessage = "There is no program with this number.";
var noLessonErrorMessage = "There is no lesson with this number. ";
var hearMoreLessons = "Which lesson would you like me to play?"
var generalReprompt = " What else would you like to know?";
var getMoreInfoMessage = "OK, " + getMoreInfoRepromptMessage;
var generalError = "I had trouble with the requested response. You just found a bug in Bug Browser! See the irony? Please submit a report on GitHub. If you're the developer, time to check CloudWatch! In the meantime, you can try another Bug Browser feature. What would you like me to do?";
var videoError = "Playing videos is not supported on this device. ";
var getMoreInfoRepromptMessage = " If you want to hear another category, you can ask me about the VRT again. What would you like to do?";
var goodbyeMessage = "OK, Bug Browser shutting down.";
var newsIntroMessage = "These are the " + numberOfResults + " most recent security vulnerability headlines, you can read more on your Alexa app.";
var newsSources = "wired,the-verge,techcrunch,ars-technica,techradar";
var newsQueries = ["security hacks", "security vulnerability", "bug bounty", "security researcher", "cybersecurity"]
var hintOptions = ["tell me hacking news",
"give me a flash briefing on hacks",
"tell me some facts about BugCrowd",
"introduce me to BugCrowd",
"what companies are looking for security researchers?",
"tell me the top active programs",
"tell me about the Vulnerability Rating Taxonomy",
"tell me about the VRT",
"introduce me to BugCrowd with a video",
"play BugCrowd overview video",
"how do you find bounties?",
"have I been hacked?",
"I have been hacked!",
"give me security tips",
"tell me about bug null pointer exception",
"tell me about recent breaches",
"tell me about recent hacks",
"surprise me"
];
var helpMessages = [
{
message:"Tell me active BugCrowd programs",
description:"Get bounties from BugCrowd",
intent:"getBugCrowdIntent"
},
{
message:"Tell me active HackerOne programs",
description:"Get bounties from HackerOne",
intent:"getHackerOneIntent"
},
{
message:"What are the priorities of security vulnerabilities?",
description:"Learn about the BugCrowd VRT",
intent:"getVRTIntent"
},
{
message:"Tell me the latest news on vulnerabilities",
description:"Get news about security vulnerabilities",
intent:"getNewsIntent"
},
{
message:"Tell me about bug bounty platforms",
description:"Learn about bug bounties and bug bounty platforms",
intent:"getOverview"
},
{
message:"Have I been hacked?",
description:"See if your email and other data has been leaked",
intent:"checkForHacks"
},
{
message:"Tell me about recent breaches",
description:"Learn about recent security breaches",
intent:"generalHacks"
},
{
message:"I have been hacked!",
description:"Get security tips",
intent:"learnSecurityMeasures"
},
{
message:"List HTTP Status Codes",
description:"Understand errors displayed by websites and servers",
intent:"listStatusCodesIntent"
}
];
var lessons = [
{
name: "registerBugCrowd",
slots: [],
hints: [
"how do you register for BugCrowd",
"how do you use BugCrowd",
"Teach me how to use BugCrowd"
],
description: "Learn the basics of using BugCrowd."
},
{
name: "getLessonOne",
slots: [],
hints: [
"what tools do I need to get started hacking",
"introduce me to hacking",
"play the introduction to hacking video"
],
description: "Get the tools you need to start hacking."
},
{
name: "getLessonTwo",
slots: [],
hints: [
"teach me Same-Origin Policy",
"teach me MIME sniffing",
"teach me HTML parsing",
"teach me cookie security",
"teach me HTTP basics",
"teach me CSRF",
"teach me Cross-Site Request Forgery",
"play the lesson The Web In Depth",
"play the video The Web In Depth"
],
description: "Learn about the web in depth including HTTP basics."
},
{
name: "getLessonThree",
slots: [],
hints: [
"teach me about authorization bypasses",
"teach me about forced browsing",
"teach me about XSS",
"teach me about types of XSS",
"teach me about Cross-Site Scripting",
"play the lesson XSS and Authorization",
"play the video XSS and Authorization"
],
description: "Learn about Cross-Site Scripting and Authorization."
},
{
name: "getLessonFour",
slots: [],
hints: [
"teach me about command injection",
"teach me about directory traversal",
"teach me about SQL Injection",
"teach me about SQLi",
"play the lesson SQL Injection and Friends",
"play the video SQL Injection and Friends"
],
description: "Learn about SQL Injection and Friends."
},
{
name: "getLessonFive",
slots: [],
hints: [
"play the lesson session fixation",
"play the video session fixation",
"teach me about session fixation"
],
description: "Learn about Session Fixation."
},
{
name: "getLessonSix",
slots: [],
hints: [
"play the lesson clickjacking",
"play the video clickjacking",
"teach me about clickjacking"
],
description: "Learn about Clickjacking."
},
{
name: "getLessonSeven",
slots: [],
hints: [
"play the lesson file inclusion bugs",
"teach me about file inclusion",
"teach me about RFI",
"teach me about LFI",
"teach me about remote file inclusion",
"teach me about local file inclusion",
"play the video file inclusion bugs"
],
description: "Learn about File Inclusion Bugs."
},
{
name: "getLessonEight",
slots: [],
hints: [
"play the lesson file upload bugs",
"play the video file upload bugs",
"teach me about file upload bugs",
"teach me about hiding data in PNG files",
"teach me about MIME type attacks",
"teach me about filename-based attacks",
"teach me about how multipart POSTs work"
],
description: "Learn about File Upload Bugs."
},
{
name: "getLessonNine",
slots: [],
hints: [
"play the lesson null termination bugs",
"play the video null termination bugs",
"teach me about null terminators"
],
description: "Learn about Null Termination Bugs."
},
{
name: "getLessonTen",
slots: [],
hints: [
"play the lesson unchecked redirects",
"play the video unchecked redirects",
"teach me about unchecked redirects"
],
description: "Learn about Unchecked Redirects."
},
{
name: "getLessonEleven",
slots: [],
hints: [
"teach me about methods of storing passwords",
"teach me about bare hash",
"teach me about Scrypt",
"teach me about Bcrypt",
"play the lesson password storage",
"play the video password storage"
],
description: "Learn about Secure Password Storage."
},
{
name: "getLessonTwelve",
slots: [],
hints: [
"play the lesson crypto crash course",
"play the video crypto crash course",
"teach me about Hash-based MAC",
"teach me about HMAC",
"teach me about Message Authentication Codes",
"teach me about MACs",
"teach me about hashes",
"teach me about Cipher Block Chaining",
"teach me about Electronic Codebook",
"teach me about CBC",
"teach me about ECB",
"teach me about block cipher modes",
"teach me about types of ciphers",
"teach me about one-time pads",
"teach me about XOR and its importance for cryptography"
],
description: "Get an overview of cryptography."
},
{
name: "getLessonThirteen",
slots: [],
hints: [
"teach me about padding oracles",
"teach me about hash length extension",
"teach me about ECB decryption",
"teach me about ECB block reordering",
"teach me about stream cipher key reuse",
"play the lesson crypto attacks",
"play the video crypto attacks"
],
description: "Learn about cryptography attacks."
},
{
name: "getLessonFourteen",
slots: [],
hints: [
"finish up the crypto video",
"teach me about padbuster",
"teach me about ECB mode",
"play the video crypto wrap-up",
"teach me about crypto wrap-up"
],
description: "Learn more about cryptography."
}
];
var bugCrowdPage = 1;
var bugCrowdTotal = 2;
var hackerOneMax = 25;
var hackerOneTotal = 100;
var currentAnswer = 0;
var answersAvailable = 0;
var output = "";
var alexa;
function extractHostname(url) {
var hostname;
//find & remove protocol (http, ftp, etc.) and get hostname
if (url.indexOf("://") > -1) {
hostname = url.split('/')[2];
}
else {
hostname = url.split('/')[0];
}
//find & remove port number
hostname = hostname.split(':')[0];
//find & remove "?"
hostname = hostname.split('?')[0];
return hostname;
}
function extractRootDomain(url) {
var domain = extractHostname(url);
splitArr = domain.split('.'),
arrLen = splitArr.length;
if (arrLen > 2) {
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
if (splitArr[arrLen - 1].length == 2 && splitArr[arrLen - 1].length == 2) {
domain = splitArr[arrLen - 3] + '.' + domain;
}
}
return domain;
}
var newSessionHandlers = {
'LaunchRequest': function () {
this.handler.state = states.SEARCHMODE;
output = welcomeMessage;
this.attributes.lastSpeech = welcomeMessage;
if (this.event.context.System.device.supportedInterfaces.Display) {
var hint = hintOptions[Math.floor(Math.random() * (hintOptions.length))];
var content = {
"title": "Bug Browser",
"hint": hint,
"bodyTemplateTitle": "Bug Browser",
"speechText" : output,
"speechTextReprompt" : welcomeReprompt,
"templateToken": "launchRequestTemplate",
"bodyTemplateContent": "Welcome to Bug Browser",
"cardContent": null,
"backgroundImage": 'https://s3.amazonaws.com/bugbrowser/images/WebIconv2Dark.png',
"askOrTell" : ":ask",
"sessionAttributes": {}
};
renderTemplate.call(this, content);
} else {
output = welcomeMessage;
this.emit(':ask', output, welcomeReprompt);
}
},
'getOverview': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getOverview');
},
'getOverviewVideo': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getOverviewVideo');
},
'getEasterEgg': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getEasterEgg');
},
'registerBugCrowd': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('registerBugCrowd');
},
'getLessonOne': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonOne');
},
'getLessonTwo': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonTwo');
},
'getLessonThree': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonThree');
},
'getLessonFour': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonFour');
},
'getLessonFive': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonFive');
},
'getLessonSix': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonSix');
},
'getLessonSeven': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonSeven');
},
'getLessonEight': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonEight');
},
'getLessonNine': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonNine');
},
'getLessonTen': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonTen');
},
'getLessonEleven': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonEleven');
},
'getLessonTwelve': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonTwelve');
},
'getLessonThirteen': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonThirteen');
},
'getLessonFourteen': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getLessonFourteen');
},
'getTeachVideos': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getTeachVideos');
},
'getNewsIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getNewsIntent');
},
'getBugCrowdIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getBugCrowdIntent');
},
'getHackerOneIntent': function() {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getHackerOneIntent');
},
'listIntent': function() {
this.handler.state = states.SEARCHMODE;
this.emitWithState('listIntent');
},
'getProgramsIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getProgramsIntent');
},
'getMoreInfoBugCrowdIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getMoreInfoBugCrowdIntent');
},
'getMoreInfoHackerOneIntent': function() {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getMoreInfoHackerOneIntent');
},
'getMoreInfo': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getMoreInfo');
},
'getVRTIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getVRTIntent');
},
'listStatusCodesIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('listStatusCodesIntent');
},
'getHelpIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('getHelpIntent');
},
'checkForHacks': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('checkForHacks');
},
'generalHacks': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('generalHacks');
},
'learnSecurityMeasures': function() {
this.handler.state = states.SEARCHMODE;
this.emitWithState('learnSecurityMeasures');
},
'bugSearchIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('bugSearchIntent');
},
'readReportIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('readReportIntent');
},
'ElementSelected': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('ElementSelected');
},
'AMAZON.RepeatIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('AMAZON.RepeatIntent');
},
'AMAZON.NextIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('AMAZON.NextIntent');
},
'AMAZON.PreviousIntent': function () {
this.handler.state = states.SEARCHMODE;
this.emitWithState('AMAZON.PreviousIntent');
},
'AMAZON.YesIntent': function () {
this.emit('getHelpIntent');
},
'AMAZON.NoIntent': function () {
this.emit('getHelpIntent');
},
'AMAZON.HelpIntent': function () {
this.emit('getHelpIntent');
},
'AMAZON.StopIntent': function () {
var self = this;
if (this.event.context.System.device.supportedInterfaces.Display) {
rp({
uri: `http://bugbrowsercache.s3-accelerate.amazonaws.com/hacktivity.json`,
transform: function (body) {
return JSON.parse(body);
}
}).then((data) => {
var count = data.count + 96000;
var content = 'Imagine if the over ' + count + ' security vulnerabilities patched so far on HackerOne and BugCrowd combined had not been resolved.';
var speakContent = 'Imagine if the over <say-as interpret-as="cardinal">' + count + '</say-as> security vulnerabilities patched so far on HackerOne and BugCrowd combined had not been resolved.';
const builder = new Alexa.templateBuilders.BodyTemplate1Builder();
const template = builder.setTitle('Bug Browser')
.setToken('cancelIntentToken')
.setBackButtonBehavior('HIDDEN')
.setBackgroundImage(makeImage('https://s3.amazonaws.com/bugbrowser/images/Security+Vulnerability.png'))
.setTextContent(makeRichText('<font size="3">' + content + '</font>'))
.build();
this.response.speak(speakContent + ' Anyways, Bug Browser is going to sleep for now.').renderTemplate(template);
this.emit(':responseReady');
}).catch(function (err) {
console.log(err);
self.emit(':tell', 'Bug Browser is going to sleep for now.');
});
} else {
rp({
uri: `http://bugbrowsercache.s3-accelerate.amazonaws.com/hacktivity.json`,
transform: function (body) {
return JSON.parse(body);
}
}).then((data) => {
var count = data.count + 96000;
var content = 'Imagine if the over ' + count + ' security vulnerabilities patched so far on HackerOne and BugCrowd combined had not been resolved.';
var speakContent = 'Imagine if the over <say-as interpret-as="cardinal">' + count + '</say-as> security vulnerabilities patched so far on HackerOne and BugCrowd combined had not been resolved.';
this.emit(':tell', speakContent + ' Anyways, Bug Browser is going to sleep for now.');
}).catch(function (err) {
console.log(err);
self.emit(':tell', 'Bug Browser is going to sleep for now.');
});
}
},
'AMAZON.CancelIntent': function () {
// Use this function to clear up and save any data needed between sessions
this.emit('AMAZON.StopIntent');
},
'SessionEndedRequest': function () {
// Use this function to clear up and save any data needed between sessions
this.emit('AMAZON.StopIntent');
},
'Unhandled': function () {
console.log("Second Unhandled event of token " + this.event.request.token + ' from ' + this.attributes.lastAction);
output = HelpMessage;
this.emit(':ask', output, welcomeReprompt);
},
};
var startSearchHandlers = Alexa.CreateStateHandler(states.SEARCHMODE, {
'getOverview': function () {
var cardTitle = "What are Bug Bounties and Bug Bounty Platforms?";
this.attributes.lastAction = "getOverview";
const imageObj = {
smallImageUrl:'https://s3.amazonaws.com/bugbrowser/images/BugBountyPlatforms.png',
largeImageUrl: 'https://s3.amazonaws.com/bugbrowser/images/BugBountyPlatforms.png'
};
output = overview + " What else would you like to know?";
this.attributes.lastSpeech = output;
if (this.event.context.System.device.supportedInterfaces.Display) {
output = overview + " If you would like to learn more about bug bounty platforms you can ask me to play the BugCrowd overview video or ask me to teach you how to use BugCrowd. What would you like me to do?";
const builder = new Alexa.templateBuilders.BodyTemplate1Builder();
const template = builder.setTitle(cardTitle)
.setBackgroundImage(makeImage('https://s3.amazonaws.com/bugbrowser/images/Bug-Window-Dark.png'))
.setTextContent(makePlainText(output))
.build();
this.response.speak(output).renderTemplate(template).cardRenderer(cardTitle, overview, imageObj).listen(HelpMessage);
this.emit(':responseReady');
} else {
this.emit(':askWithCard', output, output, cardTitle, overview, imageObj);
}
},
'getOverviewVideo': function () {
output = overview;
this.attributes.lastAction = "getOverviewVideo";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Overview.mp4';
const metadata = {
'title': 'BugCrowd Overview',
'subtitle': 'Crowdsourced Cybersecurity'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, appName, overview);
}
},
'getEasterEgg': function () {
output = "This Easter Egg is a video that can only be played on the Echo Show or Echo Spot. What else would you like to do?";
this.attributes.lastAction = "getEasterEgg";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Bugcrowd+Intro.mp4';
const metadata = {
'title': 'BugCrowd',
'subtitle': 'Crowdsourced Cybersecurity'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', output, appName, output);
}
},
'registerBugCrowd': function () {
this.attributes.lastAction = "registerBugCrowd";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Learn+Bugcrowd+in+10+Minutes.mp4';
const metadata = {
'title': 'How to use BugCrowd',
'subtitle': 'Crowdsourced Cybersecurity'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + HelpMessage, appName, output + HelpMessage);
}
},
'getLessonOne': function () {
const description = 'In this Hacker101 lesson the instructor Cody Brocious will talk about how you can take the things you learn in this class and apply them to real situations. You will learn about the required tools, thinking like a breaker, attacker-defender imbalance, lightweight threat assessment and prioritization, and how to write good bug reports.';
this.attributes.lastAction = "getLessonOne";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Introduction.mp4';
const metadata = {
'title': 'Introduction to Hacking',
'subtitle': 'Lesson 1'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonTwo': function () {
this.attributes.lastAction = "getLessonTwo";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+The+Web+In+Depth.mp4';
const metadata = {
'title': 'The Web In Depth',
'subtitle': 'Lesson 2'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonThree': function () {
this.attributes.lastAction = "getLessonThree";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+XSS+and+Authorization.mp4';
const metadata = {
'title': 'XSS and Authorization',
'subtitle': 'Lesson Three'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonFour': function () {
this.attributes.lastAction = "getLessonFour";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+SQL+Injection+and+Friends.mp4';
const metadata = {
'title': 'SQL Injection',
'subtitle': 'Lesson 4'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonFive': function () {
this.attributes.lastAction = "getLessonFive";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Session+Fixation.mp4';
const metadata = {
'title': 'Session Fixation',
'subtitle': 'Lesson 5'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonSix': function () {
this.attributes.lastAction = "getLessonSix";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Clickjacking.mp4';
const metadata = {
'title': 'Clickjacking',
'subtitle': 'Lesson 6'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonSeven': function () {
this.attributes.lastAction = "getLessonSeven";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+File+Inclusion.mp4';
const metadata = {
'title': 'File Inclusion',
'subtitle': 'Lesson 7'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonEight': function () {
this.attributes.lastAction = "getLessonEight";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+File+Upload+Bugs.mp4';
const metadata = {
'title': 'File Upload Bugs',
'subtitle': 'Lesson 8'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonNine': function () {
this.attributes.lastAction = "getLessonNine";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Null+Termination+Bugs.mp4';
const metadata = {
'title': 'Null Termination Bugs',
'subtitle': 'Lesson 9'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonTen': function () {
this.attributes.lastAction = "getLessonTen";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Unchecked+Redirects.mp4';
const metadata = {
'title': 'Unchecked Redirects',
'subtitle': 'Lesson 10'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonEleven': function () {
this.attributes.lastAction = "getLessonEleven";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Secure+Password+Storage.mp4';
const metadata = {
'title': 'Secure Password Storage',
'subtitle': 'Lesson 11'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonTwelve': function () {
this.attributes.lastAction = "getLessonTwelve";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Crypto+Crash+Course.mp4';
const metadata = {
'title': 'Crypto Crash Course',
'subtitle': 'Lesson 12'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonThirteen': function () {
this.attributes.lastAction = "getLessonThirteen";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Crypto+Attacks.mp4';
const metadata = {
'title': 'Crypto Attacks',
'subtitle': 'Lesson 13'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getLessonFourteen': function () {
this.attributes.lastAction = "getLessonFourteen";
if (this.event.context.System.device.supportedInterfaces.Display) {
const videoSource = 'https://s3.amazonaws.com/bugbrowser/video/Hacker101/Hacker101+-+Crypto+Wrap-Up.mp4';
const metadata = {
'title': 'Crypto Wrap-Up',
'subtitle': 'Lesson 14'
};
this.response.playVideo(videoSource, metadata);
this.emit(':responseReady');
} else {
this.emit(':ask', videoError + overview + generalReprompt, HelpMessage);
}
},
'getTeachVideos': function () {
var context = this;
this.attributes.lastAction = "getTeachVideos";
var cardTitle = "Bug Browser Lessons";
if (context.event.context.System.device.supportedInterfaces.Display) {
if(context.event && context.event.request && context.event.request.intent && context.event.request.intent.slots && context.event.request.intent.slots.program && context.event.request.intent.slots.program.value && context.event.request.intent.slots.program.value != null && context.event.request.intent.slots.program.value != "?"){
var desired = context.event.request.intent.slots.program.value - 1;
if(desired < lessons.length){
context.emit(lessons[desired].name)
}
else{
context.emit(':ask', noLessonErrorMessage + hearMoreLessons, hearMoreLessons);
}
}
else{
var content = 'Here are some things Bug Browser can teach:\n';
var speak = 'Here are some things you can say to Bug Browser: ';
const listItemBuilder = new Alexa.templateBuilders.ListItemBuilder();
const listTemplateBuilder = new Alexa.templateBuilders.ListTemplate1Builder();
for (var i = 0; i < lessons.length; i++) {
var value = Math.floor(Math.random() * lessons[i].hints.length);
var raw = lessons[i].hints[value];
var complete = raw.charAt(0).toUpperCase() + raw.substring(1);
speak += "Number " + (i + 1) + ". " + complete + ". \n";
content += (i + 1) + ". Say " + raw + ": " + lessons[i].description + "\n";
listItemBuilder.addItem(null, 'lessonItemToken' + i, makeRichText("<font size='2'>" + lessons[i].description + "</font>"), makeRichText("<font size='1'>" + "Say " + "<i>" + raw + "</i>" + "</font>"));
}
speak += "Select a video or ask me to play lesson number five for example to begin a lesson. What would you like to do?";
const listItems = listItemBuilder.build();
const listTemplate = listTemplateBuilder.setToken('getLessonToken')
.setTitle(cardTitle)
.setListItems(listItems)
.setBackgroundImage(makeImage('https://s3.amazonaws.com/bugbrowser/images/Coding-Monitors.png'))
.build();
context.response.speak(speak).renderTemplate(listTemplate).cardRenderer(cardTitle, content, null).listen(speak);
context.emit(':responseReady');
}
} else {
var content = 'Bug Browser lessons are only available for video-enabled devices at this time.';
context.emit(':askWithCard', content + generalReprompt, HelpMessage);
}
},
'getBugCrowdIntent': function () {
var self = this;
this.attributes.lastAction = "getBugCrowdIntent";
console.log("Finding programs from page " + bugCrowdPage + " of " + bugCrowdTotal)
rp({
uri: `https://bugcrowd.com/programs/reward?page=` + bugCrowdPage,
transform: function (body) {
return cheerio.load(body);
}
}).then(($) => {
var programs = [];
var images = [];
var bugCrowdPagination = [];
$('.bc-pagination__item').each(function(i, elem) {
bugCrowdPagination.push($(this).find('a').attr('href'));
});
$('.bc-panel__title').each(function(i, elem) {
programs.push($(this).text().trim());
});
$('.bc-program-card__header').each(function(i, elem) {
images.push($(this).find('img').attr('src'));
});
var map = new Map();
map.set(0, programs);
map.set(1, images)
map.set(2, bugCrowdPagination)
return map;
}).then((map) => {
var programs = map.get(0);
var images = map.get(1);
var bugCrowdPagination = map.get(2);
var bugCrowdTempMax = bugCrowdPagination[bugCrowdPagination.length - 1];
if(bugCrowdTempMax != null){
bugCrowdTempMax = parseInt(bugCrowdTempMax.replace(/[^0-9]/g, ''), 10);
}
if(bugCrowdTempMax != null && bugCrowdTempMax > 2){
bugCrowdTotal = bugCrowdTempMax;
}
var cardTitle = "BugCrowd Programs";
var output = "";
var read = "";
var retrieveError = "I was unable to retrieve any active programs. Please try again later.";
if (programs.length > 0) {
read = "Here are the active programs at BugCrowd from page " + bugCrowdPage + " of " + bugCrowdTotal + ": ";
for (var counter = 0; counter < programs.length; counter++) {
output += (counter + 1) + ". " + programs[counter] + "\n\n";
read += "Number " + (counter + 1) + ": " + programs[counter] + "\n\n";
}
read += moreInfoProgram;
this.attributes.lastSpeech = read;
if (this.event.context.System.device.supportedInterfaces.Display) {
const listItemBuilder = new Alexa.templateBuilders.ListItemBuilder();
const listTemplateBuilder = new Alexa.templateBuilders.ListTemplate2Builder();
for (i = 0; i < programs.length; i++) {
listItemBuilder.addItem(makeImage(images[i], 400, 400), 'programToken' + i, makePlainText(programs[i]))
}
const listItems = listItemBuilder.build();
const listTemplate = listTemplateBuilder.setToken('listToken')
.setTitle(cardTitle)
.setListItems(listItems)
.setBackgroundImage(makeImage('http://bugbrowser.s3-accelerate.amazonaws.com/images/Search.png'))
.build();
this.response.speak(read).renderTemplate(listTemplate).cardRenderer(cardTitle, output, null).listen(moreInfoProgram);
this.emit(':responseReady');
} else {
this.emit(':askWithCard', read, read, cardTitle, output);
}
} else {