add main branch files
This commit is contained in:
10
scripts/abi_gki_all.py
Normal file
10
scripts/abi_gki_all.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from xml.dom.minidom import parse
|
||||
import xml.dom.minidom
|
||||
import sys
|
||||
|
||||
|
||||
DOMTree = xml.dom.minidom.parse(sys.argv[1])
|
||||
symbols = DOMTree.getElementsByTagName("elf-symbol")
|
||||
print("[abi_symbol_list]")
|
||||
for symbol in symbols:
|
||||
print(" " + symbol.getAttribute("name"))
|
||||
50
scripts/add_device_handler.py
Normal file
50
scripts/add_device_handler.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
assert len(sys.argv) == 2
|
||||
file_name = sys.argv[1]
|
||||
github = "https://github.com/"
|
||||
issue_content = os.environ["ISSUE_CONTENT"]
|
||||
lines = issue_content.split("\n\n")
|
||||
assert len(lines) == 6
|
||||
url = lines[1]
|
||||
print(url)
|
||||
device = lines[3]
|
||||
print(device)
|
||||
code_of_conduct = lines[5]
|
||||
print(code_of_conduct)
|
||||
assert code_of_conduct.find("[X]") > 0
|
||||
tmp = url.removesuffix("/").replace(github, "").split("/")
|
||||
print(tmp)
|
||||
assert len(tmp) == 2
|
||||
maintainer = tmp[0]
|
||||
print(maintainer)
|
||||
maintainer_link = "%s%s" % (github, maintainer)
|
||||
print(maintainer_link)
|
||||
kernel_name = tmp[1]
|
||||
print(kernel_name)
|
||||
kernel_link = "%s%s/%s" % (github, maintainer, kernel_name)
|
||||
print(kernel_link)
|
||||
with open(file_name, "r") as f:
|
||||
data = json.loads(f.read())
|
||||
data.append(
|
||||
{
|
||||
"maintainer": maintainer,
|
||||
"maintainer_link": maintainer_link,
|
||||
"kernel_name": kernel_name,
|
||||
"kernel_link": kernel_link,
|
||||
"devices": device,
|
||||
}
|
||||
)
|
||||
os.remove(file_name)
|
||||
with open(file_name, "w") as f:
|
||||
f.write(json.dumps(data, indent=4))
|
||||
os.system("echo success=true >> $GITHUB_OUTPUT")
|
||||
os.system("echo device=%s >> $GITHUB_OUTPUT" % device)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
89
scripts/allowlist.bt
Normal file
89
scripts/allowlist.bt
Normal file
@@ -0,0 +1,89 @@
|
||||
// Define constants as per the provided structure.
|
||||
#define KSU_MAX_PACKAGE_NAME 256
|
||||
#define KSU_MAX_GROUPS 32
|
||||
#define KSU_SELINUX_DOMAIN 64
|
||||
|
||||
// Define the root_profile structure with padding for 64-bit alignment.
|
||||
struct root_profile {
|
||||
uint32 uid;
|
||||
uint32 gid;
|
||||
|
||||
uint32 groups_count;
|
||||
uint32 groups[KSU_MAX_GROUPS];
|
||||
char padding1[4]; // Padding for 64-bit alignment.
|
||||
|
||||
struct {
|
||||
uint64 effective;
|
||||
uint64 permitted;
|
||||
uint64 inheritable;
|
||||
} capabilities;
|
||||
|
||||
char selinux_domain[KSU_SELINUX_DOMAIN];
|
||||
|
||||
uint32 namespaces;
|
||||
char padding2[4]; // Padding for 64-bit alignment.
|
||||
};
|
||||
|
||||
// Define the non_root_profile structure with padding for 64-bit alignment.
|
||||
struct non_root_profile {
|
||||
byte umount_modules;
|
||||
char padding[7]; // Padding to make the total size a multiple of 8.
|
||||
};
|
||||
|
||||
// Define the rp_config structure with padding for 64-bit alignment.
|
||||
struct rp_config_t {
|
||||
byte use_default;
|
||||
|
||||
char template_name[KSU_MAX_PACKAGE_NAME];
|
||||
char padding[7]; // Padding to make the total size a multiple of 8.
|
||||
|
||||
struct root_profile profile;
|
||||
};
|
||||
|
||||
// Define the nrp_config structure with padding for 64-bit alignment.
|
||||
struct nrp_config_t {
|
||||
byte use_default;
|
||||
char padding1[7]; // Padding to make the total size a multiple of 8.
|
||||
|
||||
struct non_root_profile profile;
|
||||
char padding2[488]; // Padding to align the union
|
||||
};
|
||||
|
||||
// Define the main app_profile structure
|
||||
typedef struct {
|
||||
uint32 version;
|
||||
char key[KSU_MAX_PACKAGE_NAME];
|
||||
int32 current_uid;
|
||||
int64 allow_su;
|
||||
|
||||
// Based on allow_su, decide which profile to use
|
||||
if (allow_su != 0) {
|
||||
rp_config_t rp_config;
|
||||
} else {
|
||||
nrp_config_t nrp_config;
|
||||
}
|
||||
|
||||
} app_profile;
|
||||
|
||||
// Define the file header with magic number and version
|
||||
typedef struct {
|
||||
uint32 magic;
|
||||
uint32 version;
|
||||
} file_header;
|
||||
|
||||
// Main entry for parsing the file
|
||||
file_header header;
|
||||
|
||||
if (header.magic != 0x7f4b5355) {
|
||||
Printf("Invalid file magic number.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
FSeek(8); // Skip the header
|
||||
|
||||
|
||||
// Continually read app_profile instances until end of file
|
||||
while (!FEof()) {
|
||||
app_profile profile;
|
||||
}
|
||||
|
||||
51
scripts/bin2c.py
Normal file
51
scripts/bin2c.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
|
||||
line_size = 80
|
||||
|
||||
|
||||
def bin2c(filename, varname='data'):
|
||||
if not os.path.isfile(filename):
|
||||
print('File "%s" is not found!' % filename)
|
||||
return ''
|
||||
if not re.match('[a-zA-Z_][a-zA-Z0-9_]*', varname):
|
||||
print('Invalid variable name "%s"' % varname)
|
||||
return
|
||||
with open(filename, 'rb') as in_file:
|
||||
data = in_file.read()
|
||||
# limit the line length
|
||||
byte_len = 6 # '0x00, '
|
||||
out = 'unsigned int %s_size = %d;\n' \
|
||||
'const char %s[%d] = {\n' % (varname, len(data), varname, len(data))
|
||||
line = ''
|
||||
for byte in data:
|
||||
line += '0x%02x, ' % byte
|
||||
if len(line) + 4 + byte_len >= line_size:
|
||||
out += ' ' * 4 + line + '\n'
|
||||
line = ''
|
||||
# add the last line
|
||||
if len(line) + 4 + byte_len < line_size:
|
||||
out += ' ' * 4 + line + '\n'
|
||||
# strip the last comma
|
||||
out = out.rstrip(', \n') + '\n'
|
||||
out += '};'
|
||||
return out
|
||||
|
||||
|
||||
def main():
|
||||
""" Main func """
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'filename', help='filename to convert to C array')
|
||||
parser.add_argument(
|
||||
'varname', nargs='?', help='variable name', default='data')
|
||||
args = parser.parse_args()
|
||||
# print out the data
|
||||
print(bin2c(args.filename, args.varname))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
106
scripts/ksubot.py
Normal file
106
scripts/ksubot.py
Normal file
@@ -0,0 +1,106 @@
|
||||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
from telethon import TelegramClient
|
||||
|
||||
API_ID = 611335
|
||||
API_HASH = "d524b414d21f4d37f08684c1df41ac9c"
|
||||
|
||||
|
||||
BOT_TOKEN = os.environ.get("BOT_TOKEN")
|
||||
CHAT_ID = os.environ.get("CHAT_ID")
|
||||
MESSAGE_THREAD_ID = os.environ.get("MESSAGE_THREAD_ID")
|
||||
COMMIT_URL = os.environ.get("COMMIT_URL")
|
||||
COMMIT_MESSAGE = os.environ.get("COMMIT_MESSAGE")
|
||||
RUN_URL = os.environ.get("RUN_URL")
|
||||
TITLE = os.environ.get("TITLE")
|
||||
VERSION = os.environ.get("VERSION")
|
||||
MSG_TEMPLATE = """
|
||||
**{title}**
|
||||
#ci_{version}
|
||||
```
|
||||
{commit_message}
|
||||
```
|
||||
[Commit]({commit_url})
|
||||
[Workflow run]({run_url})
|
||||
""".strip()
|
||||
|
||||
|
||||
def get_caption():
|
||||
msg = MSG_TEMPLATE.format(
|
||||
title=TITLE,
|
||||
version=VERSION,
|
||||
commit_message=COMMIT_MESSAGE,
|
||||
commit_url=COMMIT_URL,
|
||||
run_url=RUN_URL,
|
||||
)
|
||||
if len(msg) > 1024:
|
||||
return COMMIT_URL
|
||||
return msg
|
||||
|
||||
|
||||
def check_environ():
|
||||
global CHAT_ID, MESSAGE_THREAD_ID
|
||||
if BOT_TOKEN is None:
|
||||
print("[-] Invalid BOT_TOKEN")
|
||||
exit(1)
|
||||
if CHAT_ID is None:
|
||||
print("[-] Invalid CHAT_ID")
|
||||
exit(1)
|
||||
else:
|
||||
try:
|
||||
CHAT_ID = int(CHAT_ID)
|
||||
except:
|
||||
pass
|
||||
if COMMIT_URL is None:
|
||||
print("[-] Invalid COMMIT_URL")
|
||||
exit(1)
|
||||
if COMMIT_MESSAGE is None:
|
||||
print("[-] Invalid COMMIT_MESSAGE")
|
||||
exit(1)
|
||||
if RUN_URL is None:
|
||||
print("[-] Invalid RUN_URL")
|
||||
exit(1)
|
||||
if TITLE is None:
|
||||
print("[-] Invalid TITLE")
|
||||
exit(1)
|
||||
if VERSION is None:
|
||||
print("[-] Invalid VERSION")
|
||||
exit(1)
|
||||
if MESSAGE_THREAD_ID is not None and MESSAGE_THREAD_ID != "":
|
||||
try:
|
||||
MESSAGE_THREAD_ID = int(MESSAGE_THREAD_ID)
|
||||
except:
|
||||
print("[-] Invaild MESSAGE_THREAD_ID")
|
||||
exit(1)
|
||||
else:
|
||||
MESSAGE_THREAD_ID = None
|
||||
|
||||
|
||||
async def main():
|
||||
print("[+] Uploading to telegram")
|
||||
check_environ()
|
||||
files = sys.argv[1:]
|
||||
print("[+] Files:", files)
|
||||
if len(files) <= 0:
|
||||
print("[-] No files to upload")
|
||||
exit(1)
|
||||
print("[+] Logging in Telegram with bot")
|
||||
script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||
session_dir = os.path.join(script_dir, "ksubot")
|
||||
async with await TelegramClient(session=session_dir, api_id=API_ID, api_hash=API_HASH).start(bot_token=BOT_TOKEN) as bot:
|
||||
caption = [""] * len(files)
|
||||
caption[-1] = get_caption()
|
||||
print("[+] Caption: ")
|
||||
print("---")
|
||||
print(caption)
|
||||
print("---")
|
||||
print("[+] Sending")
|
||||
await bot.send_file(entity=CHAT_ID, file=files, caption=caption, reply_to=MESSAGE_THREAD_ID, parse_mode="markdown")
|
||||
print("[+] Done!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
asyncio.run(main())
|
||||
except Exception as e:
|
||||
print(f"[-] An error occurred: {e}")
|
||||
Reference in New Issue
Block a user