".zip":"application/zip", ".tar":"application/x-tar" } #=============================================== #=====APPSCAN SECRET GENERATION AND MIGRATION===== #Based on https://gist.github.com/ndarville/3452907#file-secret-key-gen-py try: SECRET_KEY except NameError: SECRET_FILE = os.path.join(AppScan_HOME, "secret") try: SECRET_KEY = open(SECRET_FILE).read().strip() except IOError: try: SECRET_KEY = utils.genRandom() secret = file(SECRET_FILE, 'w') secret.write(SECRET_KEY) secret.close() utils.Migrate(BASE_DIR) except IOError: Exception('Please create a %s file with random characters to generate your secret key!' % SECRET_FILE) #============================================= #============DJANGO SETTINGS ================= # SECURITY WARNING: don't run with debug turned on in production! # ^ This is fine Do not turn it off until AppScan moves from Beta to Stable DEBUG = True TEMPLATE_DEBUG = False
'application/x-zip-compressed', 'binary/octet-stream', ] #=============================================== #=====MOBSF SECRET GENERATION AND MIGRATION===== #Based on https://gist.github.com/ndarville/3452907#file-secret-key-gen-py try: SECRET_KEY except NameError: SECRET_FILE = os.path.join(MobSF_HOME, "secret") try: SECRET_KEY = open(SECRET_FILE).read().strip() except IOError: try: SECRET_KEY = utils.genRandom() secret = file(SECRET_FILE, 'w') secret.write(SECRET_KEY) secret.close() utils.Migrate(BASE_DIR) except IOError: Exception('Please create a %s file with random characters \ to generate your secret key!' % SECRET_FILE) #============================================= #============DJANGO SETTINGS ================= # SECURITY WARNING: don't run with debug turned on in production! # ^ This is fine Do not turn it off until MobSF moves from Beta to Stable DEBUG = True
def newBill(self, userCookie, amount, category, date, reportedBy, reportedAt = utils.timestamp(False), billType = 'individual', participants = [], tags = [], description = None, userAmounts = [], emails = []): cursor = self.__conn.cursor() try: uid = self.getUser(ck = userCookie)['_id'] ppl = participants if len(ppl) == 0: ppl.append(reportedBy) bill_id = utils.genIdentifier(["%d" % utils.genRandom(), "%d" % date, "%d" % reportedBy, category]) cursor.execute(""" INSERT INTO """ + DbWorker.dbCfg['table.bill'] + """ VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """ , (bill_id, amount, category, date, reportedAt, reportedBy, billType, ",".join([str(x) for x in ppl]), utils.joinOrNone(tags), description)) utils.dbgMsg("Inserted %d rows to table %s" % (cursor.rowcount, DbWorker.dbCfg['table.bill']), DbWorker.globalCfg['debug'], DbWorker.globalCfg['debug.info'], __name__, DbWorker.currFrame.f_lineno, DbWorker.currFrame.f_code.co_filename) amnts = userAmounts if (len(amnts) == 0): amnts.append(amount) if (len(ppl) != len(amnts) and len(ppl) != len(emails)): raise LogicalError("""#ppl and #amount #emails should be same. ppl = [%s], amnts = [%s], emails = [%s] """ % (",".join(["%d" % x for x in ppl]), ",".join(["%f" % x for x in amnts])), ",".join(emails)) idAmntComb = map(lambda x, y: (x, y), ppl, amnts) idAMntEmailComb = map(lambda (x, y), z: (x, y, z), idAmntComb, emails) for uid, amt, email in idAMntEmailComb: uid = int(uid) amt = float(amt) try: self.getUser(uid = uid) except (BadArgs, RecordNotFound): tstmp = utils.timestamp(False) tmpCookie = utils.genIdentifier(["%d" % utils.genRandom(), "%d" % uid, "%d" % tstmp]) self.userLogin(userId = uid, userCookie = tmpCookie, lastSeen = tstmp, email = email, openid = None, firstName = None, lastName = None, cellPhone = None, memberSince = tstmp, uType = 'auto') cursor.execute(""" INSERT INTO """ + DbWorker.dbCfg['table.expense'] +""" VALUES(%s, %s, %s, %s, %s, %s) """ , (bill_id, uid, amt, date, category, utils.joinOrNone(tags))) except: raise finally: self.__conn.commit() cursor.close()
def genUserId(email): uid = (email is None and [None] or [(utils.genIdentifier( ["%d" % utils.genRandom(), email, "%d" % utils.timestamp()]))])[0] print "[DBG] uid = %d" % uid return uid
user = self.getUser(ck = cookie, uid = None) return user['_id'] def junk(self): pass if __name__ == "__main__": worker = DbWorker() email = raw_input("Email: ") ck = raw_input("Cookie: ") email = (len(email) and [email] or [None])[0] ck = (len(ck) and [long(ck)] or [utils.genIdentifier([email, "%d" % utils.timestamp()])])[0] print "Cookie = %d" % ck uid = (email is None and [None] or [(utils.genIdentifier( ["%d" % utils.genRandom(), email, "%d" % utils.timestamp()]))])[0] worker.userLogin(uid, ck, utils.timestamp(False), email, "xyz__nnnn", "Prakhar", "Sharma", "631-885-4602", utils.timestamp(False), 'manual') cont = raw_input("wanna report an expense (y/n): ") if cont == "y" or cont == "Y": amnt = float(raw_input("bill amount: ")) catg = raw_input("bill category: ") uid = worker.userIdFromCookie(ck) if uid is None: sys.stderr.write("User for cookie %s not present" % ck) sys.exit(1) listify = lambda tags: ((tags is None or len(tags) == 0) and [[]] or [tags.split(",")])[0] tags = listify(raw_input("tags (csv list): "))