emmanueltouzery / hotwire

Hotwire allows you to study network traffic of a few popular protocols in a simple way
MIT License
229 stars 11 forks source link

not possible to run tcpdump manually for flatpak-version #3

Open freddii opened 2 years ago

freddii commented 2 years ago

sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w /home/freddii/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 -B 8192 [sudo] Passwort für freddii: tcpdump: data link type LINUX_SLL2 tcpdump: /home/freddii/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2: Permission denied

emmanueltouzery commented 2 years ago

hmm. i'm a little confused how come the command fails although you run it with sudo :|

freddii commented 2 years ago

running the following command works, but then the log is at the wrong location. sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w /home/freddii/hotwire-record-2 -B 8192

emmanueltouzery commented 2 years ago

it works for me.

$ sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w /home/emmanuel/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 -B 8192
[sudo] password for emmanuel: 
tcpdump: data link type LINUX_SLL2
dropped privs to tcpdump
tcpdump: listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
7282 packets captured
7454 packets received by filter
166 packets dropped by kernel

which distribution are you using? what does ls -lh ~/.var/app/com.github.emmanueltouzery.hotwire/data/ print?

freddii commented 2 years ago

OS: Debian GNU/Linux bookworm/sid x86_64

$ ls -lh ~/.var/app/com.github.emmanueltouzery.hotwire/data/ insgesamt 4,0K drwxr-xr-x 2 freddii freddii 4,0K 12. Jan 13:09 hotwire

emmanueltouzery commented 2 years ago

same as me. so you have the right to write in ~/.var/app/com.github.emmanueltouzery.hotwire/data/. Presumaby both touch ~/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 and sudo touch ~/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 should work (do sudo rm ~/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 in-between).

Maybe it's related to tcpdump reducing its privileges.. which version of tcpdump do you have?

for me...

$ tcpdump --version
tcpdump version 4.99.1
libpcap version 1.10.1 (with TPACKET_V3)
OpenSSL 1.1.1l  FIPS 24 Aug 2021
freddii commented 2 years ago

$ tcpdump --version tcpdump version 4.99.1 libpcap version 1.10.1 (with TPACKET_V3) OpenSSL 1.1.1m 14 Dec 2021

touch ~/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 and sudo touch ~/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 are working. hotwire is also creating that file when pressing on capture.

freddii commented 2 years ago

Looks like i have problems with foldernames with dots in it. Maybe its a problem of my setup or tcpdump. When i change the foldername from "test" to ".test", it fails.

$ sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w "/home/freddii/test/dump" -B 8192 tcpdump: data link type LINUX_SLL2 tcpdump: listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes

$sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w "/home/freddii/.test/dump" -B 8192 tcpdump: data link type LINUX_SLL2 tcpdump: /home/freddii/.test/dump: Permission denied

so it seams not to be a bug of hotwire.

lvlgl commented 1 year ago

I can't get tcpdump to work. Maybe we could create a named pipe in /tmp instead of user's home?

emmanueltouzery commented 1 year ago

in the end tcpdump has to run on your machine, because the flatpak won't have the privileges.

we'd need to establish exactly what's the problem. You can ask hotwire to open a fifo from the GUI. If you use the open menu and ask it to open a fifo. And then you decide where is the fifo on disk.

so you can run any tcpdump command you like, and make it write to a fifo you create yourself wherever the hotwire flatpak can read. Just use the mkfifo command to create it. Let me know it works out!

lvlgl commented 1 year ago

This menu does not allow me to open any single file, including a fifo in /tmp with file permissions set to 0777. I was only able to list directories using this menu.

sysfu commented 1 year ago

Having a similar issue attempting to run the prescribed tcpdump command on Elementary OS 6.1 Jolnir (based on Ubuntu 20.4.5 LTS)

$ sudo tcpdump -ni any -s0 --immediate-mode --packet-buffered -w /home/user/.var/app/com.github.emmanueltouzery.hotwire/data/hotwire/hotwire-record-2 -B 8192 tcpdump: Couldn't change ownership of savefile

sysfu commented 1 year ago

I was able to resolve the issue by manually compiling and installing the current version of tcpdump, 4.99.3

emmanueltouzery commented 1 year ago

This menu does not allow me to open any single file, including a fifo in /tmp with file permissions set to 0777. I was only able to list directories using this menu.

you can give to the flatpak access to more folders like so:

flatpak override --user --filesystem=/tmp com.github.emmanueltouzery.hotwire

or check things like: https://askubuntu.com/questions/1086529/how-to-give-a-flatpak-app-access-to-a-directory

lvlgl commented 1 year ago

It does have access to the host filesystem, I was talking about the file picker. It is restricted to a certain filetype shown as (None), and I can't choose a pipe because I only see folders everywhere

emmanueltouzery commented 1 year ago

it does display (None) for me as well, but I can pick files. And I am running it as flatpak. So if you gave the access I'm not really sure what's going on.

lvlgl commented 1 year ago

filesystem=host permission was granted using Flatseal, and the file picker does not show files. It does show directories though

image

hariienesh commented 1 year ago

Same error even if you build from source

Capturing on '/home/mind/.local/share/hotwire/hotwire-record-41068'
tcpdump: Couldn't change ownership of savefile
tshark: Unexpected error from select: Interrupted system call.