ANN pyftpdlib 0.1 released

2007-03-05 Thread billie
Hi all,
I'm proud to announce the first beta release of pyftpdlib available at
the following urls:

home: http://billiejoex.altervista.org/pyftpdlib.html
google code: http://code.google.com/p/pyftpdlib/

About
=

pyftpdlib is an high-level FTP server library based on asyncore/
asychat frameworks.
pyftpdlib is actually the most complete RFC959 FTP server
implementation available for Python programming language.

Requirements
==

Python 2.2 or higher

Bug reports / Contacts


billiejoex -_[AT]_- gmail (dot) com

-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


distutils and paths

2007-02-19 Thread billie
Hi there.
I played with distutils for some hours but I didn't figured out how to
solve this problem so I would really be thankful if someone could help
me out.
My package is structured as follows:

setup.py
 |
  mypkg
 |  |
 |   __init__.py
 |   library.py
 |
  test
 |  |
 |   test.py
 |
  doc
   |
doc.html
doc_files
  |
   doc.css

By using setup.py script I would like to copy test and doc
directories (and all files contained in them) into Python's site-
package directory (on Windows C:\Python2x\Lib\site-packages\mypkg,
on unix /usr/lib/python2.x/site-packages/mypkg.)
Could someone point me in the right direction, please?


Thanks in advance.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsNT user authentication

2007-02-14 Thread billie
Another question, I'm sorry.
Do you got any idea about how to get permissions of a file/directory
given the username?
For example: I would like to know if C:\my_file.ext is readable/
writable by user 'x' or not.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsNT user authentication

2007-02-14 Thread billie
On 14 Feb, 14:30, Tim Golden [EMAIL PROTECTED] wrote:
 Tim Golden wrote:
  billie wrote:
  Another question, I'm sorry.
  Do you got any idea about how to get permissions of a file/directory
  given the username?
  For example: I would like to know if C:\my_file.ext is readable/
  writable by user 'x' or not.

  This is an unfortunately messy question.

 I'm sorry; that probably came out wrong. What I meant
 was that, although the question was perfectly intelligible,
 the answer is going to be more complex than you probably
 expected ;)

 TJG

No problem about that. ;)
I'll try to check demos folder then let you know something about it.
Thanks again.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsNT user authentication

2007-02-13 Thread billie
On 12 Feb, 16:53, Tim Golden [EMAIL PROTECTED] wrote:
 billie wrote:
  Do you got any idea about how getting user's home directory?

 The answer to that is unfortunately slightly complicated,
 because Windows has no such thing as a user's home directory
 or, if you prefer, it has several such things.

 If you want, you can let Python make the decision, by
 calling os.path.expanduser on ~ which, in my case,
 correctly gives h:\ which is my domain home directory.

 Obviously this is not necessarily the same as my Documents
 and Settings directory, which can also be considered a home
 directory. That you can get by querying the shell:

 code
 from win32com.shell import shell, shellcon

 idlist = shell.SHGetSpecialFolderLocation (0, shellcon.CSIDL_PERSONAL)
 documents_and_settings = shell.SHGetPathFromIDList (idlist)
 print documents_and_settings

 /code

 In my case they are the same but that will depend on your
 setup. I know in the past at least one of these has
 defaulted to c:\

 Alternatives (which in my case amount to the same thing)
 include using the HOMEDRIVE / HOMEPATH / HOMESHARE
 environment vars:

 code
 import os
 drive = os.environ.get (HOMEDRIVE, )
 path = os.environ.get (HOMEPATH, )

 share = os.environ.get (HOMESHARE, )

 print drive+path
 print share
 /code

 I haven't bothered to look, but I think this latter
 is how the expanduser function works things out.

 YMMV
 TJG

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


WindowsNT user authentication

2007-02-12 Thread billie
Hi there,
I would like to submit a username/password pair to a Windows NT
workstation and find out if it's valid.
Moreover I would like to get the user's home directory given the
username.
Does it is possible to do that by using pywin32 extension?

Could someone point me in the right direction?


Best regards

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsNT user authentication

2007-02-12 Thread billie
On 12 Feb, 14:45, Tim Golden [EMAIL PROTECTED] wrote:
 billie wrote:
  Hi there,
  I would like to submit a username/password pair to a Windows NT
  workstation and find out if it's valid.
  Moreover I would like to get the user's home directory given the
  username.
  Does it is possible to do that by using pywin32 extension?

 http://timgolden.me.uk/python/win32_how_do_i/check-a-users-credential...

 There are a few caveats (and there are other ways, too). This
 one is pretty simple, though.

 HTH
 TJG

Thanks, it shoulda work.
Do you got any idea about how getting user's home directory?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asyncore DoS vulnerability

2007-02-03 Thread billie
On 2 Feb, 17:09, Chris Mellon [EMAIL PROTECTED] wrote:

 Thats like asking why you should have to move your fingers to type or
 why you should have to eat food in order to not starve. Windows is
 placing a limit of 512 descriptors per process. Call Microsoft if you
 want to go over that.

?
That's not a select() problem: that's an asyncore problem.
I'm just saying that asyncore should handle this event in some other
way than raising a not well defined ValueError.
I've discovered this problem accidentally by writing a small test
script but personally I've never seen a paper describing it.
Not handling such a problem just means that an asyncore based server
is vulnerable to DoS attacks and I believe that a lot of servers out
there didn't used a try/except statement around asyncore.loop().
imho, such a problem should merit some attention.
Don't you agree?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asyncore DoS vulnerability

2007-02-02 Thread billie
 This is not a CRASH, It looks an exception with a Traceback, this is
 the normal way python report problems, nothing wrong with that.
 You can handle it with a try: except:

I think that such a thing should be handled by asyncore itself.

 512 is probably a fixed limit into XP, win2k3 or win2k server will
 accept more.
 Maybe It's possible to increase this value somewhere in the registry.
 If not this is how microsoft justify the difference between server and
 workstation products :-)

Yeah, maybe...

 Why does this exception isn't handled inside asyncore.py?
 To do what ? To raise a custom asyncore error ?

asyncore aims to be a framework, right?
I think that when select() limit is reached asyncore should just drop
other connections. That's all.

 You can can probably run over this limit by starting multiple of your
 server process (not thread, process).

Hope you're joking...
Why should I have to run multiple processes / threads to avoid such a
problem?
And what if my system / inteprepter does not support multiple
processes / threads?

-- 
http://mail.python.org/mailman/listinfo/python-list


asyncore DoS vulnerability

2007-02-01 Thread billie
Hi all. I've just terminated a server application using asyncore /
asynchat frameworks.
I wrote a test script that performs a lot of connections to the server
app and I discovered that asyncore (or better, select()) can manage
only a limited number of file descriptors (aka simultaneous
connections).
When this number is reached select() raises an error but asyncore
doesn't handle this exception (a crash occurs).
If you want to try this I pasted two scripts below: a server and a
client.
On my Windows XP system server.py the crash occurs when 512
simultaneous connections are reached.
Here's the traceback:

Traceback (most recent call last):
  File C:\Documents and Settings\root\Desktop\test.py, line 31, in ?
asyncore.loop(timeout=1)
  File C:\Python24\lib\asyncore.py, line 192, in loop
poll_fun(timeout, map)
  File C:\Python24\lib\asyncore.py, line 122, in poll
r, w, e = select.select(r, w, e, timeout)
ValueError: too many file descriptors in select()


Why does this exception isn't handled inside asyncore.py?




# server.py
import asyncore, socket

class server(asyncore.dispatcher):
The base class for the backend.

def __init__(self):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.bind(('', 8080))
self.listen(5)

def handle_accept(self):
sock_obj, addr = self.accept()
handler(sock_obj)

class handler(asyncore.dispatcher):

def __init__(self, sock_obj):
asyncore.dispatcher.__init__(self, sock=sock_obj)

def handle_write(self):
pass

def handle_read(self):
pass

server()
asyncore.loop(timeout=1)

-

# client.py
import socket, threading, os

def client():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((127.0.0.1, 8080))
except:
print x
os._exit(0)
while 1:
s.recv(1024)

x = 0
while 1:
x +=1
threading.Thread(target=client).start()
print x

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Projects anyone?

2007-01-17 Thread billie
placid wrote:

 Hi all,

 I'm looking for anyone who is working on a project at the moment that
 needs help (volunteer). The last project i worked on personally was
 screen-scraping MySpace profiles (read more at the following link)

 http://placid.programming.projects.googlepages.com/screen-scrapingmyspaceprofiles


 but that didn't go all to well, so im kinda bored and need something to
 do, with Python. So any suggestions anyone?

 Cheers

Please, contact me at:

billiejoex [EMAIL PROTECTED] gmail.com

I could need help for 3 projects.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2.3-2.5 what improved?

2007-01-17 Thread billie

robert wrote

 Robin Becker wrote:
  A large cgi based web Python-2.3 application needs to be speed improved.
  experiments show the following under reasonable testing (these are 2
  second reportlab pdf productions)
 
  1) 2.3 -- 2.5 improvement small 1-2%
  2) cgi -- fcgi improvement medium 10-12%
 
  I sort of remember claims being made about 2.5 being 10% faster than
  2.4/2.3 etc etc. Can anyone say where the speedups were? Presumably we
  have a lot of old cruft that could be improved in some way eg moving
  loops into comprehensions, using iterator methods etc. Are those sort of
  things what we should look at?

 Python 2.5 became quite fat. For bare CGI the Python load/init
 time eats all improvements. Smaller scripts even loose lot of speed.
 I still like Python 2.3 for many other reasons for many
 applications - especially for CGI's, on Windows, for deployable
 apps, GUI's etc. because the fat coming with Python 2.4 is not
 balanced by necessary goods - mostly just fancy things.

What do you mean? Fat of libraries or fat itself?
I tought that 2.5 was faster than precedent versions! :-\

-- 
http://mail.python.org/mailman/listinfo/python-list


sleep in asyncore

2007-01-11 Thread billie
Hi all.
I'm writing an authentication server by using asyncore / asynchat
modules.
I'd like to implement a basic brute-force protection by freezing /
sleeping the current client session for a period of time (e.g. 2
seconds) when the user sends a wrong password.
Does someone knows a trick to do that with asyncore?


Thanks in advance for your helping.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: General Question About Python

2007-01-09 Thread billie
Torabisu wrote:

 Its quite weird, we're looking for Python skills but are battling to
 find at the moment...  Normally Python on its own will probably not
 land you a job, but the last two companies I've worked for are doing
 indepth Python development, so hopefully the tables are turning a bit.

I can tell the same for Italy.
Where are you from?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: One module per class, bad idea?

2006-12-13 Thread billie

Isaac Rodriguez wrote:

  Yes, it would be a bad idea. =)

 Saying it is a bad idea and not explaining why will not help anyone. I
 would like you to elaborate on why it is a bad idea to have one file
 per class.

 Thanks,

 - Isaac.

Because it's just a useless limitation.
Python lets you the freedom to decide if using one class per file or a
lot of classes per file and this, imho, is a great advantage of Python
other Java.
Personally I like to have the possibility to include multiple classes
in one module if I need them. Obviously I'll hardly mix classes having
different tasks in the same .py file.
If you come from Java feel free to use the Java approach.

-- 
http://mail.python.org/mailman/listinfo/python-list


How to manage two (different) sockets without using threads?

2006-12-13 Thread billie
Hi all.
I'm (re)writing an FTP server application by using asyncore/asynchat
modules.
FTP tipically got two different channels: command and data.
I'm succesfully managing command channel through asynchat framework,
but I'm not sure about how to manage data channel without using a
thread/subprocess.
Is there an optimal to do that?
Can anyone point me in the right direction?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: One module per class, bad idea?

2006-12-12 Thread billie
 would it be a bad idea to have a guideline
 in your project that promotes a one class per file structure (assuming most
 of the programmers a background similar to mine)?

Yes, it would be a bad idea. =)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RAW network programming under Windows

