Execute a manual attack on a specific target
()
| 15161 | result = subprocess.run(['ip', 'addr', 'show', _get_wifi_iface()], capture_output=True, text=True, timeout=3) |
| 15162 | if result.returncode == 0: |
| 15163 | ip_match = re.search(r'inet (\d+\.\d+\.\d+\.\d+)', result.stdout) |
| 15164 | wifi_log_data['system_wifi']['ip_address'] = ip_match.group(1) if ip_match else None |
| 15165 | wifi_log_data['system_wifi']['interface_up'] = 'state UP' in result.stdout |
| 15166 | else: |
| 15167 | wifi_log_data['system_wifi']['interface_error'] = f"Exit code: {result.returncode}" |
| 15168 | except Exception as e: |
| 15169 | wifi_log_data['system_wifi']['interface_error'] = str(e) |
| 15170 | |
| 15171 | except Exception as e: |
| 15172 | wifi_log_data['system_wifi']['error'] = str(e) |
| 15173 | |
| 15174 | # === RAGNAR WIFI MANAGER STATUS === |
| 15175 | try: |
| 15176 | if (hasattr(shared_data, 'ragnar_instance') and |
| 15177 | shared_data.ragnar_instance and |
| 15178 | hasattr(shared_data.ragnar_instance, 'wifi_manager')): |
| 15179 | |
| 15180 | wifi_mgr = shared_data.ragnar_instance.wifi_manager |
| 15181 | wifi_log_data['ragnar_wifi_manager'] = { |
| 15182 | 'wifi_connected': getattr(wifi_mgr, 'wifi_connected', False), |
| 15183 | 'ap_mode_active': getattr(wifi_mgr, 'ap_mode_active', False), |
| 15184 | 'cycling_mode': getattr(wifi_mgr, 'cycling_mode', False), |
| 15185 | 'current_ssid': getattr(wifi_mgr, 'current_ssid', None), |
| 15186 | 'connection_attempts': getattr(wifi_mgr, 'connection_attempts', 0), |
| 15187 | 'ap_clients_count': getattr(wifi_mgr, 'ap_clients_count', 0) |
| 15188 | } |
| 15189 | else: |
| 15190 | wifi_log_data['ragnar_wifi_manager']['error'] = "WiFi manager not available" |
| 15191 | |
| 15192 | except Exception as e: |
| 15193 | wifi_log_data['ragnar_wifi_manager']['error'] = str(e) |
| 15194 | |
| 15195 | # === E-PAPER DISPLAY WIFI STATUS === |
| 15196 | try: |
| 15197 | if (hasattr(shared_data, 'ragnar_instance') and |
| 15198 | shared_data.ragnar_instance and |
| 15199 | hasattr(shared_data.ragnar_instance, 'display')): |
| 15200 | |
| 15201 | display = shared_data.ragnar_instance.display |
| 15202 | wifi_log_data['epaper_display'] = { |
| 15203 | 'wifi_status_text': display.get_wifi_status_text(), |
| 15204 | 'is_wifi_connected': display.is_wifi_connected() |
| 15205 | } |
| 15206 | else: |
| 15207 | wifi_log_data['epaper_display']['error'] = "Display not available" |
| 15208 | |
| 15209 | except Exception as e: |
| 15210 | wifi_log_data['epaper_display']['error'] = str(e) |
| 15211 | |
| 15212 | return jsonify(wifi_log_data) |
| 15213 | |
| 15214 | except Exception as e: |
| 15215 | logger.error(f"Error getting WiFi logs: {e}") |
| 15216 | return jsonify({'error': str(e)}), 500 |
| 15217 | |
| 15218 | @app.route('/api/epaper-display') |
| 15219 | def get_epaper_display(): |
| 15220 | """Get current e-paper display image as base64""" |
nothing calls this directly
no test coverage detected