Faking TCP Sessions with Scapy
Hi all: For various reasons, I want to take apache logs, and create actual pcap packets that could plausibly have created those logs. Obviously, a lot of the info would need to be faked, such as the actual page contents that were served (we have a byte count), the ports, and a few other details. Is there a library built on top of scapy (or other pcap library) that can generate both parts of this transaction, if I feed in the text to encapsulate? Or am I going to need to craft each packet individually (which shouldn't be a big deal anyway, really)? Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Determine sockets in use by python
Hi: I'm a newbie to python, although not to programming. Briefly, I am using a binding to an external library used for communication in a client-server context, with the server in python. Typically, I would set this up with event callbacks, and then enter a select loop, which, most the time idles and processes input events when the socket shows activity, kinda like: while True: socket.select((my_socket),(),()) process_event() Unfortunately, the API does not expose the socket to the script level, and the developer recommends a busy loop: while True: sleep(1) process_event() which I hope to avoid, for many reasons. If the socket can be exposed to the script level, then the problem would be solved. Failing that, it would be nice to be able to pythonically determine the sockets in use and select on those. Does anyone have any suggestions on how to proceed? Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Determine sockets in use by python
Hi Gary: Certainly not windows I'm developing on OS/X but for production probably Linux and FreeBSD (I'm hoping for something a bit more portable than running 'lsof' and parsing the output, but appreciate any/all advice) On Wed, Sep 29, 2010 at 11:05 AM, Gary Herron wrote: > On 09/29/2010 09:50 AM, Jim Mellander wrote: >> >> Hi: >> >> I'm a newbie to python, although not to programming. Briefly, I am >> using a binding to an external library used for communication in a >> client-server context, with the server in python. Typically, I would >> set this up with event callbacks, and then enter a select loop, which, >> most the time idles and processes input events when the socket shows >> activity, kinda like: >> >> while True: >> socket.select((my_socket),(),()) >> process_event() >> >> Unfortunately, the API does not expose the socket to the script level, >> and the developer recommends a busy loop: >> >> while True: >> sleep(1) >> process_event() >> >> which I hope to avoid, for many reasons. If the socket can be exposed >> to the script level, then the problem would be solved. >> >> Failing that, it would be nice to be able to pythonically determine >> the sockets in use and select on those. Does anyone have any >> suggestions on how to proceed? >> >> Thanks in advance >> > > It's certain that any answer to this will depend on which operating system > you are using. So do tell: What OS? > > -- > Gary Herron, PhD. > Department of Computer Science > DigiPen Institute of Technology > (425) 895-4418 > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Determine sockets in use by python
Thanks, I realized that even if I found out relevant info on the socket, I would probably need to use ctypes to provide a low level interface to select, as the socket wouldn't be a python socket object, unless there is some way to promote a c socket to a python socket object. Appreciate the info, folks. On Thu, Sep 30, 2010 at 7:14 AM, Jean-Paul Calderone wrote: > On Sep 29, 4:08 pm, Jim Mellander wrote: >> >> On Wed, Sep 29, 2010 at 11:05 AM, Gary Herron wrote: >> > On 09/29/2010 09:50 AM, Jim Mellander wrote: >> >> >> Hi: >> >> >> I'm a newbie to python, although not to programming. Briefly, I am >> >> using a binding to an external library used for communication in a >> >> client-server context, with the server in python. Typically, I would >> >> set this up with event callbacks, and then enter a select loop, which, >> >> most the time idles and processes input events when the socket shows >> >> activity, kinda like: >> >> >> while True: >> >> socket.select((my_socket),(),()) >> >> process_event() >> >> >> Unfortunately, the API does not expose the socket to the script level, >> >> and the developer recommends a busy loop: >> >> >> while True: >> >> sleep(1) >> >> process_event() >> >> >> which I hope to avoid, for many reasons. If the socket can be exposed >> >> to the script level, then the problem would be solved. >> >> >> Failing that, it would be nice to be able to pythonically determine >> >> the sockets in use and select on those. Does anyone have any >> >> suggestions on how to proceed? >> >> >> Thanks in advance >> >> > It's certain that any answer to this will depend on which operating system >> > you are using. So do tell: What OS? >> >> Hi Gary: >> >> Certainly not windows I'm developing on OS/X but for production >> probably Linux and FreeBSD >> >> (I'm hoping for something a bit more portable than running 'lsof' and >> parsing the output, but appreciate any/all advice) >> > > Linux has /proc/self/fd and OS X has /dev/fd. Those both suppose you > have some way of determining which file descriptor corresponds to the > socket or sockets that the library is using, of course. Vastly better > would be to convince the author to expose that information via a real > API. > > Jean-Paul > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list