Beispiel #1
0
def submit(filename):
    session = requests.Session()
    session.headers.clear()
    session.cookies.update(login.get_session())

    contest, letter = extract_contest_letter(filename)
    html = BeautifulSoup(
        session.get(config.URL_SUBMIT_FORM.format(contest=contest)).text,
        'html.parser')
    token = html.find('input', {'name': 'csrf_token'})['value']

    f = open(filename)
    data = {
        'csrf_token': token,
        'action': 'submitSolutionFormSubmitted',
        'submittedProblemIndex': letter,
        'programTypeId': 1,
        'source': f.read(),
        'tabSize': 4,
        'sourceFile': '',
        '_tta': login.get_tta(session.cookies.get('39ce7'))
    }
    f.close()

    # print(json.dumps(data, indent=2, ensure_ascii=False))
    res = session.post(config.URL_SUBMIT_FORM.format(contest=contest),
                       data=data,
                       params={'csrf_token': token})
    print(res.status_code)
    print(res.text)
Beispiel #2
0
def send_hnap_dummy(port, hnap, data='', header='', need_login=False):
    headers = requests.utils.default_headers()
    headers["Origin"] = "http://" + TARGET
    headers["SOAPACTION"] = '"http://purenetworks.com{}"'.format(hnap)
    headers["Accept"] = "text/xml"
    headers["Referer"] = "http://" + TARGET + "/info/Login.html"
    cookies = {}
    req = requests
    if need_login:
        global LOGIN_TYPE, SESSION
        if not SESSION:
            LOGIN_TYPE, SESSION = login.get_session(BRAND, TARGET)
        if LOGIN_TYPE == 'dlink_hnap':
            cookies = SESSION
            headers["HNAP_AUTH"] = login.HNAP_AUTH(hnap.split('/')[-1], login.PRIVATE_KEY)
        else:
            req = SESSION
    headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36"

    headers["Content-Type"] = "text/xml; charset=UTF-8"
    headers["X-Requested-With"] = "XMLHttpRequest"

    try:
        r = req.post('http://{}:{}/HNAP1/'.format(TARGET, port), headers=headers, data=data.encode(), cookies=cookies, timeout=10.0)
        print("[O]send_hanp_dummy_headers: "+str(r.request.headers))
        print("[O]send_hanp_dummy_data"+str(data.encode()))
        data = r.text.encode()
        if data[9:12] == b'401':
            return data, 401
        else:
            return data, r.status_code
    except:
        return b'', 503
Beispiel #3
0
def send_http_dummy(port,
                    uri,
                    method,
                    headers={},
                    params={},
                    need_login=False):
    global SESSION, LOGIN_TYPE
    headers['Content-Type'] = 'text/xml'
    headers[
        'User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko'
    req = requests
    if need_login:
        if not SESSION:
            LOGIN_TYPE, SESSION = login.get_session(BRAND, TARGET)
        req = SESSION
    headers['Referer'] = 'http://{}/'.format(TARGET)
    try:
        if method == 'get':
            r = req.get('http://{}:{}{}'.format(TARGET, port, uri),
                        headers=headers,
                        params=params,
                        timeout=10.0)
        elif method == 'post':
            r = req.post('http://{}:{}{}'.format(TARGET, port, uri),
                         headers=headers,
                         data=params,
                         timeout=10.0)
        else:
            return b'', 503
    except:
        return b'', 503

    data = r.text.encode()

    # leave this field blank = leave blank on belkin
    # user_page.asp on dlink
    # login.htm, login.ccp for trendnet
    if data.find(b'leave this field blank') != -1 or data.find(
            b'user_page.asp') != -1 or data.find(
                b'location.replace(\'login.htm\')') != -1 or data.find(
                    b'login.ccp') != -1:
        if need_login == True and LOGIN_TYPE != 'unknown':
            SESSION = None
            return send_http_dummy(port, uri, method, headers, params, True)
        else:
            return data, 401
    else:
        return data, r.status_code
Beispiel #4
0
def main(contest):
    session = requests.Session()
    session.headers.clear()
    session.cookies.update(login.get_session())

    html = BeautifulSoup(session.get(config.URL_SUBMISIONS.format(contest=contest)).text, 'html.parser')
    for table in html.find_all('table', class_='status-frame-datatable'):
        for tr in table.find_all('tr'):
            if tr.get('data-submission-id', None):
                sub_id = tr['data-submission-id']

                tds = tr.find_all('td')
                sub_date = tds[1].text.strip()
                sub_problem = tds[3].text.strip()
                sub_lang = tds[4].text.strip()
                sub_veredict = tds[5].text.strip()
                sub_time = tds[6].text.strip()
                sub_memory = tds[7].text.strip()
                a = "{:8}|{:19}|{:50}|{:10}|{:30}|{:6}|{:8}".format(sub_id, sub_date, sub_problem, sub_lang, sub_veredict, sub_time, sub_memory)
                print(a)
Beispiel #5
0
def session():
    login_account = os.getenv('WEIBO_ACCOUNT')
    login_pass = os.getenv('WEIBO_PASS')
    s = get_session(login_account, login_pass)
    assert s is not None
    return s
Beispiel #6
0
        'sec-ch-ua-mobile': '?0',
        'Sec-Fetch-Dest': 'document',
        'Sec-Fetch-Mode': 'navigate',
        'Sec-Fetch-Site': 'same-origin',
        'Upgrade-Insecure-Requests': '1',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/53',
    }

    url = "https://swmaestro.org/sw/mypage/mentoLec/list.do?menuNo=200046"
    r = requests.get(url=url, headers=head)
    soup = BeautifulSoup(r.content, 'html.parser')
    result = soup.select('#contentsList > div > div > div > table > tbody > tr')

    # 로그인이 안된 경우
    if not result:
        (wcs_bt, JSESSIONID) = login.get_session()
        continue

    for target in result:
        t = target.select('td.tit > div.rel > a')
        title = t[0].get_text()
        link = t[0]['href']
        index = 37
        num = ""

        # 게시글의 번호를 파싱
        while True:
            if link[index] == '&':
                break
            else:
                num += link[index]
Beispiel #7
0
def login_task(name, password):
    get_session(name, password)
Beispiel #8
0
if __name__ == '__main__':


    with open("user.txt", 'r') as f:
        str = f.read()

    _str = str.split(',')

    uname = _str[0]
    pwrod = _str[-1]

    print(uname)
    print(pwrod)

    sess = login.get_session()
    sess.headers['Referer'] = 'https://api.weibo.com/oauth2/authorize?response_type=code' \
                              '&client_id=4083586895&redirect_uri=http%3A%2F%2Fwww.xunyee.cn' \
                              '%2Fopenid%2Fsina%2Ftoken.html&state=a%3A0%3A%7B%7D&scope=email' \
                              '%2Cdirect_messages_write%2Cdirect_messages_read%2Cinvitation_write' \
                              '%2Cfriendships_groups_read%2Cfriendships_groups_write%2Cstatuses_to_me_read'


    # 登录
    sess = login.login_post(uname, pwrod, sess)

    urls = spider.find_url(sess)

    i=0
    # 访问链接
    while(True):
Beispiel #9
0
import pickle
from keras.models import load_model
import time

MODEL_FILENAME = "captcha_model.hdf5"
MODEL_LABELS_FILENAME = "model_labels.dat"

if __name__ == '__main__':

    #url = "https://weibo.com/6456846508/GqnV3s4FL?from=page_1005056456846508_profile&wvr=6&mod=weibotime&type=comment"
    url = "https://weibo.com/5473085545/Gqn21cJwJ?from=page_1005055473085545_profile&wvr=6&mod=weibotime&type=comment#_rnd1531839476120"

    name1 = "18475547852"
    pw1 = "Qarsy4646"

    sess1 = login.get_session()

    with open(MODEL_LABELS_FILENAME, "rb") as f:
        lb = pickle.load(f)

    model = load_model(MODEL_FILENAME)

    login.login_post(name1, pw1, sess1, model, lb)

    print(sess1.headers)
    print(sess1.cookies)
    print(sess1.adapters)

    #code1 = 0

    #mid1 = sender.get_mid(url, sess1)