-
Notifications
You must be signed in to change notification settings - Fork 89
/
bros
executable file
·188 lines (166 loc) · 5.21 KB
/
bros
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
#!/usr/bin/env node
var argv = require('yargs').argv,
log = require('cli-color'),
db = require('./db/db'),
os = require('os'),
menu = require('./modules/menu'),
secondaryMenu = require("./modules/secondaryMenu"),
check = require('./modules/inputChecks'),
simpleWeb = require('./modules/webserver/simple.js'),
simpleFtp = require('./modules/webserver/simpleFtp.js'),
interfaces = require('./modules/interfaces'),
settings = require('./modules/settings'),
child_process = require('child_process'),
utilities = require('./modules/utilities'),
log = require('./modules/log.js'),
enigma = require('./modules/enigma'),
initialEntry = true,
initialData = "",
sshd = require('./modules/sshd.js');
var firstArgument = argv._[0];
var secondArgument = argv._[1];
var thirdArgument = argv._[2];
var fourthArgument = argv._[3];
function getIt(){
if (initialEntry){
var chunk = process.stdin.read()
// _readableState:
initialEntry = false;
}
if (chunk){
initialData = chunk;
}
}
function getFirstArgValue(arg) {
switch (arg) {
case 1:
return secondaryMenu.infoGathering;
break;
case 2:
return secondaryMenu.linux;
break;
case 3:
return secondaryMenu.windows;
break;
case 4:
return secondaryMenu.webAttacks;
case 5:
return secondaryMenu.misc;
case 6:
return secondaryMenu.aux;
}
}
function parseArgs() {
var oldSecondary;
if (firstArgument >= 1 && firstArgument <= 6) {
secondaryMenu = getFirstArgValue(firstArgument);
if (!secondArgument) {
secondaryMenu();
} else if (!thirdArgument) {
secondaryMenu(secondArgument);
} else {
secondaryMenu(secondArgument, thirdArgument);
}
} else if (firstArgument > 10) {
// If input is entered as "bros 111" split up the input and handle them individually
var splitInput = firstArgument.toString(10).split("").map(function(t) {
return parseInt(t)
})
var inputLength = splitInput.length;
secondaryMenu = getFirstArgValue(splitInput[0]);
switch (inputLength) {
case 2:
setTimeout(function(){
secondaryMenu(splitInput[1]);
},15)
break;
case 3:
setTimeout(function(){
secondaryMenu(splitInput[1], splitInput[2])
},15)
break;
case 4:
var a = new String(splitInput[2]);
var b = new String(splitInput[3]);
var c = a+b
secondaryMenu(splitInput[1], parseInt(c))
break;
}
} else if (typeof(firstArgument) === "string") {
firstArgument = firstArgument.toUpperCase();
try {
oldSecondary = secondArgument;
secondArgument = secondArgument.toUpperCase();
} catch(err){
}
// If input is bros http, start a webserver using expressjs, pass all args
// to the simple web server module
if (firstArgument === "HTTP") {
simpleWeb.http(argv);
} else if (firstArgument === "HTTPS") {
simpleWeb.https(argv);
} else if (firstArgument === "FTP"){
simpleFtp.ftp(argv);
} else if (firstArgument === "FTPS"){
console.log("Sorry, FTPs support is planned but currently not available")
//simpleFtp.ftps(argv);
} else if (firstArgument === "SSHD"){
sshd.logger(argv);
}
else if (firstArgument === "UPDATE"){
utilities.update();
} else if (firstArgument === "ENCODE" || firstArgument === "DECODE" || firstArgument === "ENC" || firstArgument === "DEC"){
process.stdin.setEncoding('utf8');
process.stdin.once('readable', function () {
getIt();
});
utilities.delay(10, function(){
if (initialData){
if(argv._.length === 2){
enigma(argv._,initialData);
}
} else {
if (secondArgument && !thirdArgument){
utilities.encoder(oldSecondary);
} else if (thirdArgument){
enigma(argv._);
} else {
utilities.encoder();
}
}
})
} else if (firstArgument+" "+secondArgument === "SET LHOST" && !thirdArgument){
interfaces.setlhost();
} else if (firstArgument != "CONFIG") {
if (secondArgument && thirdArgument) {
check.allInputChecks(firstArgument + " " + secondArgument + " " + thirdArgument, console.log, menu.mainMenu)
} else if (firstArgument === "HELP") {
check.allInputChecks(firstArgument, menu.mainMenu, menu.mainMenu);
} else if (firstArgument === "CLEAN") {
var currentOS = os.type();
var cmd = "rm";
var dir = settings.dbPath;
if (currentOS.match("Windows")){
cmd = "del";
} else {
}
child_process.execFile(cmd, [dir], function(error, stdout, stderr){
});
console.log("The Brosec database located at %s has been wiped.", settings.dbPath)
}
else {
check.allInputChecks(firstArgument, console.log, console.log)
}
} else {
console.log(log.yellow("\n[*] Sorry, that isn't valid input from the command line"))
menu.mainMenu();
}
} else {
menu.mainMenu();
}
}
if (!firstArgument) {
menu.mainMenu();
} else {
parseArgs();
}