示例#1
0
import json
import re

from common import Browser, getConfig, getUserPass, getSecurityQuestions

username, password = getUserPass('citibank.com')
br = Browser.make()

u1 = 'https://online.citibank.com/US/JPS/portal/Home.do'

r1 = br.open(u1)

print br.geturl()

print [x.attrs for x in br.forms()]

br.select_form(nr=2)

br['username'] = username
br['password'] = password 

br.submit()

r2 = br.open('https://online.citibank.com/US/REST/accountsPanel/getCustomerAccounts.jws?ttc=742', data={})
d = json.loads(r2.read())

kill_tags = re.compile(r'<.*?>')
kill_double_space = re.compile(r'\s+')
def format_label(label):
    label = kill_tags.sub('',label)
    label = label.replace(':','')
示例#2
0
def main():
    site = 'barclaycardus.com'
    username, password = getUserPass(site)
    qa = getSecurityQuestions(site)
    br = Browser.make()

    u1 = 'https://www.barclaycardus.com/'
    r1 = br.open(u1)
    print '1'

    # form infos
    # print [x.attrs for x in br.forms()]

    # # controls
    # print [x.attrs for x in f.controls for f in br.forms()]
    print br.geturl()

    br.select_form(nr=0)
    br['userId'] = username
    r2 = br.submit()
    print '2'
    r2_text = r2.read()

    # hmmm fix up some shitty JS causing parse error
    r2_text = r2_text.replace('<!")','')
    r2.set_data(r2_text)
    br.set_response(r2)

    br.select_form(nr=0)
    br.set_all_readonly(False)

    if 'Enter Your Password' not in r2_text:
        #register PC
        #set remember device, meh?
        br.form.set_value(['true'], name='registerDevice')
        soup = BeautifulSoup(r2_text)
        questions = [x.text for x in soup.findAll('span', {'class': 'formLabel'}) if 'username' not in x.text.lower() and 'register' not in x.text.lower()]
        answers = ['answer1', 'answer2']

        for question, answer in zip(questions,answers):
            if question in qa:
                print 'using config answer for security question'
                br[answer] = qa[question]
                print '%s : %s' % (question , qa[question])
            else:
                print 'MISSING config answer for security question'
                br[answer] = raw_input('%s: ' % question)

        r3 = br.submit()
        print '3'
        r3_text = r3.read()
        # import IPython; IPython.embed()

        # hmmm fix up some shitty JS causing parse error
        r3_text = r3_text.replace('<!")','')
        r3.set_data(r3_text)
        br.set_response(r3)

    print '4'
    br.select_form(nr=0)
    br['password'] = password

    r4 = br.submit()
    r4_text = r4.read()

    soup = BeautifulSoup(r4_text)
    money = [x.text for x in soup.find(id='row1a').findAll('h1', {'class': None})]

    accountData = {
        'current_balance': money[0],
        'statement_balance': money[1],
        'available_credit': money[2],
        'revolving_credit_line': money[3],
    }
    accountName = [x.text for x in soup.findAll('h1', {'class': 'cardName'})][0]
    accountId = re.findall(r'Card ending in (\d{4})', r4_text, re.IGNORECASE)[0]

    print accountName
    print accountId
    print accountData
示例#3
0
import mechanize
import cookielib
import json
from BeautifulSoup import BeautifulSoup

from common import Browser, getConfig, getUserPass, getSecurityQuestions

site = 'hsabank.com'
username, password = getUserPass(site)
qa = getSecurityQuestions(site)
br = Browser.make()

u1 = 'https://secure.hsabank.com/ibanking3/login.aspx'

r1 = br.open(u1)
r1_text = r1.read()

#are we at the correct url?
sanity_check = "Log in to Your Account" in r1_text

br.select_form(nr=0)
br['ctl00$IbankingPlaceHolder$txtUserId'] = username
br['ctl00_IbankingPlaceHolder_txtUserId_text'] = username
#readonly forms
br.set_all_readonly(False)
br['ctl00_IbankingPlaceHolder_txtUserId_ClientState'] = '{"enabled":true,"emptyMessage":"Enter User Name"}'
br['pm_fp'] = """version%3D1%26pm%5Ffpua%3Dmozilla%2F5%2E0%20%28macintosh%3B%20intel%20mac%20os%20x%2010%5F8%5F3%29%20applewebkit%2F537%2E31%20%28khtml%2C%20like%20gecko%29%20chrome%2F26%2E0%2E1410%2E43%20safari%2F537%2E31%7C5%2E0%20%28Macintosh%3B%20Intel%20Mac%20OS%20X%2010%5F8%5F3%29%20AppleWebKit%2F537%2E31%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F26%2E0%2E1410%2E43%20Safari%2F537%2E31%7CMacIntel%26pm%5Ffpsc%3D24%7C1680%7C1050%7C1028%26pm%5Ffpsw%3D%26pm%5Ffptz%3D%2D8%26pm%5Ffpln%3Dlang%3Den%2DUS%7Csyslang%3D%7Cuserlang%3D%26pm%5Ffpjv%3D1%26pm%5Ffpco%3D1"""

r2 = br.submit()
r2_text = r2.read()
# import IPython; IPython.embed()