Last active
April 24, 2021 13:12
-
-
Save Guevara-chan/7d20b40001449a9d9694f62829a6f852 to your computer and use it in GitHub Desktop.
Junk sites URL generation util.
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
# Get compiled executable there: https://github.com/Guevara-chan/packages/releases/tag/nDustman_0.01 | |
import random, nativesockets, threadpool, parsecfg, strutils, sequtils, terminal | |
const header = "# nDustman junk sites URL generator v0.01\n# Developed in 2021 by Victoria A. Guevara" | |
# Basic init. | |
randomize() | |
const config_file = "config.ini" | |
config_file.open(fmAppend).close() | |
var cfg = config_file.loadConfig() | |
# Aux configuration proc. | |
proc cfget(key: string, def_val: string): string = | |
result = cfg.getSectionValue("", key, def_val) | |
cfg.setSectionKey "", key, result | |
# Config parsing. | |
let urlimit = (min: "min_url".cfget("5").parseInt, max: "max_url".cfget("6").parseInt) | |
let domains = "domains".cfget(".com .org .net").split(' ') | |
let charpool = "char_pool".cfget({'a'..'z', '0'..'9'}.toSeq().join("")).toLower().toSeq().deduplicate() | |
# Fiber body. | |
proc finder(urlen: int, domain: string, pool: seq[char]) {.gcsafe.} = | |
while true: | |
var url = "www." | |
for i in 1..urlen: url &= sample(pool) | |
url &= domain | |
try: | |
discard url.getAddrInfo(Port 80, AfUnspec) | |
echo url | |
let log = open("finds.txt", fmAppend) | |
log.writeLine url | |
log.close() | |
except: discard | |
# Main code. | |
stdout.styledWrite fgGreen, styleBright, header, fgBlack, styleBright, "\n-\nURL length range = ", $urlimit, | |
"\nApplicable domains: ", $domains, "\nCharacter pool: ", charpool.join(""), "\n-\n" | |
cfg.writeConfig config_file | |
for urlen in urlimit.min..urlimit.max: | |
for domain in domains: | |
spawn finder(urlen, domain, charpool) | |
sync() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment