@hashangit/breachhound
Version:
An efficient OSINT tool for uncovering digital footprints associated with a username. TypeScript port of GoSearch.
64 lines • 2.67 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkBreachDirectory = checkBreachDirectory;
const axios_1 = __importDefault(require("axios"));
const utils_1 = require("../utils");
const weakpass_1 = require("./weakpass"); // Import cracking function
async function checkBreachDirectory(targetUsername, apiKey) {
if (!apiKey) {
return { service: 'BreachDirectory', status: 'skipped', found: false };
}
// Construct the correct API URL for BreachDirectory via RapidAPI
const url = `https://breachdirectory.p.rapidapi.com/?func=auto&term=${encodeURIComponent(targetUsername)}`;
try {
const response = await axios_1.default.get(url, {
headers: {
'x-rapidapi-host': 'breachdirectory.p.rapidapi.com',
'x-rapidapi-key': apiKey, // Use the provided API key
'User-Agent': utils_1.DEFAULT_USER_AGENT
},
timeout: 20000, // Allow a slightly longer timeout
});
const found = response.data.found > 0;
let structuredDetails = {
foundCount: response.data.found || 0,
breaches: [] // Initialize an array to hold breach details
};
if (found && response.data.result) {
const breachPromises = response.data.result.map(async (entry) => {
const hashToCrack = entry.hash || entry.sha1; // Prefer hash, fallback to sha1
let crackedPassword = null;
if (hashToCrack) { // Only crack if a hash exists
crackedPassword = await (0, weakpass_1.crackPasswordHash)(hashToCrack);
}
return {
email: entry.email,
password: entry.password, // Original password from breach
crackedPassword: crackedPassword, // Result from Weakpass
source: entry.sources,
hash: entry.hash,
sha1: entry.sha1,
};
});
structuredDetails.breaches = await Promise.all(breachPromises);
}
return {
service: 'BreachDirectory',
status: 'checked',
found: found,
details: structuredDetails,
};
}
catch (error) {
return {
service: 'BreachDirectory',
status: 'error',
found: false,
error: error.message,
};
}
}
//# sourceMappingURL=breachDirectory.js.map