2020-01-22 14:22:06 +00:00
|
|
|
import random, strformat, strutils, sequtils
|
2019-12-06 12:02:04 +00:00
|
|
|
|
|
|
|
randomize()
|
|
|
|
|
|
|
|
const rvs = [
|
|
|
|
"11.0", "40.0", "42.0", "43.0", "47.0", "50.0", "52.0", "53.0", "54.0",
|
2020-01-22 14:22:06 +00:00
|
|
|
"61.0", "66.0", "67.0", "69.0", "70.0"
|
2019-12-06 12:02:04 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
proc rv(): string =
|
2020-01-22 14:22:06 +00:00
|
|
|
if rand(10) < 1: ""
|
2019-12-06 12:02:04 +00:00
|
|
|
else: "; rv:" & sample(rvs)
|
|
|
|
|
|
|
|
# OS
|
|
|
|
|
2020-01-22 14:22:06 +00:00
|
|
|
const enc = ["; U", "; N", "; I", ""]
|
|
|
|
|
2019-12-06 12:02:04 +00:00
|
|
|
proc linux(): string =
|
|
|
|
const
|
2020-01-22 14:22:06 +00:00
|
|
|
window = ["X11", "Wayland", "Unknown"]
|
|
|
|
arch = ["i686", "x86_64", "arm"]
|
|
|
|
distro = ["", "; Ubuntu/14.10", "; Ubuntu/16.10", "; Ubuntu/19.10",
|
|
|
|
"; Ubuntu", "; Fedora"]
|
|
|
|
sample(window) & sample(enc) & "; Linux " & sample(arch) & sample(distro)
|
2019-12-06 12:02:04 +00:00
|
|
|
|
|
|
|
proc windows(): string =
|
|
|
|
const
|
|
|
|
nt = ["5.1", "5.2", "6.0", "6.1", "6.2", "6.3", "6.4", "9.0", "10.0"]
|
|
|
|
arch = ["; WOW64", "; Win64; x64", "; ARM", ""]
|
|
|
|
trident = ["", "; Trident/5.0", "; Trident/6.0", "; Trident/7.0"]
|
2020-01-22 14:22:06 +00:00
|
|
|
"Windows " & sample(nt) & sample(enc) & sample(arch) & sample(trident)
|
|
|
|
|
|
|
|
let macs = toSeq(6..15).mapIt($it) & @["14_4", "10_1", "9_3"]
|
2019-12-06 12:02:04 +00:00
|
|
|
|
|
|
|
proc mac(): string =
|
2020-01-22 14:22:06 +00:00
|
|
|
"Macintosh; Intel Mac OS X 10_" & sample(macs) & sample(enc)
|
2019-12-06 12:02:04 +00:00
|
|
|
|
|
|
|
# Browser
|
|
|
|
|
|
|
|
proc presto(): string =
|
2020-01-22 14:22:06 +00:00
|
|
|
const p = ["2.12.388", "2.12.407", "22.9.168", "2.9.201", "2.8.131", "2.7.62",
|
|
|
|
"2.6.30", "2.5.24"]
|
|
|
|
const v = ["10.0", "11.0", "11.1", "11.5", "11.6", "12.00", "12.14", "12.16"]
|
2019-12-06 12:02:04 +00:00
|
|
|
&"Presto/{sample(p)} Version/{sample(v)}"
|
|
|
|
|
|
|
|
# Samples
|
|
|
|
|
|
|
|
proc product(): string =
|
|
|
|
const opera = ["Opera/9.80", "Opera/12.0"]
|
2020-01-22 14:22:06 +00:00
|
|
|
if rand(20) < 1: "Mozilla/5.0"
|
2019-12-06 12:02:04 +00:00
|
|
|
else: sample(opera)
|
|
|
|
|
|
|
|
proc os(): string =
|
2020-01-22 14:22:06 +00:00
|
|
|
let r = rand(10)
|
2019-12-06 12:02:04 +00:00
|
|
|
let os =
|
2020-01-22 14:22:06 +00:00
|
|
|
if r < 6: windows()
|
|
|
|
elif r < 9: linux()
|
2019-12-06 12:02:04 +00:00
|
|
|
else: mac()
|
|
|
|
&"({os}{rv()})"
|
|
|
|
|
2020-01-22 14:22:06 +00:00
|
|
|
proc browser(prod: string): string =
|
|
|
|
if "Opera" in prod: presto()
|
|
|
|
else: "like Gecko"
|
2019-12-06 12:02:04 +00:00
|
|
|
|
|
|
|
# Agent
|
|
|
|
|
|
|
|
proc getAgent*(): string =
|
|
|
|
let prod = product()
|
2020-01-22 14:22:06 +00:00
|
|
|
&"{prod} {os()} {browser(prod)}"
|