Skip to content

Instantly share code, notes, and snippets.

@marccane
Last active December 6, 2022 01:07
Show Gist options
  • Save marccane/c0ac8beedce747c454f0a7fdb323f824 to your computer and use it in GitHub Desktop.
Save marccane/c0ac8beedce747c454f0a7fdb323f824 to your computer and use it in GitHub Desktop.
pwnable.tw challenge sorter
#!/usr/bin/env python3
#import sys, requests, code
from lxml import etree
#code.interact(local=locals())
baseUrl = "https://pwnable.tw/challenge/"
if __name__ == '__main__':
arr = []
with open("pwnable.tw.html") as file:
content = file.read()
tree = etree.HTML(content)
for chall in tree.xpath("//ul[@id='challenge-list']/li"):
title = chall.find(".//span[@class='tititle']")
score = chall.find(".//span[@class='score']").getchildren()[0]
solves = chall.find(".//span[@class='solved_times']")
libc = chall.find(".//div[@class='libc']")
solves = int(solves.text.strip().split(' ')[1])
arr.append((title.text, score.text, solves, False if libc is None else True))
import operator as o
arr.sort(key=o.itemgetter(2), reverse=True) #solves
arr.sort(key=o.itemgetter(3)) #libc
#arr.sort(key=o.itemgetter(2), reverse=True) #solves
for i in arr:
title, score, solves, libc = i
libcText = '' if libc else 'Not '
#print("{}, {}libc, {}, Solved {} times".format(title, libcText, score, solves))
print("{}libc, {}, {} solves, {}".format(libcText, score, solves, title))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment