PythonÍøÂç×¥°ü¿â pypcap
Ethereal ×Ô´øÐí¶àÐÒéµÄ decoder,¼òµ¥,Ò×ÓÃ,»ùÓÚwinpcapµÄÒ»¸ö¿ªÔ´µÄÈí¼þ.µ«ÊÇËüµÄ¼Ü¹¹²¢²»Áé»î,ÈçºÎÄãÒª¼ÓÈëÒ»¸ö×Ô¼º¶¨ÒåµÄµÄ½âÂëÆ÷,µÃÈ¥ÐÞ¸Ä EtherealµÄ´úÂë,ÔÙÖØбàÒë,ºÜ·³Ëö.¶ÔÓÚÒ»°ãµÄÃ÷ÎÄ ÐÒé,ûÓÐʲôÎÊÌâ,µ«ÊǶÔÓÚ¼ÓÃÜÐÒé,±ÈÈçÍøÂçÓÎÏ·,¿Í»§¶Ë³ÌÐòÒ»°ã»áÔÚ¸ÕÁ¬½ÓÉϵÄʱºò,·¢ËÍÒ»¸öËæ»úÃÜÔ¿,¶øºóµÄ±¨ÎĶ¼»áÓÃÕâ¸öÃÜÔ¿½øÐмÓÃÜ,Èç´Ë. ÒªÏëÆƽâ,µÃÒªÓÐÒ»¸ö¿É±à³ÌµÄ×¥°üÆ÷.
libpcapÊÇÒ»¸ö²»´íµÄÑ¡Ôñ,µ«ÊǶÔÓÚ×¥°üÕâÑùÐèÒª·´¸´½øÐДÊÔ Ñé->Ð޸ĔÕâ¸ö¹ý³ÌµÄ²Ù×÷,c ÓïÑÔÏÔÈ»²»ÊÇÃ÷ÖǵÄÑ¡Ôñ.
PythonÌṩÁ˼¸¸ölibpcapbind,http://monkey.org/~dugsong/pypcap/ÕâÀïÓÐ Ò»¸ö×î¼òµ¥µÄ¡£ÔÚwindowsƽ̨ÉÏ,ÄãÐèÒªÏÈ°²×°winpcap,Èç¹ûÄãÒѾ°²×°ÁËEthereal·Ç³£ºÃÓÃ
Ò»¸ö¹æ·¶µÄ×¥°ü¹ý³Ì
import pcap
import dpkt
pc=pcap.pcap() #×¢£¬²ÎÊý¿ÉΪÍø¿¨Ãû£¬Èçeth0
pc.setfilter('tcp port 80') #ÉèÖüàÌý¹ýÂËÆ÷
for ptime,pdata in pc: #ptimeΪÊÕµ½Ê±¼ä£¬pdataΪÊÕµ½Êý¾Ý
print ptime,pdata #...
¶Ô×¥µ½µÄÒÔÌ«ÍøV2Êý¾Ý°ü(raw packet)½øÐнâ°ü
p=dpkt.ethernet.Ethernet(pdata)
if p.data.__class__.__name__=='IP':
ip='%d.%d.%d.%d'%tuple(map(ord,list(p.data.dst)))
if p.data.data.__class__.__name__=='TCP':
if data.dport==80:
print p.data.data.data # by gashero
һЩÏÔʾ²ÎÊý
nrecv,ndrop,nifdrop=pc.stats()
·µ»ØµÄÔª×éÖУ¬µÚÒ»¸ö²ÎÊýΪ½ÓÊÕµ½µÄÊý¾Ý°ü£¬(by gashero)µÚ¶þ¸ö²ÎÊýΪ±»ºËÐĶªÆúµÄÊý¾Ý°ü¡£
Ïà¹ØÎĵµ£º
ÔÚparamikoÖÐʹÓÃÓû§ÃûºÍÃÜÂëͨ¹ýsftp´«ÊäÎļþ£¬²»Ê¹ÓÃkeyÎļþ¡£
import getpass
import select
import socket
import traceback
import paramiko
def putfile():
#import interactive
# setup logging
paramiko.util.log_to_file('demo.log')
username = username
hostname = hostname
......
Ò»¿ÅÓï·¨ÌÇ——×°ÊÎÆ÷
ÀíÂÛ²»È¥¹Ü£¬Ö»¹ÜÄÜ°ìÊ£º
1. ÎÒÒªÈÃÒ»¸öº¯ÊýÔÚÖ´ÐеÄʱºò£¬È¥×öһЩÊÂÇ飬±ÈÈ磬ÎÒÒª¿´¿´ÕâЩº¯ÊýÊDz»ÊÇÓÐdocstring£¬½«Õâ¸ö¹¦ÄÜÄóöÀ´£¬¶¨ÒåÒ»¸ö×°ÊÎÆ÷£º
def showmedoc(func):
if func.__doc__:
& ......
ÔÎÄÁ´½Ó
Ôø¾ÔÚÉîÈëdz³öjavaÖÐÎÄÎÊÌâ
ϵ
ÁÐÖÐÑо¿¹ýjavaµÄÖÐÎÄÎÊÌ⣬ÏÖÔÚÖÐÎÄÎÊÌâÒѾ²»ÔÙî¿°íÎÒÔÚjavaÊÀ½çÖÐÂþÓεĽŲ½ÁË¡£×î½ü£¬¶ÔPython²úÉúÁËŨºñµÄÐËȤ£¬ËÖªµÀ¸úÖÐÎÄÎÊÌâÕâ¸ö
ÀÏÅóÓÑÓÖÒ»´Î²»ÆÚ¶øÓö¡£¿´À´£¬ÔÚ´úÂëÊÀ½çÖУ¬ÖÐÎÄÎÊÌâ»áÔںܳ¤Ò»¶Îʱ¼äÀï¸úÎÒÃÇÐÎÓ°²»Àë¡£ÕâÒ²Äѹ֣¬Ë ......
Ò»¡¢
ΪÁËʹÓÃpython²Ù×÷´®¿Ú£¬Ê×ÏÈÐèÒªÏÂÔØÏà¹ØÄ£¿é:
1. pyserial (http://pyserial.wiki.sourceforge.net/pySerial)
2. pywin32 (http://sourceforge.net/projects/pywin32/)
¶þ¡¢
google “python ´®¿Ú ²Ù×÷”¹Ø¼ü×Ö£¬ÕÒµ½Ïà¹Øpython´úÂ룬
ÎÒÊÇ´Óhttp://currentlife.blog.sohu.com/53741351.htmlÒ³ÃæÉÏ ......
×ÛºÏÍøÉϲ鵽µÄÄÚÈÝ£¬Ð´µÄPython·¢ËÍÓʼþµÄÀà¡£¸½¼þ²¿·Ö»¹Ã»Ð´ºÃ£¬Ö÷ÒªÊǸ½¼þµÄÎļþÃû²¿·Ö»¹²»¶Ô¡£
#!/usr/bin/env python
# coding:utf-8
import email
import smtplib
class Mailer:
def __init__(self, smtp_host, smtp_user, smtp_passwd, smtp_port = 25) :
self.smtp_host = smtp_host
s ......