-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
140 lines (130 loc) · 5.33 KB
/
cli.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
#!/usr/bin/env node
"use strict";
var Promise = require("bluebird"),
inquirer = require("inquirer"),
chalk = require("chalk"),
request = Promise.promisify(require("request")),
_ = require('underscore'),
getChallengeEmail = require("./lib/purpleHack").getChallengeEmail,
scout = ' `:oo+oo+. \n ' +
' :s/` .oo` \n ' +
' oo` :y` \n ' +
' oo s/ \n ' +
' `..-.:h` s/ \n ' +
' `-/+++/:::oy` .h. \n ' +
' `./+++:.`.` .h/ o+ \n ' +
' ./oo/-`` o/ sh/` :y` \n ' +
' `/o+:++++:-` o+ -h/s:` :h/` \n ' +
'`s/` `.-:++++y. `h-`:o+:/s+-/s: \n ' +
'/s `.-+++-` /s `:ho. +o \n ' +
'-y:` `.ss/` .d``/s- `. s/ \n ' +
' ./s+/:--..````...-h.:o/`h/s/` `s/ s+ \n ' +
' -+o-.--::/oyo+//:+s/ `:ohy- +o :y` \n ' +
'/s- :s:` `s/ `+s. :y` `y- \n ' +
'h- `+s. -y /s-/s. /y` \n ' +
's+ `oo` -h. so--- `y- \n ' +
'.h` `oo` /ys: so-/h. /s` \n ' +
' y: +o` .-::/:-.y/.s/.`y/::+s` `ys+:. \n ' +
' o+ +d/ :y/-..-:+h` `:/oh- `y: .h-:o+` \n ' +
' /s`/soo .h` s+ `-` -y. /y` +s \n ' +
' `yoo`-h` `h: .d` `+s `s/ `h. \n ' +
' .- o+ :ho -y:/:----://+++`s+ -y`.h. \n ' +
' `o++sos /y`.-::::-.`` `y: `.yos: \n ' +
' `` /y +s /so+//:..` -y--+o+/h: \n ' +
' /y s/ `-so..-:+o+:.:ysd. -y. \n ' +
' /s `hs. /s` `-:/--h -y- \n ' +
' +o -y:s+.` -h. -h .y/ \n ' +
' o+ .h` -+o++o- s+`+++:.s+`\n ' +
' s/ s/ :hs+ `/s/so\n ' +
' y: /y .:. `:/.\n ' +
' y: .y: \n ' +
' -ooooo. \n\n';
var letsHack = {
question: chalk.green("Lets hack!"),
answers: [new inquirer.Separator(),
'simple mode',
'hack mode',
'l33t mode (will send email to PurpleScout challenge mail)'
]
};
inquirer.prompt([
{
type: "list",
name: "hackMode",
message: chalk.cyan(scout) + letsHack.question,
choices: letsHack.answers,
filter: function( val ) {
return letsHack.answers.indexOf(val)-1;
}
}
], function(listSelection){
global.hackMode = listSelection.hackMode;
getChallengeEmail().then(function(purpleEmail){
console.log('Ooh yeay, got ' + chalk.green(purpleEmail));
if (listSelection.hackMode > 1) {
inquirer.prompt([{
type: "input",
name: "name",
message: 'Whats your name?'
},{
type: "input",
name: "resume",
message: 'Where is your resume located?'
},{
type: "input",
name: "user",
message: 'Email (gmail only supported)',
validate: function(input) {
if (input.indexOf('@gmail.com') < 0) return 'gmail.com accounts only supported';
return true;
}
},{
type: "password",
name: "password",
message: 'Password'
}], function(userInfo) {
var nodemailer = require('nodemailer'),
transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: userInfo.user,
pass: userInfo.password
}
});
var messageString = 'Name: ' + userInfo.name + '\nCode: github.com/reimertz/purplehack' + '\nResume: ' + userInfo.resume;
inquirer.prompt([{
type: "list",
name: "sendEmail",
message: 'Do you want to send\n\n' + messageString + '\n\n to ' + purpleEmail + ' from ' + userInfo.user + '?',
choices: [new inquirer.Separator(),
'Yes',
'No'
],
filter: function( val ) {
return letsHack.answers.indexOf(val)-1;
}
}], function(answer) {
if(!!answer.sendEmail){
transporter.sendMail({
from: userInfo.user,
to: purpleEmail,
subject: 'challenge answer sent with challenge(Say whaaaaat?)',
text: messageString
}, function(error, info){
if(error){
console.log(error);
} else {
console.log('Message sent!');
}
process.exit();
});
} else {
console.log(chalk.red('Aborted'));
process.exit();
}
}
)
})
}
})
});