So I've been a fan of hackthissite.org for a while now. IT Security has been an interest of mine since I was introduced to computers. They've got tons of hacking challenges to test your skills and teach you new ones.
Just recently though, I noticed that they have coding/scripting challenges now as well. They range from beginner to really difficult, but they've got some really neat ones up there. If you're interested, go register (for free, of course) and try them out for yourself.
The first challenge asks you to code something that can take a number of scrambled words, that were chosen from a file that they provide you with, run the input through a script and produce the unscrambled words in a specific format. i.e. (word1, word2, word3,.....)
Sure you could do it manually, but the page expires a few seconds after the scrambled words are given. So you have to get the scrambled words, run them through your script and submit the output in a few seconds.
There are a ton of ways you could handle this, like sending the output to a file, or console, or even have it go straight to the clipboard so you can paste it into the web form quickly. Even write something to parse the page, pull down the words, and post the output automatically...
Below the break, you can see how I did it using python. Kind of a spoiler if you're planning to try this stuff out yourself, just fyi.
Here's how I did it:
filename = open('scrambled.txt', 'r')
scrambled = []
temp = filename.readlines()
for line in temp:
x = line.strip()
scrambled.append(x)
filename.close()
print(scrambled)
filename = open("wordlist.txt", 'r')
wordlist = filename.read()
wordlist = wordlist.split("\r\n")
filename.close()
final = []
for i in scrambled:
if i != "":
for x in wordlist:
if len(i) == len(x):
order1 = []
order2 = []
for blah in i:
order1.append(blah)
for blah in x:
order2.append(blah)
order1.sort()
order2.sort()
if order1 == order2:
final.append(x)
for i in final:
print(i + ',')
This just takes the words I saved to a txt and spits it out to the console. Not very fancy, but it works.
I'd highly recommend checking out hackthissite.org if you're looking for some way to test your coding skills in fun and engaging ways.
-newt
No comments:
Post a Comment