2006-11-10 Thread billie
sturlamolden wrote:

 You can try to install Windows Services for Unix 3.5 (aka SFU 3.5).
 It transforms your Windows into a certified UNIX (not just a Unix
 clone). SFU 3.5 has a full BSD socket API (derived from OpenBSD), not
 just Winsock. As the POSIX subsystem in SFU 3.5 is not layered on top
 of the Win32 subsystem, but talks directly to the NT kernel,
 restrictions in Winsock should not affect the BSD sockets in SFU 3.5.
 This behaviour is different from e.g. Cygwin, where the Unix APIs are
 layered on top of the Win32 subsystem.

It isn't exactly what I'm searching for but thanks anyway.

 In any case, I hope you are aware that spoofing IP packets gives you
 bad karma.

No problem about it. I'm just a lover of low-level network programming.
=)

-- 
http://mail.python.org/mailman/listinfo/python-list


RAW network programming under Windows

2006-11-05 Thread billie
RAW network programming under Windows it's not always possible because
of the security limitations that microsoft introduced in the latest
Windows versions and that affects WinSocket API.
On UNIX systems I'm able to freely send raw packets (for example I'm
able to compile IP packets with a src address defined by me) through
raw socket API, but if I do the same on a Windows system socket module
raises an error.

Now I'm searching for something different from raw socket api, an
extension module able to send arbitrary RAW packets through the
network.
I noticed that WinPcap (http://www.winpcap.org/) has a function to do
that (pcap_sendpacket()) so I started to search a Python wrapping for
WinPcap.
I found:
pcapy: http://oss.coresecurity.com/projects/pcapy.html
pypcap: http://www.monkey.org/~dugsong/pypcap/
...but none of them include a wrap for pcap_sendpacket() function.

Does someone know if exist a *complete* Python wrapping of WinPcap
library?

-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter systray

2006-10-09 Thread billie
Hi all. I'd like to develop a GUI-based application the most portable
as possible, able to run in systray.
I think that, for portability reasons, Tkinter could be the best
choice, so I tried to google a little bit about it.
According to this :
http://mail.python.org/pipermail/python-list/2002-September/123257.html
...it seems that it's impossible (or better, it WAS impossible in
September 2002) handling this case by using Tkinter.
Four years later is there a way to make this happen?

Thanks in advance.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to run in background?

2006-10-06 Thread billie
I'm sorry. I tried with windows=myscript.py but it doesn't seem to
work.
I really don't know where find this information that's extremely
important for me.
I googled a lot but I didn't found a solution for my problem. :-\

-- 
http://mail.python.org/mailman/listinfo/python-list


How to run in background?

2006-09-25 Thread billie
Hi all. I know that it's possible to automatically run a Python program
in background by giving it the pyw extension.
This is useful when I release a source ditribution of my program.
How could it be possible to do the same thing with an .exe file
compiled with py2exe extension? Do I have to write a batch script
separately?

Thanks in advance

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get process id...

2006-09-21 Thread billie

[EMAIL PROTECTED] ha scritto:

 SpreadTooThin wrote:
  How does one get the process id?
  Is there a method for windows and unix (mac os x etc...)

 under linux, do:
   import os
   os.getpid()

Under Windows:
import ctypes
ctypes.windll.kernel32.GetCurrentProcessId()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get process id...

2006-09-21 Thread billie

Fredrik Lundh ha scritto:

 billie wrote:

  under linux, do:
  
import os
os.getpid()
 
  Under Windows:
  
  import ctypes
  ctypes.windll.kernel32.GetCurrentProcessId()

 getpid() works just fine on Windows too:

   import ctypes
   ctypes.windll.kernel32.GetCurrentProcessId()
 1916
   import os
   os.getpid()
 1916

I tought it doesn't work. Good

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why a main() function?

2006-09-19 Thread billie
Another advantage is that you can catch all the unhandled exceptions of
the entire program (it they occurs) by doing something like this:

def another_call():
raise SomeUnexpectedException   # it will be catched in '__main__'

def call():
another_call()

def run():
call()

in __name__ == '__main__':
try:
 run()
