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

Function get_credentials_api

webapp_modern.py:13141–13186  ·  view source on GitHub ↗

Get credential data with network intelligence if available

()

Source from the content-addressed store, hash-verified

13139 return jsonify(loot)
13140 except Exception as e:
13141 logger.error(f"Error getting loot: {e}")
13142 return jsonify({'error': str(e)}), 500
13143
13144
13145@app.route('/api/report/export')
13146def export_report():
13147 """Generate and download a self-contained HTML scan report"""
13148 try:
13149 from datetime import datetime as _dt
13150 import html as _html
13151
13152 # Gather data
13153 hosts = shared_data.db.get_all_hosts()
13154 all_creds = web_utils.get_all_credentials()
13155 flat_creds = []
13156 for svc, entries in all_creds.items():
13157 for e in entries:
13158 flat_creds.append({**e, 'service': svc})
13159
13160 # Attack logs (last 30 days)
13161 attack_log_dir = os.path.join(shared_data.logsdir, 'attacks')
13162 all_attacks = []
13163 if os.path.exists(attack_log_dir):
13164 from datetime import timedelta
13165 cutoff = _dt.now() - timedelta(days=30)
13166 for lf in sorted(os.listdir(attack_log_dir), reverse=True)[:30]:
13167 if not lf.startswith('attacks_') or not lf.endswith('.json'):
13168 continue
13169 try:
13170 file_date = _dt.strptime(lf.replace('attacks_','').replace('.json',''), '%Y-%m-%d')
13171 if file_date < cutoff:
13172 continue
13173 with open(os.path.join(attack_log_dir, lf), 'r', encoding='utf-8') as f:
13174 all_attacks.extend(json.load(f))
13175 except Exception:
13176 continue
13177 all_attacks.sort(key=lambda x: x.get('timestamp',''), reverse=True)
13178
13179 # Stats
13180 alive_hosts = [h for h in hosts if h.get('status') == 'alive']
13181 total_ports = sum(len([p for p in (h.get('ports','') or '').split(',') if p.strip()]) for h in hosts)
13182 success_attacks = [a for a in all_attacks if a.get('status') == 'success']
13183
13184 generated_at = _dt.now().strftime('%Y-%m-%d %H:%M:%S')
13185 network_ssid = getattr(shared_data, 'active_network_ssid', None) or 'Unknown'
13186
13187 def e(s): return _html.escape(str(s or ''))
13188
13189 # Build host rows

Callers

nothing calls this directly

Calls 5

appendMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected