Пример #1
0
def simple():
    if not session:
        session['count'] = 0
    if not session.get('mass'):
        session['mass'] = values()

    pr1 = session['mass']['rows'][0][1]
    pc1 = session['mass']['cols'][0][1]
    pr2 = session['mass']['rows'][1][1]
    pc2 = session['mass']['cols'][1][1]

    if request.method == "POST":
        answer = request.form.get('answer').strip().rstrip().split()
        try:
            user_pr1 = str(answer[0] + answer[1])
            user_pr2 = str(answer[2] + answer[3])
            user_pc1 = str(answer[0] + answer[2])
            user_pc2 = str(answer[1] + answer[3])
        except:
            session.clear()
            return render_template(
                "index.html",
                message="Not all fields are filled, try again",
                button='<a href="/" class="button">New Game</a>')
        if f(pc1, user_pc1) and f(pc2, user_pc2) and f(pr2, user_pr2) and f(
                pr1, user_pr1):
            session['count'] = int(session['count']) + 1
            session['mass'].clear()
            return render_template(
                'index.html',
                message="correct",
                count=int(session['count']),
                button='<a href="/" class="button">Next</a>')
        else:
            session.clear()
            return render_template(
                "index.html",
                message="Wrong! Try again.",
                button='<a href="/" class="button">New Game</a>')
    count = int(session['count'])
    if count == 200:
        return render_template_string("yetiCTF{[c]+o{2}[l]+_R3}")
    return render_template("index.html",
                           count=count,
                           pr1=pr1,
                           pr2=pr2,
                           pc1=pc1,
                           pc2=pc2)
Пример #2
0
def addresscompare(a1,a2):
	a1numbers=re.f(r'\d+', a1)
	a2numbers=re.findall(r'\d+', a2)

	if (len(a1numbers) > 0 and len(a2numbers) > 0):
		if (a1numbers[0]!=a2numbers[0]):
			return False
	if (fuzz.token_sort_ratio(a1,a2) > match_percent):
		return True
	else:
		return False
Пример #3
0
def cekpay():
    global d
    e = 0
    format = ['[h]', '[m]', '[cr]', '[lf]', '[crlf]']
    fmt = f(r'(\[.*?\])', d['pay'])
    for i in fmt:
        if i not in format:
            tamp('\rm==> \rk' + i + ' \rmformat tidak di dukung....')
            e = 1
    if e == 1:
        tamp('\rm[!] payload error....')
        tamp('\rk' + '#' * 65)
        exit(1)
Пример #4
0
"""Demonstrate high quality docstrings.

Repeatedly search for and extract substrings that match a particular pattern.
Construct a well-formed regular expression to match and extract the link values
"""

from urllib import urlopen as uo
from re import findall as f

default = 'http://www.py4inf.com/book.html'
url = raw_input('Enter URL: ') or default
html = uo(url).read()
links = f('href="(http://.*?)"', html)
for link in links:
    print link
Пример #5
0
import urllib.request as rs
from re import findall as f

url = "https://www.britishairways.com/en-gb/information/help-and-contacts/contact-us"
# 0344 493 0787
con = rs.urlopen(url)
rd = con.read()
strval = rd.decode()
pdata = f("\d{4} \d{3} \d{4}", strval)
for d in pdata:
    print(d)
Пример #6
0
chk=0
###사진저장하기
import urllib.request
###사진바이너리형식으로
import base64

photo=[]


###
###사진경로
l = soup.find_all("dt",class_='image')
for _ in l:
    _=str(_)
    _=f(r'\w+.\w+.\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+/\w+-\w+-\w+-\w+-\w+.jpg',_)
    _=str(_)[2:-2]
    #print('https://'+_)
    _='https://'+_

   
    ###사진저장하기
    ur = _
    savename = product[2*chk+chk]+".png"
    try:
       urllib.request.urlretrieve(ur, savename)
       print("saved")
       ###사진파일 바이너리 파일로 전환하기
       with open("/home/nova/bigdata/python/today/%s"%savename, "rb") as imageFile:
          bi = base64.b64encode(imageFile.read())
          print(bi)
Пример #7
0
"""
Tired of summing up numbers by hand for your night job as an accountant, you are
writing your own calculator that allows you to type in a lot of numbers and sums
them for you. Naturally, your calculator begins with a sum of 0.

Every time you reach an input value of 0 output the sum so far, and reset the
sum to 0.
"""

#import sys, re
#import sys as s, re as r
from sys import stdin as s
from re import findall as f, split as sp

# Original
#print '\n'.join([str(ans) for ans in [sum(x) for x in [map(int, v) for v in [line.split() for line in re.findall('.*?0', ' '.join(re.split('\\s', ' '.join(sys.stdin.readlines()))))]]]])

# Better
#print '\n'.join([str(sum(map(int, line.split()))) for line in re.findall('.*?0', ' '.join(re.split('\\s', sys.stdin.read())))])

# Betterer
#print '\n'.join([str(sum(map(int, line.split()))) for line in r.findall('.*?0', ' '.join(s.stdin.read().split('\\s')))])

# Cheat on those imports!
print '\n'.join([str(sum(map(int, l.split()))) for l in f('.*?0', ' '.join(sp('\\s', s.read())))])
Пример #8
0
"""
Tired of summing up numbers by hand for your night job as an accountant, you are
writing your own calculator that allows you to type in a lot of numbers and sums
them for you. Naturally, your calculator begins with a sum of 0.

Every time you reach an input value of 0 output the sum so far, and reset the
sum to 0.
"""

#import sys, re
#import sys as s, re as r
from sys import stdin as s
from re import findall as f, split as sp

# Original
#print '\n'.join([str(ans) for ans in [sum(x) for x in [map(int, v) for v in [line.split() for line in re.findall('.*?0', ' '.join(re.split('\\s', ' '.join(sys.stdin.readlines()))))]]]])

# Better
#print '\n'.join([str(sum(map(int, line.split()))) for line in re.findall('.*?0', ' '.join(re.split('\\s', sys.stdin.read())))])

# Betterer
#print '\n'.join([str(sum(map(int, line.split()))) for line in r.findall('.*?0', ' '.join(s.stdin.read().split('\\s')))])

# Cheat on those imports!
print '\n'.join([
    str(sum(map(int, l.split())))
    for l in f('.*?0', ' '.join(sp('\\s', s.read())))
])
Пример #9
0
 def get_string_number_cell(stroka):
     return int(f('(\d+)N',
                  stroka)[0]), int(f('N(\d+)X', stroka)[0]), int(
                      f('X(\d+)Y',
                        stroka)[0]), int(f('Y(\d+)', stroka)[0])