zxc111 / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

How to load contents of alert screen ? #231

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using Pyv8 to display an deobfuscated HTML file's contents(using 'alert') 
on cmd. But I need double-decoding to see complete code. Can I make 
first-decoded file's contents on alert screen as a HTML file?

I'll show you simple examples to get answers.

↓ First, It's content of test.html
a="abcdefgh"
b="bcdefghi"
c="cdefghij"
d="defghijk"

↓ Second, It's content of test.py to remove 'a' and add 'alert(b)', 
'alert(c)'.
import sys,re,PyV8

class Global(PyV8.JSClass):

    def alert(self, value):
        print value

ctx = PyV8.JSContext(Global())
ctx.enter()

original=open ('test.html','r').read()

if original.find("a+?'"):
    original = re.sub("a+?'",'',original)

first=original+'''alert(b)\n'''+'''alert(c)'''

open('decode.html','w').write(first)

print ctx.eval(first)

↓ compile result of test.py
bcdefghi
cdefghij
None

and I want to add string this code. ( alert(d) )

↓ I tried it........
import sys,re,PyV8

class Global(PyV8.JSClass):

    def alert(self, value):
        print value

ctx = PyV8.JSContext(Global())
ctx.enter()

original=open ('test.html','r').read()

if original.find("a+?'"):
    original = re.sub("a+?'",'',original)

first=original+'''alert(b)\n'''+'''alert(c)'''

open('decode.html','w').write(first)

second = ctx.eval(first) + 'alert(d)'

↓ I only get ctx.eval(fist) and error message.
bcdefghi
cdefghij

Traceback (most recent call last):
  File "C:/Users/KOREA/Desktop/test.py", line 20, in <module>
    second = ctx.eval(first) + 'alert(d)'
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

How to process " second = ctx.eval(first) + 'alert(d)' " ? plz help.

1.I print an HTML file's contents on html using Pyv8 with 'alert'

2.I want to make and write file with printed content in alert screen

3.I tried like second = ctx.eval(first) + 'alert(d)' and only to get error 
message.

Original issue reported on code.google.com by Clanic....@gmail.com on 12 Apr 2014 at 10:53