Initial commit: Werkzeuge-Sammlung

Enthält:
- rdp_client.py: RDP Client mit GUI und Monitor-Auswahl
- rdp.sh: Bash-basierter RDP Client
- teamleader_test/: Network Scanner Fullstack-App
- teamleader_test2/: Network Mapper CLI

Subdirectories mit eigenem Repo wurden ausgeschlossen.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-01-28 09:39:24 +01:00
commit cb073786b3
112 changed files with 23543 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
import axios from 'axios';
import type {
Scan,
ScanRequest,
ScanStartResponse,
Host,
HostWithServices,
Service,
Topology,
HostStatistics,
} from '../types/api';
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';
const api = axios.create({
baseURL: API_BASE_URL,
timeout: 30000,
headers: {
'Content-Type': 'application/json',
},
});
// Scan Endpoints
export const scanApi = {
startScan: async (request: ScanRequest): Promise<ScanStartResponse> => {
const response = await api.post<ScanStartResponse>('/api/scans/start', request);
return response.data;
},
getScanStatus: async (scanId: number): Promise<Scan> => {
const response = await api.get<Scan>(`/api/scans/${scanId}/status`);
return response.data;
},
listScans: async (): Promise<Scan[]> => {
const response = await api.get<Scan[]>('/api/scans');
return response.data;
},
cancelScan: async (scanId: number): Promise<{ message: string }> => {
const response = await api.delete<{ message: string }>(`/api/scans/${scanId}/cancel`);
return response.data;
},
};
// Host Endpoints
export const hostApi = {
listHosts: async (params?: {
status?: 'up' | 'down';
limit?: number;
offset?: number;
}): Promise<Host[]> => {
const response = await api.get<Host[]>('/api/hosts', { params });
return response.data;
},
getHost: async (hostId: number): Promise<HostWithServices> => {
const response = await api.get<HostWithServices>(`/api/hosts/${hostId}`);
return response.data;
},
getHostByIp: async (ip: string): Promise<HostWithServices> => {
const response = await api.get<HostWithServices>(`/api/hosts/ip/${ip}`);
return response.data;
},
getHostServices: async (hostId: number): Promise<Service[]> => {
const response = await api.get<Service[]>(`/api/hosts/${hostId}/services`);
return response.data;
},
getHostStatistics: async (): Promise<HostStatistics> => {
const response = await api.get<HostStatistics>('/api/hosts/statistics');
return response.data;
},
deleteHost: async (hostId: number): Promise<{ message: string }> => {
const response = await api.delete<{ message: string }>(`/api/hosts/${hostId}`);
return response.data;
},
getHostsByService: async (serviceName: string): Promise<Host[]> => {
const response = await api.get<Host[]>(`/api/hosts/by-service/${encodeURIComponent(serviceName)}`);
return response.data;
},
};
// Topology Endpoints
export const topologyApi = {
getTopology: async (): Promise<Topology> => {
const response = await api.get<Topology>('/api/topology');
return response.data;
},
getNeighbors: async (hostId: number): Promise<Host[]> => {
const response = await api.get<Host[]>(`/api/topology/neighbors/${hostId}`);
return response.data;
},
};
// Health Check
export const healthApi = {
check: async (): Promise<{ status: string }> => {
const response = await api.get<{ status: string }>('/health');
return response.data;
},
};
export default api;

View File

@@ -0,0 +1,125 @@
import type {
WSMessage,
WSScanProgress,
WSScanComplete,
WSHostDiscovered,
WSError,
} from '../types/api';
const WS_BASE_URL = import.meta.env.VITE_WS_URL || 'ws://localhost:8000';
export type WSMessageHandler = {
onScanProgress?: (data: WSScanProgress) => void;
onScanComplete?: (data: WSScanComplete) => void;
onHostDiscovered?: (data: WSHostDiscovered) => void;
onError?: (data: WSError) => void;
onConnect?: () => void;
onDisconnect?: () => void;
};
export class WebSocketClient {
private ws: WebSocket | null = null;
private handlers: WSMessageHandler = {};
private reconnectAttempts = 0;
private maxReconnectAttempts = 5;
private reconnectDelay = 2000;
private reconnectTimer: number | null = null;
constructor(handlers: WSMessageHandler) {
this.handlers = handlers;
}
connect(): void {
if (this.ws?.readyState === WebSocket.OPEN) {
return;
}
try {
this.ws = new WebSocket(`${WS_BASE_URL}/api/ws`);
this.ws.onopen = () => {
console.log('WebSocket connected');
this.reconnectAttempts = 0;
this.handlers.onConnect?.();
};
this.ws.onmessage = (event) => {
try {
const message: WSMessage = JSON.parse(event.data);
this.handleMessage(message);
} catch (error) {
console.error('Failed to parse WebSocket message:', error);
}
};
this.ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
this.ws.onclose = () => {
console.log('WebSocket disconnected');
this.handlers.onDisconnect?.();
this.attemptReconnect();
};
} catch (error) {
console.error('Failed to create WebSocket connection:', error);
this.attemptReconnect();
}
}
private handleMessage(message: WSMessage): void {
switch (message.type) {
case 'scan_progress':
this.handlers.onScanProgress?.(message.data as WSScanProgress);
break;
case 'scan_complete':
this.handlers.onScanComplete?.(message.data as WSScanComplete);
break;
case 'host_discovered':
this.handlers.onHostDiscovered?.(message.data as WSHostDiscovered);
break;
case 'error':
this.handlers.onError?.(message.data as WSError);
break;
default:
console.warn('Unknown message type:', message.type);
}
}
private attemptReconnect(): void {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
console.error('Max reconnection attempts reached');
return;
}
if (this.reconnectTimer) {
return;
}
this.reconnectAttempts++;
const delay = this.reconnectDelay * this.reconnectAttempts;
console.log(`Attempting to reconnect in ${delay}ms (attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
this.reconnectTimer = window.setTimeout(() => {
this.reconnectTimer = null;
this.connect();
}, delay);
}
disconnect(): void {
if (this.reconnectTimer) {
clearTimeout(this.reconnectTimer);
this.reconnectTimer = null;
}
if (this.ws) {
this.ws.close();
this.ws = null;
}
}
isConnected(): boolean {
return this.ws?.readyState === WebSocket.OPEN;
}
}