Ejemplo n.º 1
0
 def getIP(self):
     try:
         res=urllib2.urlopen('http://whois.pconline.com.cn/ipJson.jsp',timeout=2000)
     except:
         return None
     if res.getcode()!=200:
         return None
     re=res.read().decode('gbk').encode('utf8')
     res.close()
     re=re[re.rfind('{'):re.find('}')+1]
     return json.loads(re)
Ejemplo n.º 2
0
def getIP():
    try:
        res=urllib2.urlopen('http://whois.pconline.com.cn/ipJson.jsp',timeout=2)
    except:
        return None
    if res.getcode()!=200:
        return None
    re=res.read().decode('gbk').encode('utf8')
    res.close()
    re=re[re.rfind('{'):re.find('}')+1]
    return json.loads(re)
Ejemplo n.º 3
0
def check_pcre_compile(re):
    options = []
    if len(re) and re[0] == '/':
        optp = re.rfind('/')
        if optp > 0:
            options = list(re[optp + 1:])
            re = re[1:optp]
    opts = 0
    for opt in options:
        if opt in PCRE_OPT:
            opts |= PCRE_OPT[opt]
    try:
        sniffles.pcrecomp.compile(re, opts)
    except:
        return False
    return True
Ejemplo n.º 4
0
def check_pcre_compile(re):
    options = []
    if len(re) and re[0] == '/':
        optp = re.rfind('/')
        if optp > 0:
            options = list(re[optp + 1:])
            re = re[1:optp]
    opts = 0
    for opt in options:
        if opt in PCRE_OPT:
            opts |= PCRE_OPT[opt]
    try:
        sniffles.pcrecomp.compile(re, opts)
    except:
        return False
    return True
Ejemplo n.º 5
0
    def _conditionalize(self, args):
        part = args[0]

        next = []
        segments = args[1:]
        for segment in segments:
            next.append(self._conditionalize(segment))
        next = ', '.join(next)
        if next:
            next = ''.join([', ', next]);

        conditions = []
        for name in rfind('[:*](\\w+)', part):
            conditions.append(''.join(['"', name, '" in parameters']))
        if conditions:
            conditions = ' and '.join(conditions)
        else:
            conditions = 'true'

        return ''.join(['((', conditions, ') and "".join(["', rsub('[:*](\\w+)', '", parameters["\\1"], "', part), '"', next, ']) or "")'])