示例#1
0
from tuby.core import TubyStream
try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    TUBY = TubyStream()

import os
from tuby.core import modpath, readfile, _mkmodfn

for dirpath, dirnames, filenames in os.walk(modpath):
    for fn in filenames:
        if not fn.endswith('.py'):
            continue
        if fn.startswith('tb_module_manifest'):  # infinite loop
            continue
        module = compile(''.join(readfile(_mkmodfn(fn[:-3]))), '<string>',
                         'exec')
        scope = {'TUBY': TubyStream()}
        try:
            exec module in scope
        except Exception:
            pass

        def getvalue(key):
            if key not in scope['TUBY']:
                return 'na'
            return scope['TUBY'][key].encode('utf8')

        version = getvalue('__version__')
        author = getvalue('__author__')
        email = getvalue('__email__')
示例#2
0
try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    from tuby.core import TubyStream
    TUBY = TubyStream()

import sys
import struct
import socket


def ip2int(addr):
    return int(struct.unpack("!I", socket.inet_aton(addr))[0])


def int2ip(addr):
    return socket.inet_ntoa(struct.pack("!I", addr))


def genlist(src):
    iptxt, cidr = [p.strip() for p in src.split('/')]
    ipnum = ip2int(iptxt)
    rest = ~((1 << (32 - int(cidr))) - 1)
    minr = ipnum & rest
    maxr = minr ^ ~rest
    for i in range(minr, maxr):
        yield int2ip(i)


def helper(ip):
    for ip in genlist(ip):
示例#3
0
文件: word.py 项目: t0z/tuby
import os
from os.path import expanduser, abspath
from multiprocessing import Pool, Queue, Process, Event, Value
from multiprocessing.queues import Empty
from random import randint
from time import sleep, time

try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    from tuby.core import TubyStream
    TUBY = TubyStream()

DEBUG = True
lf = '\n'
__numproc_resolve__ = 3


def clean_word(word):
    pos = len(word) - 1
    if word[pos] in [':', '=']:
        word = word[0:pos]
        pos -= 1
    for o, e in (('[', ']'), ('(', ')'), ('{', '}'), ('<', '>')):
        if word[0] == o and word[pos] == e:
            word = word[1, pos]
            pos -= 1
    return word.strip()


def readfile(path, filename):
示例#4
0
try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    from tuby.core import TubyStream
    TUBY = TubyStream()

import json
packet = None
allip = {}
for data in TUBY.stdin:
    try:
        packet = json.loads(data)
    except Exception as e:
        TUBY.stderr('Exception: %s\n' % e)
        continue
    ip = None
    port = None
    for addr in ['s_addr', 'd_addr']:
        ip = packet[addr]
        port = packet['%s_port' % addr[0]]
        if ip in allip:
            allip[ip] = allip[ip] + 1
        else:
            allip[ip] = 1
            TUBY.stdout.write('[found.ip/%s] %s:%s\n' % (addr,
                                                        packet[addr], port))

#     TUBY.stdout.write('%s:%s %s:%s %s\n' % (packet['s_addr'],
#                                             packet['s_port'],
#                                             packet['d_addr'],
#                                             packet['d_port'],
示例#5
0
try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    from tuby.core import TubyStream
    TUBY = TubyStream()

import json
packet = None
allip = {}
for data in TUBY.stdin:
    try:
        packet = json.loads(data)
    except Exception as e:
        TUBY.stderr('Exception: %s\n' % e)
        continue
    ip = None
    port = None
    for addr in ['s_addr', 'd_addr']:
        ip = packet[addr]
        port = packet['%s_port' % addr[0]]
        if ip in allip:
            allip[ip] = allip[ip] + 1
        else:
            allip[ip] = 1
            TUBY.stdout.write('[found.ip/%s] %s:%s\n' %
                              (addr, packet[addr], port))

#     TUBY.stdout.write('%s:%s %s:%s %s\n' % (packet['s_addr'],
#                                             packet['s_port'],
#                                             packet['d_addr'],
#                                             packet['d_port'],
示例#6
0
文件: word.py 项目: t0z/tuby
import os
from os.path import expanduser, abspath
from multiprocessing import Pool, Queue, Process, Event, Value
from multiprocessing.queues import Empty
from random import randint
from time import sleep, time

try:
    TUBY = TUBY  # @UndefinedVariable
except Exception:
    from tuby.core import TubyStream
    TUBY = TubyStream()


DEBUG = True
lf = '\n'
__numproc_resolve__ = 3


def clean_word(word):
    pos = len(word) - 1
    if word[pos] in [':', '=']:
        word = word[0:pos]
        pos -= 1
    for o, e in (('[', ']'), ('(', ')'), ('{', '}'), ('<', '>')):
        if word[0] == o and word[pos] == e:
            word = word[1, pos]
            pos -= 1
    return word.strip()