MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / add_credential

Method add_credential

network_intelligence.py:312–358  ·  view source on GitHub ↗

Add a new credential finding

(self, host: str, service: str, username: str, password: str,
                      protocol: str = "unknown", details: Optional[Dict] = None)

Source from the content-addressed store, hash-verified

310 return None
311
312 def add_credential(self, host: str, service: str, username: str, password: str,
313 protocol: str = "unknown", details: Optional[Dict] = None) -> Optional[str]:
314 """Add a new credential finding"""
315 try:
316 network_id = self.get_current_network_id()
317 if not network_id:
318 self.logger.error("No network ID available for credential")
319 return None
320
321 # Create credential ID
322 cred_hash = hashlib.md5(f"{host}:{service}:{username}:{password}".encode()).hexdigest()[:12]
323 cred_id = f"cred_{cred_hash}"
324
325 # Create credential data
326 cred_data = {
327 'id': cred_id,
328 'host': host,
329 'service': service,
330 'username': username,
331 'password': password,
332 'protocol': protocol,
333 'details': details or {},
334 'discovered': datetime.now().isoformat(),
335 'network_id': network_id,
336 'status': 'active',
337 'confirmation_count': 1,
338 'last_confirmed': datetime.now().isoformat()
339 }
340
341 # Add to active credentials
342 if network_id not in self.active_credentials:
343 self.active_credentials[network_id] = {}
344
345 self.active_credentials[network_id][cred_id] = cred_data
346
347 # Update network profile
348 self.update_network_profile(network_id)
349
350 # Save data
351 self.save_intelligence_data()
352
353 self.logger.info(f"Added credential: {cred_id} on network {network_id}")
354 return cred_id
355
356 except Exception as e:
357 self.logger.error(f"Error adding credential: {e}")
358 return None
359
360 def confirm_finding(self, finding_id: str, finding_type: str = "auto"):
361 """Confirm an existing finding (vulnerability or credential)"""

Callers 1

add_credentialFunction · 0.80

Calls 7

errorMethod · 0.80
hexdigestMethod · 0.80
infoMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected