-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcn.py
More file actions
32 lines (27 loc) · 1.26 KB
/
cn.py
File metadata and controls
32 lines (27 loc) · 1.26 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
from utils import randomString
from requests import post, get
from hpparser import findCode
class Context:
def __init__(self) -> None:
self.token = randomString(24)
self.LOGIN_PAYLOAD = 'user=admin&password=senhafoda'
self.cookies = None
def authenticate(self):
authResponse = get("http://www.bancocn.com/admin/login.php")
self.cookies = authResponse.cookies
post('http://www.bancocn.com/admin/index.php', data=self.LOGIN_PAYLOAD, allow_redirects=True, cookies=self.cookies, headers={
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
'Content-Type': 'application/x-www-form-urlencoded'
})
# Returns the show url
def upload(self, title: str, fileName: str, contents, category: int = 1) -> str:
files = {
'image': (fileName, contents, "image/png"),
}
it = post('http://www.bancocn.com/admin/index.php', files=files, data={
'category': category,
'Add': 'Add',
'title': title
}, cookies=self.cookies)
assert it.status_code == 200
return findCode(it.text, title).replace('..', 'http://www.bancocn.com/')