except:
 # do cleanup
 # log exit message
 # exit

-- 
http://mail.python.org/mailman/listinfo/python-list


Interact with system command prompt

2006-09-18 Thread billie
Hi all. I would like to know if there's some python framework able to
interact with system command prompt (cmd.exe or /bin/sh, depending on
the system) from python.
I need something that supports key/path auto completion by pressing TAB
button and the possibility to use interactive programs like ftp, gpg or
even vi.
I would like to write a remote shell application the best featured as
possible and I'm wondering if Python is able to emulate the
functionalities of applications like telnet or ssh.

Thanks in advance for your helping.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interact with system command prompt

2006-09-18 Thread billie

Diez B. Roggisch ha scritto:

 billie wrote:

  Hi all. I would like to know if there's some python framework able to
  interact with system command prompt (cmd.exe or /bin/sh, depending on
  the system) from python.
  I need something that supports key/path auto completion by pressing TAB
  button and the possibility to use interactive programs like ftp, gpg or
  even vi.
  I would like to write a remote shell application the best featured as
  possible and I'm wondering if Python is able to emulate the
  functionalities of applications like telnet or ssh.

 Check out IPython.

 http://ipython.scipy.org/


 Diez

Thank you. It seems to me a powerful tool. I'll try to play with it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interact with system command prompt

2006-09-18 Thread billie
Uhm... It seems that IPython got some problems:
http://ipython.scipy.org/doc/manual/node12.html

In details:

Note that this does not make IPython a full-fledged system shell. In 
particular, it has no job control, so if you type Ctrl-Z (under Unix), you'll 
suspend pysh itself, not the process you just started.

What the shell profile allows you to do is to use the convenient and powerful 
syntax of Python to do quick scripting at the command line.

-- 
http://mail.python.org/mailman/listinfo/python-list


Limitate speed of a socket-based data transferring

2006-09-14 Thread billie
Hi all. I'm writing a TCP-based application that I will use to trasfer
binary files through the network. This piece of code represents how do
I get a file from a remote peer and save it on my local hard drive:

file_obj = open('downloaded.ext', 'wb')
while 1:
buf = sock.recv(2048)
if len(buf) == 0:
 break
file_obj.write(buf)
file_obj.close()
sock.close()

I would like to know how could be possible to limit the file transfer
speed (for example: don't write more than 50 Kb/sec).
Some ideas?

Best regards

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Outbound port on sockets

2006-09-14 Thread billie

bmearns wrote

 Is it possible to specify which port to use as the outbound port on a
 connection? I have the IP address and port number for the computer I'm
 trying to connect to (not listening for), but it's expecting my
 connection on a certain port.

 Specifically, I'm trying to write an FTP host, and I'm trying to
 implement the PORT command. From everything I've read, the client
 supplies the IP address and port number for where I'm supposed to
 connect to send it data (like a LISTing), and it's expecting me to
 connect over port 20. If anyone is familiar with FTP and can tell me
 whether this is true or not, whether I really need to go out on port
 20, I'd appreciate it, as well.

 Thanks.

This isn't correct.
If you send a PORT command you're telling server to establish a
connection with you, not the contrary. In this case, even if you are an
FTP client, you temporary ACCEPT an outbound connection from the FTP
server.
The right format of a FTP PORT command is:

PORT x,x,x,x,y,z

...where x(s) represents your IP address in dotted form and (x * y) the
TCP port you bind.
For further informations you can check RFC959 or take a look at ftplib
in standard module library. Also in twisted you can find a lot of
useful code in the module protocols.ftp.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Outbound port on sockets

2006-09-14 Thread billie
 The right format of a FTP PORT command is:

 PORT x,x,x,x,y,z

 ...where x(s) represents your IP address in dotted form and (x * y) the
 TCP port you bind.

Sorry, I wanted to say: (y * z)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: editor for Python on Linux

2006-02-20 Thread billie
I really think that IDLE is one of the best around in Python source editing. 
The only great lacks are tabs. Does somebody know if is there some IDLE 
modified version including tabbed browsing, out there? 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Netstat in python. Does it's possible?

2006-02-13 Thread billie
Thank you all for your helping.


-- 
http://mail.python.org/mailman/listinfo/python-list


Netstat in python. Does it's possible?

2006-02-11 Thread billie
Hi all. I don't know if Python is good for this kind of jobs but I'm 
wondering if it's possible emulate the netstat command in Python.
I'd need to know if a certain executable opened a socket and, in that case, 
I'd like to know what kind of socket it uses (TCP or UDP), its src/dst PORT, 
and the current STATE of the connection (listening, established, SYN 
sent...).

Thanks in advance. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Using RAW_SOCKETS on win XP SP2

2006-02-07 Thread billie
Hi all. I'd need to send a TCP SYN packet having a certain string as 
payload. I'm
using Python and an high level packet building library called Impacket to
build TCP and IP datagrams. I wrote this simple code that works on Linux but 
not on Windows XP SP2, probably because of SP2 security limitations. Do you 
got any idea about how could I solve this problem?
I found an article of Fyodor (author of nmap port scanner) about how to
solve this kind of SP2 limitations:
http://seclists.org/lists/nmap-hackers/2004/Jul-Sep/0003.html
...that says:

 Instead of sending raw IP packets, we move one layer down and send our
 raw IP packets in raw ethernet frames.

Do you got any idea about how could I implement a stuff like this?

Best regards.


from impacket import ImpactPacket
from socket import *

src = '10.0.0.1'
dst = '10.0.0.25'

s = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)

