Last active
September 26, 2024 14:07
-
-
Save ZoomTen/ecdf2f6e4d5d187c30ac6abef6a283b0 to your computer and use it in GitHub Desktop.
I'm too late, so here I am hammering Wikia's servers for 3 days straight
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
import std/random | |
import std/strutils | |
import std/httpclient | |
import std/monotimes | |
import std/cmdline | |
import malebolgia | |
import malebolgia/ticketlocks | |
proc toThreeString(i: int): string = i.toHex(3).toLowerAscii() | |
proc searchUrlWorker( | |
m: MasterHandle, | |
threadNo: int, | |
start: int, | |
res: ptr string, | |
L: ptr TicketLock, | |
finalUrl: string | |
) = | |
var i = start | |
echo "start $#, $#" % [$threadNo, i.toThreeString()] | |
var client = newHttpClient() | |
defer: | |
client.close() | |
for n in 1..103: | |
if m.cancelled: | |
# Cease all operations on this thread if one of the other | |
# threads have ended | |
break | |
if i > 4095: | |
# Don't try any further than 4095 | |
break | |
let hexStr = i.toThreeString() | |
if client.head(finalUrl % [$hexStr[0], $hexStr[1], $hexStr[2]]).status == "200 OK": | |
m.cancel() | |
echo "Got matching value $# on thread $#" % [hexStr, $threadNo] | |
withLock L[]: | |
res[] = hexStr | |
break | |
else: | |
inc i | |
echo "end $#, $#" % [$threadNo, i.toThreeString()] | |
proc searchUrl(filename: string) = | |
var m = createMaster() | |
var gotString: string | |
var L = initTicketLock() | |
let startT = getMonoTime() | |
let | |
base = "https://static.wikia.nocookie.net/sonicfanchara/images/$#/$#$#/" | |
suffix = "/revision/latest" | |
finalUrl = base & filename & suffix | |
m.awaitAll: | |
for i in 0..39: | |
m.spawn searchUrlWorker(m.getHandle(), i, i * 103, gotString.addr, L.addr, finalUrl) | |
echo "took $#" % [$(getMonoTime() - startT)] | |
if gotString != "": | |
let url = finalUrl % [$gotString[0], $gotString[1], $gotString[2]] | |
echo url | |
var downloader = newHttpClient() | |
defer: | |
downloader.close() | |
downloader.downloadFile(url, filename) | |
else: | |
echo "not found :(" | |
when isMainModule: | |
let params = commandLineParams() | |
if len(params) < 1: | |
echo "needs a file name parameter, do not start with File:" | |
quit(1) | |
searchUrl(params[0]) |
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
--define:ssl | |
--define:danger | |
--opt:speed | |
--mm:arc | |
--define:useMalloc | |
--define:ThreadPoolSize=40 |
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 sh | |
parallel -j8 ./bruteforce {} < 04_nail.txt |
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
Cartoon_comic_Dark_Ace.jpg | |
Cartoon_comic_Dash.jpg | |
Cartoon_comic_Emily.jpg | |
Cartoon_comic_Fionna.jpg | |
Cartoon_comic_Macca.jpg | |
Cartoon_comic_Matrix.jpg | |
Cartoon_comic_Sam.jpg | |
Cartoon_comic_Shimmer.jpg | |
Cartoon_comic_Shine.jpg | |
Cartoon_comic_Static.jpg | |
Cartoon_comic_Tailsalyn.jpg | |
Cartoon_comic_Thunder_Punch.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment