Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, input_string, opts):
BaseTokenizer.__init__(self, input_string, opts)
# This is not pretty, but given how we did the version import
# it is the only way to do this without having setup.py fail on a missing
# six dependency.
self._six = __import__("six")
import jsbeautifier.javascript.acorn as acorn
self.acorn = acorn
self.in_html_comment = False
self.has_char_escapes = False
# comment ends just before nearest linefeed or end of file
# IMPORTANT: This string must be run through six to handle \u chars
self._whitespace_pattern = re.compile(
self._six.u(r'[\n\r\u2028\u2029\t\u000B\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff ]+'))
self._newline_pattern = re.compile(
self._six.u(r'([^\n\r\u2028\u2029]*)(\r\n|[\n\r\u2028\u2029])?'))
# // comment ends just before nearest linefeed or end of file
self.comment_pattern = re.compile(
self._six.u(r'//([^\n\r\u2028\u2029]*)'))
#!/usr/bin/env python2
import sys
from sys import stdout
import re
from jsbeautifier import beautify, default_options
tests_passed = 0
opts = default_options()
opts.indent_size = 4
opts.indent_char = ' '
opts.preserve_newlines = True
opts.jslint_happy = False
opts.keep_array_indentation = False
opts.brace_style = 'collapse'
def test_fragment(input, expectation = None):
global opts
if expectation == None:
expectation = input
res = beautify(input, opts)
if res != expectation:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import os
import copy
import jsbeautifier
options = jsbeautifier.default_options()
options.wrap_line_length = 80
data = ''
data_min = ''
def beautifier_test_underscore():
jsbeautifier.beautify(data, options)
def beautifier_test_underscore_min():
jsbeautifier.beautify(data_min, options)
def beautifier_test_github_min():
jsbeautifier.beautify(github_min, options)
juicers = [
(r"}\('(.*)', *(\d+|\[\]), *(\d+), *'(.*)'\.split\('\|'\), *(\d+), *(.*)\)\)"),
(r"}\('(.*)', *(\d+|\[\]), *(\d+), *'(.*)'\.split\('\|'\)"),
]
for juicer in juicers:
args = re.search(juicer, source, re.DOTALL)
if args:
a = args.groups()
if a[1] == "[]":
a = list(a)
a[1] = 62
a = tuple(a)
try:
return a[0], a[3].split('|'), int(a[1]), int(a[2])
except ValueError:
raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
# could not find a satisfying regex
raise UnpackingError(
'Could not make sense of p.a.c.k.e.r data (unexpected code structure)')
def _filterargs(source):
"""Juice from a source file the four args needed by decoder."""
argsregex = (r"}\('(.*)', *(\d+), *(\d+), *'(.*)'\."
r"split\('\|'\), *(\d+), *(.*)\)\)")
args = re.search(argsregex, source, re.DOTALL).groups()
try:
return args[0], args[3].split('|'), int(args[1]), int(args[2])
except ValueError:
raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
]
for juicer in juicers:
args = re.search(juicer, source, re.DOTALL)
if args:
a = args.groups()
if a[1] == "[]":
a = list(a)
a[1] = 62
a = tuple(a)
try:
return a[0], a[3].split('|'), int(a[1]), int(a[2])
except ValueError:
raise UnpackingError('Corrupted p.a.c.k.e.r. data.')
# could not find a satisfying regex
raise UnpackingError(
'Could not make sense of p.a.c.k.e.r data (unexpected code structure)')
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = ['--assert=plain'] + [DIR + \
x for x in os.listdir(DIR) if x.endswith('.py') and x[0] not in '._']
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
setup(name='jsbeautifier',
version=__version__,
description='JavaScript unobfuscator and beautifier.',
long_description=('Beautify, unpack or deobfuscate JavaScript. '
'Handles popular online obfuscators.'),
author='Liam Newman, Einar Lielmanis, et al.',
author_email='team@beautifier.io',
url='https://beautifier.io',
entry_points={
'console_scripts': [
'js-beautify = jsbeautifier:main'
]
},
packages=['jsbeautifier',
'jsbeautifier.tests', 'jsbeautifier.tests.generated',
'jsbeautifier.core',
'jsbeautifier.javascript',
'jsbeautifier.unpackers', 'jsbeautifier.unpackers.tests'],
import jsbeautifier
import sys
import os
import random
filename = sys.argv[2]+"-"+str(os.times()[4])+"-"+str(random.randint(1,99999))+".txt"
os.system("copy NUL db/"+filename)
parser = open(sys.argv[1],"r")
body = parser.read().split('\r\n\r\n')
with open("db/"+filename,'w') as f:
f.write(body[1])
parser.close()
res = jsbeautifier.beautify_file("db/"+filename)
with open("db/"+filename,'w') as f:
f.write(res)
print filename
final = ""
hdr = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:37.0) Gecko/20100101 Firefox/37.0'
print('--------findurl-----',url)
if "myvidstream" in str(url):
#print("myvidstream="+url
packed = ''
content = ccurl(url,"")
soup = BeautifulSoup(content,'lxml')
link = soup.findAll('script',{'type':'text/javascript'})
for i in link:
if 'myvidstream' in i.text:
#print(i.text)
packed = i.text
break
if packed:
val = packer.unpack(packed)
print(val)
soup = BeautifulSoup(val,'lxml')
m = (re.search('file[^)]*',val)).group()
print(m)
if m:
n = re.search("http[^']*",m).group()
if n:
print(n)
final = n
final = re.sub(' |"','',final)
final = re.sub("'",'',final)
fi = final.split('\\')
if fi:
final = fi[0]
else:
found = ""
return found
elif "myvidstream" in i:
packed = ''
final = ""
content = ccurl(i)
soup = BeautifulSoup(content,'lxml')
link = soup.findAll('script',{'type':'text/javascript'})
for i in link:
if 'myvidstream' in i.text:
#print(i.text)
packed = i.text
break
if packed:
val = packer.unpack(packed)
print(val)
soup = BeautifulSoup(val,'lxml')
m = (re.search('file[^)]*',val)).group()
print(m)
if m:
n = re.search("http[^']*",m).group()
if n:
print(n)
final = n
final = re.sub(' |"','',final)
final = re.sub("'",'',final)
fi = final.split('\\')
if fi:
final = fi[0]
"""
link = re.findall('eval[(][^"]*.split',content)