本文整理汇总了Python中tools.Tools类的典型用法代码示例。如果您正苦于以下问题:Python Tools类的具体用法?Python Tools怎么用?Python Tools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, verbose=0):
Tools.__init__(self)
"""
Well known port search tool
downloaded port list from
http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv
format of csv file
Service Name,Port Number,Transport Protocol,Description,Assignee,Contact,Registration Date,Modification Date,Reference,Service Code,Known Unauthorized Uses,Assignment Notes
ftp-data,20,tcp,File Transfer [Default Data],[Jon_Postel],[Jon_Postel],,,,,,
ftp-data,20,udp,File Transfer [Default Data],[Jon_Postel],[Jon_Postel],,,,,,
format of dictionary
[portnum_protocol]['name'] = name
[portnum_protocol]['description'] = description
Written by Peter Rogers
(C) Intelligent Planet 2013
"""
self.verbose = verbose
self.port_dict = {}
self.load_file = 'c:/ports.csv'
self.load()
示例2: trans_unicode_list2atom_gram_list
def trans_unicode_list2atom_gram_list(unicode_list) :
atom_list = []
idx = 0
unicode_num = len(unicode_list)
atom_unicode_list = []
while idx < unicode_num :
current_unicode = unicode_list[idx]
atom_unicode_list.append(current_unicode)
if not Tools.is_unicode_Lu_Ll_char(current_unicode) :
type_str = ""
if len(atom_unicode_list) > 1 :
type_str = ENG_TYPE
else :
type_str = Tools.get_unichr_type(atom_unicode_list[0])
#if type_str not in TYPES :
# TYPES.append(type_str)
# print type_str
# print WSAtomTranslator.trans_atom_gram_list2unicode_line(atom_unicode_list).encode("utf-8")
atom_list.append(WSAtom(atom_unicode_list , type_str))
atom_unicode_list = []
idx += 1
else :
if len(atom_unicode_list) > 0 :
# here it must be Lu or Ll Type char
atom_list.append(WSAtom(atom_unicode_list , ENG_TYPE ))
atom_unicode_list = []
return atom_list
示例3: __init__
def __init__(self):
Tools.__init__(self)
"""
Dictionary storage method
Use # followed by csv fields to define headers e.g. #host, ip, model, serial number
dictionary format example
dict_db[unique numeric key] = {}
dict_db[unique numeric key]['host'] = 'router-01'
dict_db[unique numeric key]['ip'] = '1.1.1.1'
dict_db[unique numeric key]['model'] = 'cisco 2811'
dictionary search index
search_db['router-01'] = {}
search_db['router-01']['tag'] = 'host'
search_db['router-01']['key'] = unique numeric key
search_db['1.1.1.1'] = {}
search_db['router-01']['tag'] = 'ip'
search_db['router-01']['key'] = unique numeric key
host entries appended to the self index list to provide a way to check for unique entries when adding data
data entries appended to the register if unique, if not the key number is added to the entry i.e. Cisco #123
Written by Peter Rogers
(C) Intelligent Planet 2013
"""
self.verbose = 1
self.space_size = 18
self.index = []
self.index_db = {}
self.register = {}
self.dict_db = {}
self.search_db = {}
示例4: __init__
def __init__(self, ip="", hostname="", out_dict="", auth_con=""):
Tools.__init__(self)
Vty.__init__(self, hostname, out_dict)
"""
interface to the the telnet library
"""
self.ip = ip
self.hostname = hostname.lower()
self.port = 23
self.auth_con = auth_con
self.user = ""
self.password = ""
self.path = os.getcwd() + "\\"
self.newline = "\r\n"
self.space = " "
self.verbose = 1
self.read_until_timeout = 2
self.timeout = 5
self.sleep = 0.1
# set the values for Cisco as default
self.login_text = "Username: "
self.password_text = "Password: "
self.exit_text = "q"
self.banner_list = ["\d+>", "--More--", "\d+#"]
self.more = "--More--"
示例5: __init__
def __init__(self):
Tools.__init__(self)
"""
MAC lookup to identify the vendor from the OUI of the mac address
Usage example:
>>> x = mac.Mac()
>>> x.id_mac('0000.0c07.ac03')
('Cisco', 'CISCO SYSTEMS')
Tested with Python ver 2.7.2 on Win7 & Win XP
(c) 2012 - 2014 Intelligent Planet Ltd
"""
if "\\" in os.getcwd():
self.path = os.getcwd() + "\\"
else:
self.path = os.getcwd() + "/"
self.mac_file = self.path + "mac"
self.mac_file_url = "http://anonsvn.wireshark.org/wireshark/trunk/manuf"
self.oui_list = []
try:
self.load_mac()
except:
self.create_mac_file() # download mac oui list and save to file as per the self.mac_file value
self.load_mac()
示例6: generate_stats
def generate_stats(self):
spkwhole = SpeakerStatistics("whole")
self.statistics["whole"]=spkwhole
for spc in self.get_speech_list():
self.statistics["whole"].add_speech(spc.get_length())
#check if the speakers all have the dot so we don't get the same speaker doubled.
if "." in spc.get_speaker():
speaker = spc.get_speaker()
else:
speaker = spc.get_speaker() + "."
if(speaker not in self.statistics):
spkstat = SpeakerStatistics(speaker)
spkstat.add_speech(spc.get_length())
self.statistics[speaker] = spkstat
else:
spkstat = self.statistics[speaker]
spkstat.add_speech(spc.get_length())
#the medium and mean count for the whole text
for key,value in self.statistics.items():
if(key!="whole"):
self.counts.append(value.get_count())
tools = Tools()
self.median_count = tools.calc_median(self.counts)
self.average_count = tools.calc_average(tools.calc_sum(self.counts),len(self.counts))
示例7: __init__
def __init__(self, verbose=0):
Tools.__init__(self)
"""
Well known port search tool
downloaded port list from
http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv
format of csv file
Service Name,Port Number,Transport Protocol,Description,Assignee,Contact,Registration Date,Modification Date,Reference,Service Code,Known Unauthorized Uses,Assignment Notes
ftp-data,20,tcp,File Transfer [Default Data],[Jon_Postel],[Jon_Postel],,,,,,
ftp-data,20,udp,File Transfer [Default Data],[Jon_Postel],[Jon_Postel],,,,,,
format of dictionary
[portnum_protocol]['name'] = name
[portnum_protocol]['description'] = description
Tested with Python ver 2.7.2 on Win7 & Win XP
(c) 2012 - 2014 Intelligent Planet Ltd
"""
self.verbose = verbose
self.port_dict = {}
self.path = os.getcwd() + '\\'
self.load_file = self.path + 'ports.csv'
self.load()
示例8: generate_stats
def generate_stats(self):
word_count = 0
pause = False
spkwhole = SpeakerStatistics("whole")
self.statistics["whole"]=spkwhole
for spc in self.get_speech_list():
self.statistics["whole"].add_speech(spc.get_length())
#five hundred span and 10 pause
for words in spc.get_words_array():
word_count = word_count + 1
if (word_count % 500 == 0):
word_count = 0
pause = True
if(word_count == 10 and pause == True):
pause = False
word_count = 0
if "." in spc.get_speaker():
speaker = spc.get_speaker()
else:
speaker = spc.get_speaker() + "."
if(pause != True):
if(speaker not in self.statistics):
spkstat = SpeakerStatistics(speaker)
spkstat.add_speech(spc.get_length())
self.statistics[speaker] = spkstat
else:
spkstat = self.statistics[speaker]
spkstat.add_speech(spc.get_length())
#the medium and mean count for the whole text
for key,value in self.statistics.items():
if(key!="whole"):
self.counts.append(value.get_count())
tools = Tools()
self.median_count = tools.calc_median(self.counts)
self.average_count = tools.calc_average(tools.calc_sum(self.counts),len(self.counts))
示例9: __init__
def __init__(self):
Tools.__init__(self)
"""
Cisco show command parse tool and Db viewer
sh ip int brief format is:
['Interface', 'IP-Address', 'OK?', 'Method', 'Status', 'Protocol']
Dict format example is:
self.dict_db[self.hostname] = {}
self.dict_db[self.hostname][command] = {}
self.dict_db[self.hostname][command][interface] = {}
self.dict_db[self.hostname][command][interface][ip-address] = value
"""
self.verbose = 0
### set the path to the log and db files ###
try: self.path = 'H:/crt/sessions/'
except: self.path = 'C:/Program Files/SecureCRT/Sessions/'
self.load_file = self.path + 'log'
self.db_file = self.path + 'show_db'
self.load_dict()
self.classify_dict = {'sh ip int brief': ['Interface', 'IP-Address']}
示例10: __init__
def __init__(self, verbose=0):
Tools.__init__(self)
"""
X.25 Routing parser for cisco routers
format of router output
r01#sh x25 rou | inc dest|0/0
1 dest ^(0000111111).* xot 10.11.12.13
2 dest ^(0000111112).* xot 10.11.12.14
format of dictionary
key = auto incrementing integer
[key]['router'] = hostname
[key]['route_id'] = route_num
[key]['x25_route'] = destination
[key]['ip_address'] = ip_add
[key]['match'] = match
Written by Peter Rogers
(C) Intelligent Planet 2013
"""
self.verbose = verbose
self.x25_dict = {}
self.route_list = []
self.config = []
self.config_list = []
self.load_file = 'c:/x25'
self.out_file = 'c:/x25_out'
self.display_heading = '\n # X.25 route IPaddress match router \n'
self.load()
示例11: __init__
def __init__(self, verbose=0):
Tools.__init__(self)
"""
Assigned Internet Protocol Numbers search tool
downloaded port list from
http://www.iana.org/assignments/protocol-numbers/protocol-numbers-1.csv
format of csv file
Decimal,Keyword,Protocol,Reference
0,HOPOPT,IPv6 Hop-by-Hop Option,[RFC2460]
1,ICMP,Internet Control Message,[RFC792]
format of dictionary
[Protocol_num]['name'] = name
[Protocol_num]['description'] = description
Tested with Python ver 2.7.2 on Win7 & Win XP
(c) 2012 - 2014 Intelligent Planet Ltd
"""
self.verbose = verbose
self.protocol_dict = {}
self.path = os.getcwd() + '\\'
self.load_file = self.path + 'protocols.csv'
self.load()
示例12: __init__
def __init__(self, verbose=0):
Tools.__init__(self)
"""
Cisco IP Cache Flow parse tool and Db viewer
SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts
Fa0/1 10.155.20.122 Se0/0:0.101* 10.7.10.124 01 0000 0000 219
Fa0/1 10.155.20.123 Se0/0:0.101* 10.7.10.124 01 0000 0000 219
Fa0/0 10.182.137.8 Se0/0:0.101* 62.239.26.81 06 C508 07D0 2
[flow_id] = {}
[flow_id][SrcIPaddress]
[flow_id][DstIPaddress]
[flow_id][SrcIf]
[flow_id][DstIf]
[flow_id][Protocol]
[flow_id][SrcPort]
[flow_id][DstPort]
[flow_id][Packets]
Written by Peter Rogers
(C) Intelligent Planet 2013
"""
self.load_file = 'c:/cache_load'
self.limit = 200
self.verbose = verbose
self.cache_dict = {}
self.display_heading = '\nSrcIPaddress SrcPort DstIPaddress DstPort Protocol Packets\n'
示例13: __init__
def __init__(self, ip='192.168.1.10', name='test', port=23):
Tools.__init__(self)
"""
Network tool kit
Tested on Win XP with Python 2.7
(c) 2012, 2013 Intelligent Planet Ltd
"""
self.init_net(ip, name, port)
self.timeout = 0.2
self.sleep = 0.1
self.verbose = 1
self.buffers = 1024
self.error = 'fail'
self.web_proxy = '172.19.193.122'
self.port_list = [20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 161, 162, 179, 443, 520, 1719, 1720, 1985, 1998, 2000, 2427, 3389, 5060, 5900, 8080]
#FTP(20, 21), SSH(22), Telnet(23), SMTP(25), DNS(53), DHCP(67, 68), TFTP(69), HTTP(80), SNMP(161, 162), BGP(179), HTTPS(443), RIP(520)
#H.323(1719. 1720), HSRP(1985), XOT(1998), SCCP(2000), MGCP(2427), RDP(3389), SIP(5060), VNC(5900)
self.http_get = 'GET /index.html HTTP/1.1 \r\n'
self.http_host = 'Host: %s \r\n\r\n'
示例14: get_fix_stage
def get_fix_stage(self):
tool = Tools()
fDs = self.root.findall(".//"+self.prefix+"stage")
result = []
for f in fDs:
if ("{http://www.germanistik.uni-wuerzburg.de/lehrstuehle/computerphilologie/dramenanalyse}fixed-stage" in f.attrib):
result.append(tool.unicode_safe(f.text))
#print tool.unicode_safe(f.text)
return result
示例15: to_work
def to_work(self) :
print('Moving to working space')
renamed = os.path.join(self.work_new, '#rename')
for name in os.listdir(self.dl_tmp) :
src = os.path.join(self.dl_tmp, name)
if name[0] != '#' and Tools.is_archive(src) :
tool = Tools(src, os.path.join(renamed, name))
tool.move()
print('-'*150)