Last active
December 6, 2022 01:07
-
-
Save marccane/c0ac8beedce747c454f0a7fdb323f824 to your computer and use it in GitHub Desktop.
pwnable.tw challenge sorter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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