-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge from develop, release for 1.1.0
- Loading branch information
Showing
7 changed files
with
211 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
|
||
""" | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
:author: lightless <[email protected]> | ||
:homepage: None | ||
:license: GPL-3.0, see LICENSE for more details. | ||
:copyright: Copyright (c) 2017 lightless. All rights reserved | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
|
||
""" | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
:author: lightless <[email protected]> | ||
:homepage: None | ||
:license: GPL-3.0, see LICENSE for more details. | ||
:copyright: Copyright (c) 2017 lightless. All rights reserved | ||
""" | ||
|
||
import ast | ||
|
||
|
||
# rule_content = "'password' in {{content}} and 'token' not in {{content}}" | ||
rule_content = '[x for x in {}.__class__.__bases__[0].__subclasses__() if x.__name__ == "zipimporter"]' | ||
# rule_content = '[].__class__.__mro__[-1].__subclasses__()' | ||
filter_content = "aaaabbbcccdde\naaacccbdbadjf" | ||
# filter_content = "aaaabbbcccdde\naaacccbdbadjf\npassword=123" | ||
|
||
# print("globals: {}".format(globals())) | ||
# print("locals: {}".format(locals())) | ||
|
||
code = rule_content.replace("{{content}}", "filter_content") | ||
print("final code: {}".format(code)) | ||
|
||
result = eval(code, {"__builtins__": None}, {"filter_content": filter_content}) | ||
print(result) | ||
|
||
|
||
# class ASTNode(ast.NodeVisitor): | ||
# def generic_visit(self, node): | ||
# print("node: {}".format(dir(node.body))) | ||
# print("node: {}".format(node.body.keywords)) | ||
# print("node name: {}".format(type(node))) | ||
# | ||
# | ||
# n = ast.parse(code, '<usercode>', "eval") | ||
# v = ASTNode() | ||
# v.visit(n) | ||
# | ||
# print("global node: {}".format(n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
|
||
""" | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
:author: lightless <[email protected]> | ||
:homepage: None | ||
:license: GPL-3.0, see LICENSE for more details. | ||
:copyright: Copyright (c) 2017 lightless. All rights reserved | ||
""" | ||
from lupa import LuaRuntime | ||
|
||
lua = LuaRuntime() | ||
lua.eval("1+1") | ||
|
||
|
||
# rule_content = "'password' in {{content}} and 'token' not in {{content}}".replace("\'", "\"") | ||
rule_content = '[x for x in {}.__class__.__bases__[0].__subclasses__() if x.__name__ == "zipimporter"]' | ||
# rule_content = '[].__class__.__mro__[-1].__subclasses__()' | ||
# filter_content = "aaaabbbcccdde\naaacccbdbadjf" | ||
filter_content = "aaaabbbcccdde\naaacccbdbadjf\npassword=123" | ||
|
||
code = rule_content.replace("{{content}}", "filter_content") | ||
code = "python.eval(\'{code}\')".format(code=code) | ||
print("final code: {}".format(code)) | ||
|
||
result = lua.eval(code) | ||
print("result: {}".format(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
|
||
""" | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
:author: lightless <[email protected]> | ||
:homepage: None | ||
:license: GPL-3.0, see LICENSE for more details. | ||
:copyright: Copyright (c) 2017 lightless. All rights reserved | ||
""" | ||
|
||
import time | ||
import multiprocessing | ||
|
||
|
||
def worker(): | ||
print("start long job!") | ||
time.sleep(15) | ||
print("end long job!") | ||
|
||
|
||
p = multiprocessing.Process(target=worker) | ||
p.start() | ||
|
||
# try: | ||
# print("start join!") | ||
# p.join(5) | ||
# print("join done!") | ||
# except multiprocessing.TimeoutError: | ||
# print("timeout!") | ||
# p.terminate() | ||
|
||
# 下面这段是正确的杀掉子进程的方法 | ||
# 确认下queue会不会导致内存泄露 | ||
p.join(5) | ||
if p.is_alive(): | ||
print("still alive! kill it!") | ||
p.terminate() | ||
p.join() | ||
|
||
|
||
print("main done!") | ||
|
||
while True: | ||
time.sleep(1) |