예제 #1
0
def tds_msg(_msg, _method):
    _tdes = basic_fun.TripleDes()
    _tdes.method = _method
    _msg = _tdes.encrypt(_msg)
    _msg = base64.b64encode(_msg)
    return _msg
예제 #2
0

if __name__ == '__main__':
    row_argv = sys.argv
    list_0 = row_argv
    mode = list_0[1]
    if mode == "mtree_build":
        sys_order = "python ./data_collection.py"
        p = os.system(sys_order)
    elif mode == "server":
        db = pymysql.connect("localhost", "root", "root", "new_schema")
        cursor = db.cursor()
        init_db()

        k_session = basic_fun.file_read("k_session.txt", "rb")
        tdes = basic_fun.TripleDes()
        tdes.method = basic_fun.tls_handshake_2(k_session)

        msg = basic_fun.file_read("message_sec.txt", "rb")
        msg = base64.b64decode(msg)
        msg = tdes.decrypt(msg)
        list_msg = str(msg, "utf-8").split("\n")
        action = list_msg[0]
        if action == "1":  # register
            pid = list_msg[1]
            pwd_hash = list_msg[2]
            allow = pid_authenticate(pid)
            if allow == 1:
                sql = "select * from status where PID = \"%s\"" % pid
                cursor.execute(sql)
                result = cursor.fetchall()