-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
165 lines (155 loc) · 4.25 KB
/
index.js
File metadata and controls
165 lines (155 loc) · 4.25 KB
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
#! /usr/bin/env node
const path = require("path");
const { exec } = require("child_process");
const shellExec = require("shell-exec");
const fs = require("fs");
const spinner = require("ora")();
const credentials = path.join() + "/credentials/";
const ostype = require("check-os");
const clear = require("clear");
const cli = require("commander");
const chalk = require("chalk");
const figlet = require("figlet");
const Table = require("console.table");
const hackwifi = new cli.Command();
clear();
helper();
console.log(
chalk.magentaBright(figlet.textSync("hackwifi", { horizontalLayout: "full" }))
);
if (!ostype.isWindows) {
shellExec("sudo grep psk= /etc/NetworkManager/system-connections/*")
.then((res) => {
const all_profiles = res.stdout.split("\n");
const hackedPasswords = [];
let result;
for (let profile of all_profiles) {
result = profile.replace("/etc/NetworkManager/system-connections/", "");
const name = result.split(":psk=")[0];
const password = result.split(":psk=")[1];
hackedPasswords.push({
name,
password,
});
}
console.log(chalk.green(Table.getTable(hackedPasswords)));
process.exit(0);
})
.catch((err) => {
process.exit(1);
});
}
if (!fs.existsSync(credentials) && ostype.isWindows) {
fs.mkdirSync(credentials);
}
fs.hackwifi = function () {
return new Promise(function (resolve, reject) {
if (ostype.isWindows) {
spinner.start("be patient");
exec("netsh wlan show profiles > wlan.txt", (err, stdout, stderr) => {
if (err) {
if (err) reject(err);
} else {
const wlan = fs.readFileSync("wlan.txt");
const formatted = wlan
.toString()
.split("All User Profile :")
.slice(1, -1);
resolve(formatted);
}
});
}
});
};
fs.readdirAsync = function (dirname) {
return new Promise(function (resolve, reject) {
fs.readdir(dirname, function (err, filenames) {
if (err) reject(err);
else resolve(filenames);
});
});
};
fs.readFileAsync = function (filename, enc) {
return new Promise(function (resolve, reject) {
fs.readFile(filename, enc, function (err, data) {
if (err) reject(err);
else resolve(data);
});
});
};
function getFile(filename) {
return fs.readFileAsync(credentials + filename, "utf8");
}
function fetchPasswords() {
setTimeout(() => {
fs.readdirAsync(credentials)
.then(function (filenames) {
return Promise.all(filenames.map(getFile));
})
.then(function (files) {
const hackedPasswords = [];
files.forEach(function (file) {
if (!file.includes("Open") && file !== undefined) {
let name = file.split("SSID name :")[1];
if (name !== undefined) {
name = name.split("Network type")[0];
}
const pass = file
.toString()
.split("Cost settings")[0]
.split("Key Content :")[1];
if (pass !== undefined) {
hackedPasswords.push({
name: name.trim(),
password: pass.trim(),
});
}
}
});
spinner.succeed("done");
console.log(chalk.magenta(Table.getTable(hackedPasswords)));
});
}, 2000);
}
fs.hackwifi()
.then((profiles) => {
profiles.forEach((profile) => {
exec(
`netsh wlan show profiles "${profile.trim()}" key=clear > ${credentials}/"${profile.trim()}"`
);
});
})
.then(() => {
fetchPasswords();
});
function helper() {
console.log();
hackwifi
.name("hackwifi")
.description(
`
**hackwifi** is a tool made for hacking(revealing) wifi passwords
`
)
.version("1.0.5")
.parse(process.argv);
hackwifi.on("--help", function () {
console.log("Examples:");
console.log(" $ hackwifi");
console.log(" $ hackwifi --help");
});
}
setTimeout(() => {
if (
fs.exists(credentials, () => {
exec("rmdir /Q /S credentials && del wlan.txt", (err, stderr, stdout) => {
if (stdout) {
spinner.succeed("done");
} else {
process.exit(1);
}
});
})
) {
}
}, 5000);