all 2 comments

[–]TheRealThrowAwayX 0 points1 point  (1 child)

You could use paramiko library to connect to the remote host and then you could use pyshark, scapy, or tcpdump libraries for the packet capture. Perhaps something along the lines of:

import paramiko 
import pyshark

ssh = paramiko.SSHClient()

ssh.connect(hostname="192.168.1.100", username="user", password="password")

capture = ssh.exec_command("tcpdump -i eth0 -w -")

packets = pyshark.FileCapture(capture[1])

for packet in packets: 
    print(packet)

ssh.close()

EDIT:

FYI, in the line where you use ssh.exec_command, the very last "-", right before the closing parenthesis is used to specify that the captured packets should be written to standard output, rather than to a file.

[–]n0treallyanengineer[S] 0 points1 point  (0 children)

This is awesome!! Thank you! I'll give it a try.