예제 #1
0
 def subs(self):
     """dumps time that a flag was submitted. useful to prove who submitted fastest? 
     """
     solves = list(db.select((s.time, s.flag.flag, s.user.name, s.value) for s in db.Solve))
     solves.insert(0, ['Time','Flag','User','Value'])
     table  = mdTable(solves)
     print(table.table)
예제 #2
0
 def challs(self):
     """This dumps the all the challenges """
     with db.db_session:
         challs = list(db.select((chall.id, chall.title,  chall.description[:20], chall.flags, chall.visible, chall.byoc, ) for chall in db.Challenge))
         # data = [c for c in challs]
         challs.insert(0,['ID', 'Title', 'Description', 'Flags', 'Visible', 'BYOC', 'BYOC_External'])
         table = mdTable(challs)
         print(table.table)
예제 #3
0
    def trans(self):
        """Dumps a list of all transactions from all users. This will allow you to reconstitute a score if needed or analyze if something doesn't work as expected.
        """
        ts = list(db.select( (t.id, t.value, t.type, t.sender.name, t.recipient.name,t.message,t.time)for t in db.Transaction))

        ts.insert(0, ["Trans ID", "Value", 'Type','Sender', 'Recipient', 'Message', 'Time'])
        table = mdTable(ts)
        print(table.table)
예제 #4
0
    def users(self):
        """Dump all users, which team they're on and their individual score. 
        """
        data = db.select(u for u in db.User)[:]
        
        data = [(u.id, u.name,u.team.name, db.getScore(u)) for u in data]

        data.insert(0, ['ID', 'Name','Team', 'Score'])
        table = mdTable(data)
        print(table.table)
예제 #5
0
 def teams(self):
     """This dumps the all the teams """
     teams = db.Team.select()[:]
     data = []
     for t in teams:
         line = [t.name, ', '.join([tm.name for tm in t.members]), t.password]
         # print(line)
         data.append(line)
     data.insert(0,['Team', 'Members', 'Team Password Hash'])
     table = mdTable(data)
     table.inner_row_border = True
     print(table.table)
예제 #6
0
 def flags(self):
     """dump all flags... useful for debugging"""
     with db.db_session:
         # flags = list(db.select((flag.id, flag.flag, flag.value, flag.challenges) for flag in db.Flag))
         # for flag in flags:
         #     print(flag)
         # flags = list(db.select((flag.id, flag.flag, flag.value, ','.join((c.title for c in flag.challenges))) for flag in db.Flag))
         data = []
         for flag in db.Flag.select():
             data.append([flag.id, flag.flag, flag.value, ','.join([c.title for c in flag.challenges])])
         data.insert(0, ['ID', 'Flag', 'Value', 'Challenges'])
         table = mdTable(data)
         print(table.table)
예제 #7
0
    def bstat(self):
        """BYOC stats for all players. useful for the awards ceremony"""
        challs = list(db.select(c for c in db.Challenge))

        # num solves per challenge
        stats = []
        for chall in challs:
            num_solves = list(db.select(s for s in db.Solve if s.challenge == chall))

            chall_rewards = sum(db.select(sum(t.value) for t in db.Transaction if t.type == "byoc reward" and t.challenge == chall).without_distinct())

            line = [chall.id, chall.title, len(num_solves),chall.author.name, chall_rewards]
            
            stats.append(line)
        stats.insert(0, ['Chall ID', 'Title', '# Solves', 'Author', 'Payout'])

        table = mdTable(stats)

        # team total byoc rewards sum
        total_byoc_rewards = sum(db.select(sum(t.value) for t in db.Transaction if t.type == "byoc reward" ))

        print(table.table)
        print(f'\nTotal BYOC rewards granted: {total_byoc_rewards}')
예제 #8
0
 def showall(self):
     """Show all of the current settings for byoctf"""
     data = [(k,SETTINGS[k]) for k in SETTINGS.iterkeys()]
     data.insert(0, ['Setting', 'Value'])
     table = mdTable(data)
     print(table.table)