ip = ImpactPacket.IP()
ip.set_ip_src(src)
ip.set_ip_dst(dst)

tcp = ImpactPacket.TCP()
tcp.set_SYN()
tcp.set_th_sport(43749)
tcp.set_th_dport(1000)
tcp.contains(ImpactPacket.Data('hello there'))

ip.contains(tcp)

s.sendto(ip.get_packet(), (dst, 0))


++  ERROR ++

s.sendto(ip.get_packet(), (dst, 0))
socket.error: (10022, 'Invalid argument')



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using RAW_SOCKETS on win XP SP2

2006-02-07 Thread billie
Up :-) 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best way to capture output of another command-line program in Win32?

2006-02-06 Thread billie
Another way:

 import popen2
 exec_cmd = popen2.popen4('dir')
 output = exec_cmd[0].read()
 print output
[...]
04/02/2006  21.44   106 setup.py
06/02/2006  23.25   656 time_synch.py
07/02/2006  00.5216.885 knockd.log
07/02/2006  00.35 6.376 conf.pyc
[...]



-- 
http://mail.python.org/mailman/listinfo/python-list


Determine the IP address of an eth interface

2006-01-18 Thread billie
Hi all. I'm searching for a module that permits me to low-level interact
with ethernet interfaces of my system.
I would like to determine at least the first of the followings values:

1 - IP address assigned to the interface
2 - subnet mask
3 - default gateway
4 - primary and secondary dns
5 - default wins server
6 - mac address
7 - broadcast address

On python cookbook I found this usefuls script that returns the IP address
of a specified interface but it only works on unix platforms. I was 
wondering if exist a specific module that could solve this kind of
problems.
Best regards.

import socket
import fcntl
import struct

def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915,  # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])

 get_ip_address('lo')
'127.0.0.1'

 get_ip_address('eth0')
'38.113.228.130'

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to lock a file in ftp site

2005-12-19 Thread billie
No, I think you have to manually set this policy directly on the ftp server. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen4

2005-10-18 Thread billie

Piet van Oostrum wrote:
 I think you need something like pyexpect for this.

PyExpect seems to be no more mantained.


-- 
http://mail.python.org/mailman/listinfo/python-list


popen4

2005-10-16 Thread billie
Hi all. I'm trying to execute system commands and capture the output by 
using popen4:

stdout example:
exec_cmd = popen2.popen4(echo hello!)
output = exec_cmd[0].read()
hello

stderr example:
exec_cmd = popen2.popen4(echobv hello!)
output = exec_cmd[0].read()
Unrecognized command

