How to run sngrep from a web page

Issues related to applications and software problems
Post Reply
edlentz
Posts: 75
Joined: 2013/06/11 20:20:25

How to run sngrep from a web page

Post by edlentz » 2022/05/13 18:08:24

I am looking for a way to run sngrep from a webpage. I wish not to have to go to the command line. I have tried using a simple php page:

Code: Select all

<?php
//Store the output of the executed command
$output1 =  exec('sngrep');
//Print the return value
echo $output1;
echo "<br/>";
?>
All I get is a blank page I get this error: Couldn't open device any: any: You don't have permission to capture on that device (socket: Operation not permitted)
Couldn't open device any: any: You don't have permission to capture on that device (socket: Operation not permitted)

I tried a cgi script

Code: Select all

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"

echo "<h1>SNGrep Terminal</h1>"
echo "<pre> $(sngrep) </pre>"

echo "</body></html>"
I got the header but nothing else.

Is there anyway to do this? Not having to ssh into the system would be a big help.

Thanks

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to run sngrep from a web page

Post by TrevorH » 2022/05/13 19:13:08

It sounds like a horrible idea especially since you're not supplying any arguments to your sngrep invocation so it will just run and find everything. In addition, it seems to use ncurses for display and it doesn't end until you interact with it to tell it to stop so you will invoke it and it will run and the command will never return. I'd also bet that selinux is busy blocking you from even trying from within httpd.

I have sngrep packaged and my package spec explicitly sets %caps(cap_net_raw=eip cap_net_admin=eip) on the executable so that non-root users can run it and get access to the network device (which looks like the problem you are currently experiencing).
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

edlentz
Posts: 75
Joined: 2013/06/11 20:20:25

Re: How to run sngrep from a web page

Post by edlentz » 2022/05/13 20:08:50

TrevorH
You are probably 100% correct. I am just trying to come up with a way tht I can get the info that sngrep provides to a gui. I want to keep users out of the command line as much as possible. I'll keep looking for something that works without compromising the system
Thanks

Post Reply