Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def jschl(tag, domain='www.doutula.com'):
snippet, obj = '', None
for line in tag.splitlines():
if 's,t,o,p,b,r,e,a,k,i,n,g' in line and ' ' in line:
define = line.rsplit(' ', maxsplit=1)[-1]
if '=' in define and define.endswith(';'):
obj = define.split('=')[0]
snippet += define
if 'submit()' in line:
break
if obj:
for seg in line.split(';'):
if seg.startswith(obj) and '=' in seg:
snippet += seg + ';'
return js2py.eval_js(snippet) + len(domain)
async def eval(self, ctx):
args = ctx.message.content
args = args.split(' ')
if ctx.message.author.id not in ownerids:
await ctx.send(":x: You do not have permission to evaluate code.")
return
try:
if args[1] != "":
if args[1] == "py":
code = ctx.message.content.replace(args[0]+" "+args[1]+" ", "")
code = code.strip('` ')
elif args[1] == "js":
code = ctx.message.content.replace(args[0]+" "+args[1]+" "+args[2]+" ", "")
javascript = 'Excecuted successfully and returned: {}'
try:
result = js2py.eval_js(str(code))
if result is None:
a = "Executed successfully with no objects returned."
else:
a = javascript.format(result)
await ctx.send(embed=discord.Embed(description=a,color=0x00ff00).set_author(name="Evaluated with success", icon_url=ctx.message.author.avatar_url.replace("?size=1024", "")).set_footer(text="Executed by: "+str(ctx.message.author)).set_thumbnail(url='http://www.iconsdb.com/icons/preview/green/checked-checkbox-xxl.png').add_field(name="Code",value="[See here.]({})".format(hastebin.post(code))))
return
except Exception as e:
await ctx.send(embed=discord.Embed(description="Excecuted and errored: {}".format(type(e).__name__ + ': ' + str(e)),color=0xff0000).set_author(name="Evaluated and errored", icon_url=ctx.message.author.avatar_url.replace("?size=1024", "")).set_footer(text="Executed by: "+str(ctx.message.author)).set_thumbnail(url='https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Red_x.svg/480px-Red_x.svg.png').add_field(name="Code",value="[See here.]({}.js)".format(hastebin.post(code))))
return
else:
code = ctx.message.content.replace(args[0]+" ", "")
code = code.strip('` ')
python = 'Excecuted successfully and returned: {}'
result = None
env = {
def get_fp_sign(fp_raw):
rsp = requests.get(
'https://login.xunlei.com/risk?cmd=algorithm&t=' +
str(time.time() * 1000)
)
sign = ''
try:
xl_al = js2py.eval_js(rsp.content)
sign = xl_al(fp_raw)
except Exception as e:
print(e)
return sign
js = self.extract_js(body)
except Exception:
# Something is wrong with the page.
# This may indicate Cloudflare has changed their anti-bot
# technique. If you see this and are running the latest version,
# please open a GitHub issue so I can update the code accordingly.
logging.error("[!] Unable to parse Cloudflare anti-bots page. "
"Try upgrading cloudflare-scrape, or submit a bug report "
"if you are running the latest version. Please read "
"https://github.com/Anorov/cloudflare-scrape#updates "
"before submitting a bug report.")
raise
# Safely evaluate the Javascript expression
params["jschl_answer"] = str(int(js2py.eval_js(js)) + len(domain))
# Requests transforms any request into a GET after a redirect,
# so the redirect has to be handled manually here to allow for
# performing other types of requests even as the first request.
method = resp.request.method
cloudflare_kwargs["allow_redirects"] = False
redirect = self.request(method, submit_url, **cloudflare_kwargs)
return self.request(method, redirect.headers["Location"], **original_kwargs)
def play_video(self, selection):
url = urlparse.urljoin(self.arconaitv_url, selection)
url = requests.get(urlparse.urljoin(url, selection), headers=self.headers).content
url = re.compile("var _(.+?)", re.DOTALL).findall(str(url))[0].strip()
url = url.replace("eval(", "var a =")
url = "var _" + url[:-1]
url = url.replace("decodeURIComponent(escape(r))", "r.slice(305,407)")
url = js2py.eval_js(url).replace("'", "")
play_item = xbmcgui.ListItem(path=url + '|User-Agent=%s' % client.agent())
xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)
js = self.extract_js(body)
except Exception:
# Something is wrong with the page.
# This may indicate Cloudflare has changed their anti-bot
# technique. If you see this and are running the latest version,
# please open a GitHub issue so I can update the code accordingly.
logging.error("[!] Unable to parse Cloudflare anti-bots page. "
"Try upgrading cloudflare-scrape, or submit a bug report "
"if you are running the latest version. Please read "
"https://github.com/Anorov/cloudflare-scrape#updates "
"before submitting a bug report.")
raise
# Safely evaluate the Javascript expression
params["jschl_answer"] = str(int(js2py.eval_js(js)) + len(domain))
# Requests transforms any request into a GET after a redirect,
# so the redirect has to be handled manually here to allow for
# performing other types of requests even as the first request.
method = resp.request.method
cloudflare_kwargs["allow_redirects"] = False
redirect = self.request(method, submit_url, **cloudflare_kwargs)
return self.request(method, redirect.headers["Location"], **original_kwargs)
def getBattleFormatsData():
js=urllib2.urlopen("https://raw.githubusercontent.com/Zarel/Pokemon-Showdown/master/data/formats-data.js").read()
return json.loads(js2py.eval_js('exports={},'+js+'JSON.stringify(exports.BattleFormatsData)'))
destination_filename (Optional[str]): if specified, the JSON string
will be written to this file
Returns:
str : the JSON string representation of the requested data
"""
url_prefix = \
"https://raw.githubusercontent.com/Zarel/Pokemon-Showdown/master/"
if not url.startswith('https'):
url = url_prefix + url
prerun = 'exports={}; '
postrun = 'JSON.stringify(exports.'+entry+', null, 2)'
javascript = urlopen(url).read().decode('utf-8')
json_string = js2py.eval_js(prerun+javascript+postrun)
if destination_filename:
_write(json_string, destination_filename)
return json_string