コード例 #1
0
ファイル: client.py プロジェクト: MRPanyu/pywayout
 def handle(self):
     random.seed()
     pos = random.randrange(len(Secret.key))
     self.secret_in = Secret(pos)
     self.secret_out = Secret(pos)
     enc = self.secret_in.enc
     dec = self.secret_out.dec
     remote = None
     try:
         sock = self.connection
         remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         remote.connect((server_host, server_port))
         print 'connected to server: ' + server_host + ":" + str(
             server_port)
         # send the random pos as first two bytes
         remote.send(struct.pack('>H', pos))
         # proxy the in/out streams
         fdset = [sock, remote]
         while True:
             r, w, e = select.select(fdset, [], [])
             if sock in r:
                 if remote.send(enc(sock.recv(4096))) <= 0: break
             if remote in r:
                 if sock.send(dec(remote.recv(4096))) <= 0: break
     except socket.error:
         pass
     except IndexError:
         pass
     finally:
         if remote != None: remote.close()
コード例 #2
0
ファイル: api.py プロジェクト: evansims/riverid-python
    def changepassword(self, email, oldpassword, newpassword):
        Validator.email(email)
        Validator.password(newpassword)

        if self.user.get(email)['password'] != Secret.hash(oldpassword, SALT):
            raise RiverException(_('The old password is incorrect for this user.'))

        self.user.update(email, password=Secret.hash(newpassword, SALT))
コード例 #3
0
 def open_connection(self):
     self.engine = db.create_engine(Secret().db_address, pool_recycle=3600)
     self.metadata = db.MetaData()
     self.connection = self.engine.connect()
     self.table_name = Secret().table_name
     self.table = db.Table(self.table_name,
                           self.metadata,
                           autoload=True,
                           autoload_with=self.engine)
コード例 #4
0
 def __init__(self):
     sr = Secret()
     self.con = mysql.connector.connect(host='localhost',
                                        user='******',
                                        password=sr.get_secret_key(),
                                        database=sr.get_database())
     query = "create table if not exists accounts(user_name varchar(200), user_email varchar(200), app_name varchar(100), url varchar(300), password varchar(100))"
     cur = self.con.cursor()
     cur.execute(query)
     self.con.commit()
コード例 #5
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def changepassword(self, email, oldpassword, newpassword):
        Validator.email(email)
        Validator.password(oldpassword)
        Validator.password(newpassword)

        if self.user.get(email)['password'] != Secret.hash(oldpassword, SALT):
            raise RiverException(
                _('The old password is incorrect for this user.'))

        self.user.update(email, password=Secret.hash(newpassword, SALT))
コード例 #6
0
ファイル: test_secret.py プロジェクト: vaulty/vaulty
 def test_lock(self):
     s = Secret(self.c)
     s.create(self.TEST_PASSPHRASE, reinitialize=True)
     s.unlock(self.TEST_PASSPHRASE)
     self.assertTrue(s.unlocked())
     s.lock()
     self.assertFalse(s.unlocked())
コード例 #7
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def register(self, email, password):
        Validator.email(email)
        Validator.password(password)

        if self.user.exists(email):
            raise RiverException(_('The given email address has already been registered.'))
        
        user_id = Secret.generate(128)

        self.user.insert(email, enabled=True, id=user_id, password=Secret.hash(password, SALT))

        return user_id
コード例 #8
0
ファイル: server.py プロジェクト: MRPanyu/pywayout
 def handle(self):
     try:
         sock = self.connection
         # read first two bytes as random pos
         data = self.rfile.read(2)
         pos = struct.unpack('>H', data)[0]
         self.secret_in = Secret(pos)
         self.secret_out = Secret(pos)
         enc = self.secret_in.enc
         dec = self.secret_out.dec
         # 1. Version/Method
         data = dec(self.rfile.read(2))
         ver = ord(data[0])
         if (ver != 5):
             raise 'version is not 5: ' + ver
         data = dec(self.rfile.read(ord(data[1])))
         sock.send(enc("\x05\x00"))
         # 2. Request
         data = dec(self.rfile.read(4))
         mode = ord(data[1])
         addrtype = ord(data[3])
         addr = None
         if addrtype == 1:  # IPv4
             addr = socket.inet_ntoa(dec(self.rfile.read(4)))
         elif addrtype == 3:  # Domain name
             addr = dec(self.rfile.read(ord(dec(self.rfile.read(1)))))
         port = struct.unpack('>H', dec(self.rfile.read(2)))
         print "addrtype: " + str(
             addrtype) + ", addr: " + addr + ", port: " + str(port[0])
         reply = "\x05\x00\x00\x01"
         try:
             if mode == 1 and addr != None:  # 1. Tcp connect
                 remote = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                 remote.connect((addr, port[0]))
                 pass  # print 'To', addr, port[0]  nothing do to.
             else:
                 reply = "\x05\x07\x00\x01"  # Command not supported
             local = remote.getsockname()
             reply += socket.inet_aton(local[0]) + struct.pack(
                 ">H", local[1])
         except socket.error:
             # Connection refused
             reply = '\x05\x05\x00\x01\x00\x00\x00\x00\x00\x00'
         sock.send(enc(reply))
         # 3. Transfering
         if reply[1] == '\x00':  # Success
             if mode == 1:  # 1. Tcp connect
                 self.handle_tcp(sock, remote)
     except socket.error:
         pass
     except IndexError:
         pass