The problem occurs when I try to execute interactive commands like ftp, 
python intepreter etc...
In this case the program crashes without even giving an error.
Suggestions?

Regards


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a Python mentor

2005-10-14 Thread billie

Nir Aides  wrote
 Hello Len,

 You should try the #python IRC room.
 It is always very active and helpful.

 Nir

Do you mean efnet #Python chan?
It's not too much active... 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to(can we ?) pass argument to .py script ?

2005-10-12 Thread billie
It's quite simple. If this usage example can helps you...

### parser
try:
opts, args = getopt.getopt(sys.argv[1:], h, e, p:, [help])
mode = 'reply' # default mode
pwd = ' ' # default pass (blank)
for o, a in opts:
if o == '--help' or o == '-h':
print helper()
os._exit(0)
if o == '-h':
print helper()
os._exit(0)
if o == '-e':
mode = 'echo/reply'
if o == '-p':
pwd = a
if len(args)  3 :
print  ERR: Too much few arguments.\n Type %s -h for help. \
%(sys.argv[0])
os._exit(0)
if len(args)  3:
print \
 ERR: Too much arguments.\n Type -h and \
look example to send argumented commands.
os._exit(0)
except:
print  ERR: Invalid Option.\n Type %s -h for help. \
%(sys.argv[0])
os._exit(0)
### /parser 


-- 
http://mail.python.org/mailman/listinfo/python-list


how to capture key pressing

2005-10-10 Thread billie
Hi all. I'm searching for a module that permit me to costantly log every key 
pressed on the keyboard and eventually assign it a function (e.g. when esc 
is pressed: exit program). 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to capture key pressing

2005-10-10 Thread billie
 Look at curses.

I was searching for something portable on multiple platforms.
Curses doesn't work on Windows. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Build spoofed IP packets

2005-10-06 Thread billie
 It's SP2. Microsoft decided allowing raw socket access is a security 
 threat and disabled it in SP2.
Uhm.. I heard about that. Damn it. :-\ 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Build spoofed IP packets

2005-10-05 Thread billie

 Yes, give us the error. And know that you can't build raw IP packets
 unless you're root.

 Sybren

Sorry. I forgot to paste the error:

Traceback (most recent call last):
  File C:\test\client.py, line 156, in ?
send_pkt()
  File C:\test\client.py, line 96, in send_pkt
s.sendto(ip.get_packet(), (dst, 0)) # send packet to server
socket.error: (10004, 'Interrupted system call')

Note: this only happens on Windows XP prof SP2. On Linux I got no problems.
I run the program as Administrator. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Mantain IDE colors and paste them in an HTML page

2005-10-04 Thread billie
Hi all. I need to insert a Python source in an HTML page mantaining to 
coloration gives by the IDE.
I tried the export function of scite but it does not generate a proper HTML 
code that permit me to copy and paste it into another HTML page.
Does anyone got any suggestion?

Regards


-- 
http://mail.python.org/mailman/listinfo/python-list


Build spoofed IP packets

2005-10-04 Thread billie
Hi all. I'd need to build spoofed IP packets. Do you know something about a 
python implementation?
For low level packet building I already used Impacket module but if I 
specify a spoofed src address during IP packet creation, module returns an 
error.
Suggestions?

Regards. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python guru.. for a short conversation regarding bittorrent..

2005-10-02 Thread billie
If it can helps you ABC is a (good) bittorent client written in py.


-- 
http://mail.python.org/mailman/listinfo/python-list


Using multiple threads with pcapy

2005-09-14 Thread billie
Hi all. Because of pcapy sniffng library doesn't permit to listen on 
multiple interfaces I'm trying to use threads to avoid this problem.
In the source below I tried to start a thread for every NIC installed on my 
system (I got 2 NICs) but once I started the first thread the program can't 
go further.
Note that the first trhread works properly (I can sniff traffic) but the 
problem is that the second thread regarding the other NIC never starts.
Does someone got any suggestion?

Thanks in advance.

http://rafb.net/paste/results/0NHfUm76.html 


-- 
http://mail.python.org/mailman/listinfo/python-list