test_server.cpython-310.pyc•5.6 kB
o
�UhD � @ s� d Z ddlZddlZddlZddlmZ ej�deee �j
�� ddlZej
�dd�Zej
�e�Zej�e� ejZejZdd� Zdd � Zd
d� ZedkrRe� dS dS )
z�
Test script for Wireshark MCP Server
This script tests the core functionality of the Wireshark MCP server
without requiring a full MCP client setup.
� N)�Path�wireshark_mcp_serverzwireshark-mcp-server.pyc
� s� �t d� t d� z't d� t� } t d| j� �� | jr$t d| j� �� | jr/t d| j� �� W n tyJ } zt d|� �� W Y d}~d S d}~ww t d
� zM| �� }|d dkr�t d
|d � d�� t|d dd� �D ]\}}t d|d � d|� �� qn|d dkr�t d|d d � d�� n t d|d � �� W n ty� } z
t d|� �� W Y d}~nd}~ww t d� g d�}|D ]}t� |�}|r�dnd}t d|� d|� d |r�d!nd"� �� q�g d#�} | D ]}
t�
|
�}|r�dnd}t d|� d$|
� d |r�d!nd"� �� q�t d%� zV| �� }|d dk�rY|d �rY|d d& }d|v �r,|�d�d& }nd'}t d(|� �� | j|dd)d*�}
|
d dk�rOt d+|
d, � d-�� nt d.|
d � �� nt d/� W n t�yx } z
t d0|� �� W Y d}~nd}~ww t d1� g d2�}|D ]#}t�
|�}|�r�dnd}|�r�|nd3}t d|� d4|� d |� �� �q�t d5� t d6� t d7� t d8� t d9� t d:� d;S )<z+Test the Wireshark interface functionality.u, 🧪 Testing Wireshark MCP Server Componentsz2==================================================z01. Testing Wireshark Interface Initialization...u ✅ TShark found at: u ✅ Dumpcap found at: u ✅ Capinfos found at: u/ ❌ Error initializing Wireshark interface: NFz(
2. Testing Network Interface Listing...�status�successu
✅ Found �countz network interfaces:�
interfaces� z � z. z ... and z moreu$ ⚠️ Interface listing issue: �messageu! ❌ Error listing interfaces: z"
3. Testing Security Validation...)�eth0�wlan0z
Ethernet 2zWi-Fi�1zinvalid;command�
../etc/passwdu ✅u ❌z z Interface 'z': �Valid�Invalid)ztcp port 80zhost 192.168.1.1z
tcp; rm -rf /z
normal filterz Filter 'z2
4. Testing Live Capture (if permissions allow)...r r
z! Testing capture on interface: �
)r �timeoutu ✅ Successfully captured �packet_countz packetsuN ⚠️ Capture test failed (this is expected without proper permissions): u. ⚠️ No interfaces available for testingu? ⚠️ Capture test failed (expected without permissions): z!
5. Testing File Path Security...)z/tmp/test.pcapr zC:\Windows\System32\test.pcapz./nonexistent.pcapztest.txt�Rejectedz Path 'u"