コード例 #9
0
ファイル: api.py プロジェクト: brianherbert/riverid
    def changeemail(self, oldemail, newemail, password):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException('The password is incorrect for this user.')
        
        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(MAIL_FROM, newemail, 'RiverID Email Change', token)
コード例 #10
0
def main():
    # Generate one
    secret = Secret()
    secret.generate()

    # Run app
    app = configure()
    server = HTTPServer(app, xheaders=True)
    server.listen(port=options.port)

    logging.info(secret.read())
    logging.info('Running on port %s' % options.port)
    IOLoop.current().start()
コード例 #11
0
ファイル: api.py プロジェクト: brianherbert/riverid
    def requestpassword(self, email):
        Validator.email(email)

        token = Secret.generate(16)

        if self.user.exists(email):
            subject = 'RiverID: Please confirm your password change.'
            self.user.update(email, token=token)
        else:
            subject = 'RiverID: Please confirm your email address.'
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(MAIL_FROM, email, subject, token)
コード例 #12
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def requestpassword(self, email, mailbody):
        Validator.email(email)

        token = Secret.generate(16)

        if self.user.exists(email):
            subject = _('RiverID: Please confirm your password change.')
            self.user.update(email, token=token)
        else:
            subject = _('RiverID: Please confirm your email address.')
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(MAIL_FROM, email, subject, mailbody, token=token)
コード例 #13
0
    def __init__(self, is_coinbase, encryption_pass=None):
        if not encryption_pass:
            encryption_pass = getpass.getpass("Encryption password: "******"gmail_password"],
                default_config.notification_receiver,
            )
        else:
            self.email_notification = None

        if is_coinbase and default_config.withdraw_btc_threshold:
            self.address_selector = AddressSelector(
                self.secrets["master_public_key"],
                default_config.withdraw_beginning_address,
            )
        self.db_manager = DBManager()
        self.next_robinhood_buy_datetime = self.calcRobinhoodFirstBuyTime()
        if is_coinbase:
            Logger.info("\n\n\n")
            Logger.info("----------------------")
            Logger.info("----------------------")
            Logger.info("Coinbase DCA started")
            Logger.info("")
            self.coinbase_pro = self.newCoinbaseProClient()
            self.next_buy_datetime = self.calcFirstBuyTime()
コード例 #14
0
    def save_image(self):
        file_name = str(self.step.current_step) + str(os.getpid()) + str(
            random.randrange(6000)) + ".png"
        self.driver.save_screenshot(file_name)
        s = Secret()
        client = self.session.client('s3',
                                     region_name='sfo2',
                                     endpoint_url=s.endpoint_url,
                                     aws_access_key_id=s.ACCESS_ID,
                                     aws_secret_access_key=s.SECRET_KEY)

        client.upload_file(file_name,
                           s.SPACE,
                           'screenshots/' + file_name,
                           ExtraArgs={
                               'ACL': 'public-read',
                               'ContentType': 'image/png'
                           })
        base_image = s.OURL + file_name

        self.xcursor = self.cnxn.cursor()
        self.xcursor.execute(
            "update detail_unit_tests set screenshot=(?) where id=(?)",
            base_image, int(self.step.log_id))

        os.unlink(file_name)
コード例 #15
0
def configure():

    load_config_file()

    agents = dict(agents=Agents())

    proxy_ = proxy.initialize(options.proxy_url, options.proxy_user,
                              options.proxy_password)

    routes = [
        url(r"/?", Home, agents),
        url(r"/login", Login, dict(secret=Secret())),
        url(r"/logout", Logout),
        url(r"/add", AddAgent, agents),
        url((r"/remove/([^/]*)"), RemoveAgent, agents),
        url((r"/toggle/([^/]*)"), ToggleAgent, agents),
        url((r"/auth/([^/]*)"), Authenticate,
            dict(agents=Agents(), proxy=proxy_)),
        url(r'/(favicon\.ico)', StaticFileHandler, dict(path=local('static')))
    ]

    settings = dict(
        autoreaload=options.debug,
        compress_response=True,
        cookie_secret=os.urandom(64),
        debug=options.debug,
        logging=options.loglevel,
        login_url='/login',
        static_path=local('static'),
        template_path=local('templates'),
        xheaders=True,
        xsrf_cookies=True,
    )
    return Application(routes, **settings)
コード例 #16
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def register(self, email, password):
        Validator.email(email)
        Validator.password(password)

        if self.user.exists(email):
            raise RiverException(
                _('The given email address has already been registered.'))

        user_id = Secret.generate(128)

        self.user.insert(email,
                         enabled=True,
                         id=user_id,
                         password=Secret.hash(password, SALT))

        return user_id
コード例 #17
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def changeemail(self, oldemail, newemail, password, mailbody):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(MAIL_FROM,
                  newemail,
                  _('RiverID Email Change'),
                  mailbody,
                  token=token)
コード例 #18
0
ファイル: app.py プロジェクト: dciets/dci-ctf-2018
def print_flag():
    if not request.args.get('n'):
        return 'no "n" specified<br/><br/>Example: http://host:port/?n=123<br/><br/>Source code: /code'
    n = request.args.get('n')
    secret = Secret()
    try:
        n = int(n)
    except ValueError:
        return 'n should be an integer'
    try:
        s = int2hex(n).decode('hex')
        secret.flag = 'sorry ¯\_(ツ)_/¯'
    except:
        n %= 2**3 * 10**8
        s = int2hex(n).decode('hex')
    if s != 'yes':
        secret.flag = 'sorry ¯\_(ツ)_/¯'
    return secret.flag
コード例 #19
0
ファイル: api.py プロジェクト: brianherbert/riverid
    def signin(self, email, password):
        Validator.email(email)
        Validator.password(password)

        user = self.user.get(email)

        if user['enabled'] == False:
            raise RiverException('The account is disabled.')
        
        if user['password'] != Secret.hash(password, SALT):
            raise RiverException('The password is incorrect for this user.')

        session_id = Secret.generate(64)
        session_start = datetime.utcnow().isoformat()

        self.user.add(email, 'session', id=session_id, start=session_start)

        return dict(user_id=user['id'], session_id=session_id)
コード例 #20
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def signin(self, email, password):
        Validator.email(email)
        Validator.password(password)

        user = self.user.get(email)

        if user['enabled'] == False:
            raise RiverException(_('The account is disabled.'))

        if user['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        session_id = Secret.generate(64)
        session_start = datetime.utcnow().isoformat()

        self.user.add(email, 'session', id=session_id, start=session_start)

        return dict(user_id=user['id'], session_id=session_id)
コード例 #21
0
ファイル: api.py プロジェクト: evansims/riverid-python
    def requestpassword(self, email, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(email)

        token = Secret.generate(16)

        if mailfrom is None:
            mailfrom = MAIL_FROM

        if self.user.exists(email):
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your password change.')
            self.user.update(email, token=token)
        else:
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your email address.')
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(mailfrom, email, mailsubject, mailbody, token=token)
コード例 #22
0
ファイル: api.py プロジェクト: evansims/riverid-python
    def changeemail(self, oldemail, newemail, password, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        if self.user.exists(newemail):
            raise RiverException(_('The new email address has already been registered.'))

        if mailsubject is None:
            mailsubject = _('CrowdmapID Email Change')

        if mailfrom is None:
            mailfrom = MAIL_FROM

        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(mailfrom, newemail, mailsubject, mailbody, token=token)
コード例 #23
0
    def __init__(self, id, database_creds, ng):
        self.cnxn = pyodbc.connect(database_creds.get_connectioN_string(),
                                   autocommit=True)
        self.ng = ng

        pid = os.getpid()

        cursor = self.cnxn.cursor()
        self.save_cursor = self.cnxn.cursor()
        option = Options()

        option.add_argument("--disable-infobars")

        option.add_argument("--disable-gpu")
        option.add_argument("--start-maximized")
        #   option.add_argument("--headless")
        #   option.add_argument("--window-size=1024,768")
        option.add_argument("--disable-extensions")
        option.add_argument("--disable-translate")
        option.add_argument("--allow-file-access-from-files")
        option.add_argument("--disable-dev-shm-usage")
        option.page_load_strategy = 'eager'

        # option.add_argument("--enable-usermedia-screen-capturing")
        # option.add_argument("--use-fake-ui-for-media-stream")
        # option.add_argument("--use-fake-device-for-media-stream")
        #  option.add_argument("--use-fake-ui-device-for-media-stream")
        #  option.add_argument("--use-file-for-fake-video-capture=C:\\temp\\bunnyvideo.mjpeg")
        #   option.add_argument("--use-file-for-fake-audio-capture=C:\\temp\\bunny.opus")
        option.add_argument("--enable-tracing")
        #  option.add_argument("--enable-tracing-output = c:\\temp\\log.txt")

        # Pass the argument 1 to allow and 2 to block
        #  option.add_experimental_option("prefs", {
        #     "profile.default_content_setting_values.notifications": 2
        #  })
        option.set_capability('unhandledPromptBehavior', 'accept')

        secret = Secret()

        self.driver = webdriver.Remote(command_executor=secret.URL,
                                       desired_capabilities={
                                           "browserName": "chrome",
                                       },
                                       options=option)

        self.step = Test()
        self.session = session.Session()
        self.master_id = id

        self.run()
コード例 #24
0
ファイル: Csv_To_Pandas.py プロジェクト: EjiOsa/Stock
    def Last_Week_Average(self, df):
        '''
        前週の株価を週平均にして返す。元データはKABU+の共有フォルダから取得。
        tryやlenの部分は祝日のある週の対応をしている。
        '''
        daily = Secret().MyDir()[4]
        now = date.today()
        m1 = now - timedelta(weeks=1)
        w1 = m1.weekday()
        m1mon = m1 - timedelta(days=w1)

        csv = 'japan-all-stock-prices_日付.csv'
        m1dfList = []
        for n in range(5):
            m1week = m1mon + timedelta(days=n)
            m1weekstr = str(m1week).replace('-', '')
            csv_m1 = csv.replace('日付', m1weekstr)
            try:
                Ls_df = pd.read_csv(daily + csv_m1, encoding='shift-jis')
            except FileNotFoundError:
                pass
            else:
                m1dfList.append(Ls_df)

        L = len(m1dfList)

        for n in range(L):
            m1dfList[n].drop([0, 1], 0, inplace=True)
            m1dfList[n].drop(m1dfList[n].columns[1:5], 1, inplace=True)
            m1dfList[n].drop(m1dfList[n].columns[2:], 1, inplace=True)

        Ave_df = pd.merge(m1dfList[0], m1dfList[1], on='SC', how='outer')
        for n in range(2, L):
            Ave_df = pd.merge(Ave_df, m1dfList[n], on='SC', how='outer')
        Ave_df.replace('-', np.nan, inplace=True)

        colLis = ['SC']
        for n in range(L):
            colLis.append('株価' + str(n + 1))
        Ave_df.columns = colLis

        N = len(m1dfList) + 1
        d = Ave_df.columns[1:N]
        for c in d:
            Ave_df[c] = Ave_df[c].astype(float)
        Ave_df['週平均'] = Ave_df[d].mean(axis=1)
        Ave_df.drop(Ave_df.columns[1:N], axis=1, inplace=True)
        df = pd.merge(df, Ave_df, on='SC', how='outer')
        df = df.sort_values(by='SC')
        df.reset_index(inplace=True, drop=True)
        return df
コード例 #25
0
ファイル: api.py プロジェクト: brianherbert/riverid
    def setpassword(self, email, token, password):
        Validator.email(email)
        Validator.token(token)
        Validator.password(password)

        user = self.user.get(email)

        if not user['token']:
            raise RiverException('No password change has been requested for this email address.')

        if user['token'] != token:
            raise RiverException('The token is not valid for this email address.')

        self.user.update(email, enabled=True, token=False, password=Secret.hash(password, SALT))
コード例 #26
0
ファイル: Csv_To_Pandas.py プロジェクト: EjiOsa/Stock
    def add_csv(self, df):
        '''
        KABU+のページとリンクしている共有フォルダからCSVデータを取得、必要な情報のみに修正している。
        '''
        dir, prices, results, ratio, daily = Secret().MyDir()
        df_all = pd.read_csv(prices, encoding='shift-jis')  #別のcsvから時価総額だけ抽出する。
        df_all.drop([0, 1], inplace=True)
        df_all.drop(df_all.columns[1:14], axis=1, inplace=True)
        df_all.drop(df_all.columns[2:4], axis=1, inplace=True)
        df_all = df_all.replace({'-': np.nan, 0: np.nan})
        df_all['時価総額(百万円)'] = df_all['時価総額(百万円)'].astype(float)

        df_all_s = pd.read_csv(results, encoding='shift-jis')  #別のcsvから抽出する。
        df_all_s.drop(df_all_s.columns[1:11], axis=1, inplace=True)
        df_all_s.drop(df_all_s.columns[3:6], axis=1, inplace=True)
        df_all_s = df_all_s.replace({'-': np.nan, 0: np.nan})
        for n in list(df_all_s.columns[1:3]):
            df_all_s[n] = df_all_s[n].astype(float)

        df_ratio = pd.read_csv(
            ratio, encoding='shift-jis')  #別のcsvから抽出する。これはエンコードを指定する。
        df_ratio.drop(df_ratio.columns[3:5], axis=1, inplace=True)
        df_ratio = df_ratio.replace({'-': np.nan})
        for m in list(df_ratio.columns[1:3]):
            df_ratio[m] = df_ratio[m].str.replace('%', '')
            df_ratio[m] = df_ratio[m].astype(float)

        df = df.replace(r'歳|万円|\n\t+|\n+|,', '', regex=True)  #正規表現
        df = df.replace({'-': np.nan, '--': np.nan, '0': np.nan})  #辞書型

        a = list(df.columns[4:16]) + list(df.columns[18:20])
        for n in a:
            df[n] = df[n].astype(float)

        for m in list(df.columns[16:18]):
            for c in df[m]:
                if not '月' in str(c):
                    df.replace(c, np.nan, inplace=True)
                elif not str(c).endswith('日'):  #'日' in str(c):
                    df.replace(c, str(c) + '1日', inplace=True)

        for n in list(df.columns[16:18]):
            df[n] = pd.to_datetime(df[n], format='%Y年%m月%d日')

        df = pd.merge(df, df_all, on='SC', how='outer')
        df = pd.merge(df, df_all_s, on='SC', how='outer')
        df = pd.merge(df, df_ratio, on='SC', how='outer')
        df = df.sort_values(by='SC')
        df.reset_index(inplace=True, drop=True)
        return df
コード例 #27
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def setpassword(self, email, token, password):
        Validator.email(email)
        Validator.token(token)
        Validator.password(password)

        user = self.user.get(email)

        if not user['token']:
            raise RiverException(
                _('No password change has been requested for this email address.'
                  ))

        if user['token'] != token:
            raise RiverException(
                _('The token is not valid for this email address.'))

        self.user.update(email,
                         enabled=True,
                         token=False,
                         password=Secret.hash(password, SALT))
コード例 #28
0
    def raku_url_get(self):#楽天。ログインしてアドレス抽出。
        ID , PASS = Secret().Id_Pass()
        MyUrl =('https://www.rakuten-sec.co.jp/ITS/V_ACT_Login.html')#('https://www.rakuten-sec.co.jp/')

        driver = webdriver.Chrome()
        driver.get(MyUrl)

        driver.find_element_by_id('form-login-id').send_keys(ID)
        driver.find_element_by_id('form-login-pass').send_keys(PASS)
        driver.find_element_by_id('login-btn').click()

        driver.find_element_by_id('gmenu_domestic_stock').find_element_by_tag_name('a').click()

        driver.find_element_by_id('dscrCdNm2').send_keys('1301')
        driver.find_elements_by_class_name('btn-box')[0].find_elements_by_tag_name('img')[0].click()

        driver.find_elements_by_class_name('nav-tab-01-jp')[0].find_elements_by_tag_name('li')[5].find_elements_by_tag_name('a')[0].click()

        soup = BeautifulSoup(driver.page_source,'html.parser')#'lxml')
        #iframe = soup.find('iframe',id = 'J010101-008-1')
        iframe = soup.select('#J010101-008-1')[0]
        Url = iframe['src']
        return Url
        driver.quit()
コード例 #29
0
from hashlib import sha256
import random
from secret import Secret

Sr = Secret()
SECRET_KEY = Sr.get_secret_key()


def get_hexdigest(salt, plaintext):
    return sha256((salt + plaintext).encode('utf-8')).hexdigest()


def make_password(plaintext, app_name):
    salt = get_hexdigest(SECRET_KEY, app_name)[:20]
    hsh = get_hexdigest(salt, plaintext)
    return ''.join((salt, hsh))


def password(plaintext, app_name, length):
    raw_hex = make_password(plaintext, app_name)
    # creating new Password
    ALPHABET = ('abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTYVWXYZ',
                '0123456789', '(,._-*~"<>/|!@#$%^&)+=')
    num = int(raw_hex, 16)
    chars = []
    while len(chars) < length:
        n = random.randint(0, len(ALPHABET) - 1)
        alpha = ALPHABET[n]
        n = random.randint(0, len(alpha) - 1)
        chars.append(alpha[n])
    return ''.join(chars)
コード例 #30
0
    def fetch_home_info_from_address(self,
                                     year='2020',
                                     street_num=None,
                                     street_name=None):
        ''' plug in address and year into site and create a dataframe of the data that is returned as a dictionary '''
        time.sleep(3)  # sleep to not put too much pressure on site
        home = self.home

        url = Secret().url

        driver = webdriver.Chrome(executable_path='dependencies/chromedriver')
        self.driver = driver
        driver.get(url)

        search_by_address_button = driver.find_elements_by_xpath(
            '//*[@id="s_addr"]')[0]
        search_by_address_button.click()

        year_box = driver.find_elements_by_xpath(
            '//*[@id="Real_addr"]/table/tbody/tr[4]/td[1]/select')[0]
        street_no_box = driver.find_elements_by_xpath(
            '//*[@id="Real_addr"]/table/tbody/tr[4]/td[2]/input')[0]
        street_name_box = driver.find_elements_by_xpath(
            '//*[@id="Real_addr"]/table/tbody/tr[4]/td[3]/input')[0]

        year_box.send_keys(year)
        street_no_box.send_keys(street_num)
        street_name_box.send_keys(street_name)
        street_name_box.send_keys(Keys.RETURN)

        time.sleep(15)  # sleep to not put too much pressure on site
        iframe = self.driver.find_element_by_tag_name('iframe')
        self.driver.switch_to.frame(
            iframe
        )  # after the iframe loads, switch into it for selenium to search by element

        # CHECK IF WE GOT RESULTS
        try:
            if driver.find_element_by_class_name(
                    'Open'):  # if this element exists, the results were empty
                print('\n~~~~~~~~~~~~~~~~~~~~~~~',
                      'No data on this year and address: ', year, ': ',
                      street_num, ' ', street_name,
                      '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
                driver.quit()
                return False  # this address had no results. skip it
        except:
            pass

        for table in driver.find_elements_by_class_name('bgcolor_1'):
            sub_headings = [
                x.text.upper().replace(':', '').replace('/', '').replace(
                    '#', '').replace('\n', '_').replace(' ', '_').encode(
                        'ascii', errors='ignore').decode()
                for x in table.find_elements_by_class_name('sub_header')
            ]
            data_points = [
                x.text.upper()
                for x in table.find_elements_by_class_name('data')
            ]

            if len(data_points) + len(
                    sub_headings
            ) <= 1:  # if there is one data or point subheading or less, ignore it
                continue

            elif len(data_points) == len(
                    sub_headings
            ):  # if the lengths are the same, I should be able to map them 1 to 1 to df
                for i, sub in enumerate(sub_headings):
                    home[sub] = data_points[
                        i]  # assign the subheading value to the data value
                    continue

            elif 'VALUATIONS' in sub_headings:
                home['PREVIOUS_LAND_VALUATION_MARKET'] = data_points[7]
                home['PREVIOUS_LAND_VALUATION_APPRAISED'] = data_points[8]
                home['CURRENT_LAND_VALUATION_MARKET'] = data_points[10]
                home['CURRENT_LAND_VALUATION_APPRAISED'] = data_points[11]
                home['PREVIOUS_IMPROVEMENT_VALUATION_MARKET'] = data_points[13]
                home['PREVIOUS_IMPROVEMENT_VALUATION_APPRAISED'] = data_points[
                    14]
                home['CURRENT_IMPROVEMENT_VALUATION_MARKET'] = data_points[16]
                home['CURRENT_IMPROVEMENT_VALUATION_APPRAISED'] = data_points[
                    17]
                home['PREVIOUS_TOTAL_VALUATION_MARKET'] = data_points[19]
                home['PREVIOUS_TOTAL_VALUATION_APPRAISED'] = data_points[20]
                home['CURRENT_TOTAL_VALUATION_MARKET'] = data_points[22]
                home['CURRENT_TOTAL_VALUATION_APPRAISED'] = data_points[23]

            elif 'LAND' and 'MARKET_VALUE_LAND' in sub_headings:
                continue  # we don't want to get this data for now
                #subs_for_df = sub_headings[2:14] # get the 12 not including "land" and "market value land"

            elif 'EXTRA_FEATURES' or 'OWNER_AND_PROPERTY_INFORMATION' or 'VALUE_STATUS_INFORMATION' or 'IMPR_SQ_FT' or 'EXEMPTIONS_AND_JURISDICTIONS' in sub_headings:
                continue  # we don't want to get this data for now

            else:
                print('SUB: ' + str(len(sub_headings)) + str(sub_headings))
                print('DATA: ' + str(len(data_points)) + str(data_points))
                print('\n')

        try:
            building_data = driver.find_element_by_class_name('bgcolor_3')
            rows = building_data.find_elements(
                By.TAG_NAME, 'tr')  # get all of the rows in the table
            table_data = []
            for row in rows:
                table_data = row.find_elements(By.TAG_NAME, 'td')
                for data in table_data:
                    table_data.append(data.text)

            headers = [
                val for idx, val in enumerate(table_data) if idx % 2 == 0
            ]
            values = [
                val for idx, val in enumerate(table_data) if idx % 2 == 1
            ]

            for idx, header in enumerate(header):
                formatted_header = header.replace(' ', '_').replace(
                    ':',
                    '').replace('/',
                                '').replace('#', '').replace('\n', '_').upper(
                                )  # change string to ascii camel case format
                home[formatter_header] = values[idx]
        except:
            print('Unable to get additional building data.')
            pass

        home_dict = home.to_dict('records')[0]

        return home_dict
コード例 #31
0
ファイル: api.py プロジェクト: d8agroup/riverid
    def checkpassword(self, email, password):
        Validator.email(email)
        Validator.password(password)

        return self.user.get(email)['password'] == Secret.hash(password, SALT)
コード例 #32
0
import time
import keyboard
import requests

from helpers import Helpers
from secret import Secret

authorization, port = Secret.getSecret()

fullUrl = "https://127.0.0.1:" + port

routeAllowed = ['TOP', 'MID', 'SUP', 'JUNGLE', 'ADC', 'RANDOM']
championRoutes: dict[str, dict[str, list[str]]] = {}
posBan = 0
posPick = 0


class Core:
    @staticmethod
    def start():
        welcome()

        while not keyboard.is_pressed("ctrl+q"):
            if keyboard.is_pressed("ctrl+b"):
                showChampions()

            if keyboard.is_pressed("ctrl+r"):
                configureRoles()

            if keyboard.is_pressed("ctrl+space"):
                showRoutes()
コード例 #33
0
from secret import Secret
from menu import menu, create, find, find_accounts

sr = Secret()
secret = sr.get_secret_key()

passw = input(
    'Please provide the master password to start using password Manager:')
if passw == secret:
    print('acces granted')
else:
    print('acess denied')
    exit()

choice = menu()
while choice != 'Q':
    if choice == '1':
        create()
    elif choice == '2':
        find_accounts()
    elif choice == '3':
        find()
    choice = menu()
exit()
コード例 #34
0
ファイル: test_secret.py プロジェクト: vaulty/vaulty
 def test_unlock_wrong_pass(self):
     s = Secret(self.c)
     s.create(self.TEST_PASSPHRASE, reinitialize=True)
     self.assertEqual(s.unlock('bar'), SecretStatus.OPENSSL_ERROR)
コード例 #35
0
ファイル: ftester.py プロジェクト: seanyainkiranina/sel
    def __init__(self, id, database_creds, ng):
        self.cnxn = pyodbc.connect(database_creds.get_connectioN_string(),
                                   autocommit=True)
        self.ng = ng

        pid = os.getpid()

        cursor = self.cnxn.cursor()
        self.save_cursor = self.cnxn.cursor()
        option = Options()

        option.add_argument("--disable-infobars")

        option.add_argument("--disable-gpu")
        option.add_argument("--start-maximized")
        option.add_argument("--headless")
        option.add_argument("--window-size=1024,768")
        option.add_argument("--disable-extensions")
        option.add_argument("--disable-translate")
        option.add_argument("--allow-file-access-from-files")

        option.add_argument("--proxy-server='direct://'")
        option.add_argument("--proxy-bypass-list=*")
        option.add_argument("--start-maximized")
        option.add_argument('--disable-dev-shm-usage')
        option.add_argument('--no-sandbox')
        option.add_argument('--ignore-certificate-errors')

        # option.add_argument("--enable-usermedia-screen-capturing")
        # option.add_argument("--use-fake-ui-for-media-stream")
        # option.add_argument("--use-fake-device-for-media-stream")
        #  option.add_argument("--use-fake-ui-device-for-media-stream")
        #  option.add_argument("--use-file-for-fake-video-capture=C:\\temp\\bunnyvideo.mjpeg")
        #   option.add_argument("--use-file-for-fake-audio-capture=C:\\temp\\bunny.opus")
        option.add_argument("--enable-tracing")
        #  option.add_argument("--enable-tracing-output = c:\\temp\\log.txt")

        # Pass the argument 1 to allow and 2 to block
        #  option.add_experimental_option("prefs", {
        #     "profile.default_content_setting_values.notifications": 2
        #  })
        option.set_capability('unhandledPromptBehavior', 'accept')
        option.log.level = "trace"

        secret = Secret()

        fp = webdriver.FirefoxProfile()
        fp.set_preference("devtools.debugger.remote-enabled", True)
        fp.set_preference("devtools.debugger.prompt-connection", False)
        fp.set_preference("devtools.debugger.remote-enabled", True)

        fp.set_preference("marionette.log.level", "Trace")

        self.driver = webdriver.Remote(browser_profile=fp,
                                       command_executor=secret.URL,
                                       desired_capabilities={
                                           "browserName": "firefox",
                                           "marionette": "true"
                                       },
                                       options=option)

        self.step = Test()
        self.session = session.Session()
        self.master_id = id

        self.run()
コード例 #36
0
ファイル: 8hour.py プロジェクト: TheNew000/8hourDBExtraction
from flask import Flask, render_template, redirect, request
from flaskext.mysql import MySQL
from secret import Secret

mysql = MySQL()
app = Flask(__name__)

Secret = Secret()

app.config['MYSQL_DATABASE_USER'] = Secret.user
app.config['MYSQL_DATABASE_PASSWORD'] = Secret.pw
app.config['MYSQL_DATABASE_DB'] = Secret.db
app.config['MYSQL_DATABASE_HOST'] = Secret.host
mysql.init_app(app)

conn = mysql.connect()
cursor = conn.cursor()

cursor.execute(
    "SELECT T1.item_id, GROUP_CONCAT(T1.meta_value SEPARATOR ', ') AS Result FROM wp_kczafk_frm_item_metas T1 GROUP BY T1.item_id"
)
result = cursor.fetchall()

for i in range(0, len(result)):
    table_list = result[i][1].split(', ', 5)
    for j in range(0, len(table_list)):
        if table_list[j] is None:
            table_list[j] = 'NULL'
    if len(table_list) < 3:
        print "This Person Sucks Hambone"
    elif len(table_list) < 6:
コード例 #37
0
ファイル: api.py プロジェクト: brianherbert/riverid
    def checkpassword(self, email, password):
        Validator.email(email)
        Validator.password(password)

        return self.user.get(email)['password'] == Secret.hash(password, SALT)
コード例 #38
0
 def getPassword(self):
     s = Secret(self.cipherKey)
     return s.DecodeAES(self.password)
コード例 #39
0
ファイル: Get_Csv.py プロジェクト: EjiOsa/Stock
import urllib.request
import datetime as dt
from secret import Secret

url = 'http://kabusapo.com/dl-file/dl-stocklist.php'
#csvに月曜の日付を付ける。
t = dt.date.today()
w = t.weekday()
m = t - dt.timedelta(days=w)
#保存先はデスクトップのPYTHONディレクトリに。
name = Secret().MyDir()[0]
name = name.replace('日付', str(m))
urllib.request.urlretrieve(url, name)
コード例 #40
0
ファイル: test_secret.py プロジェクト: vaulty/vaulty
 def test_unlock(self):
     s = Secret(self.c)
     s.create(self.TEST_PASSPHRASE, reinitialize=True)
     self.assertEqual(s.unlock(self.TEST_PASSPHRASE), SecretStatus.OK)
コード例 #41
0
 def __encryptPassword(self, plainText):
     s = Secret(self.cipherKey)
     return s.EncodeAES(plainText)
コード例 #42
0
ファイル: setup.py プロジェクト: freenancial/bitcoin-dca
#!/usr/bin/env python3

from secret import Secret

if __name__ == "__main__":
    Secret.encryptAllSecrets()