def chmod (mod,filename): perm_user = int(mod[0]) perm_others = int(mod[1]) perm_guest = int(mod[2]) if permissions.check_owner (files.output(filename),files.readall("/proc/info/su")): owner = permissions.get_owner (files.output(filename)) permissions.create (files.output(filename),perm_user,perm_others,perm_guest,owner) colors.show ('','ok','Change mode of \''+filename+'\' to '+mod+'.') else: colors.show ("chmod","perm","")
def ls(path, options): if options == "": if files.isdir(path): if permissions.check(files.output(path), "r", files.readall("/proc/info/su")): list = files.list(path) list.sort() for i in list: if files.isdir(path + "/" + i): print(colors.get_path() + i + "/" + colors.get_colors()) else: print(i) else: colors.show("ls", "perm", "") else: colors.show("ls", "fail", path + ": directory not found.") elif options == "-p": if files.isdir(path): if permissions.check(files.output(path), "r", files.readall("/proc/info/su")): list = files.list(path) list.sort() for i in list: if files.isdir(path + "/" + i): perm = permissions.get_permissions(path + "/" + i) print(perm + "\t" + colors.get_path() + i + "/" + colors.get_colors()) else: perm = permissions.get_permissions(path + "/" + i) print(perm + "\t" + i) else: colors.show("ls", "perm", "") else: colors.show("ls", "fail", path + ": directory not found.") elif options == "-n": if files.isdir(path): if permissions.check(files.output(path), "r", files.readall("/proc/info/su")): list = files.list(path) list.sort() for i in list: if files.isdir(path + "/" + i): perm = permissions.get_permissions(path + "/" + i) perm = str(permissions.show_number(perm)) print(perm + "\t" + colors.get_path() + i + "/" + colors.get_colors()) else: perm = permissions.get_permissions(path + "/" + i) perm = str(permissions.show_number(perm)) print(perm + "\t" + i) else: colors.show("ls", "perm", "") else: colors.show("ls", "fail", path + ": directory not found.")
def cut(src, dest): su = files.readall("/proc/info/su") if permissions.check(files.output(src), "r", su) and permissions.check( files.output(src), "w", su): if isfile(src): if permissions.check(files.output(dest), "w", su): if files.isdir(dest): colors.show("libabr.file.cut", "fail", dest + ": dest is a directory.") else: perm = permissions.get_permissions(files.output(src)) control.write_record(files.output(dest), perm, "/etc/permtab") files.cut(src, dest) else: colors.show("libabr.file.cut", "perm", "") elif isdir(src): if permissions.check(files.output(dest), "w", su): if files.isfile(dest): colors.show("libabr.file.cut", "fail", dest + ": dest is a file.") else: perm = permissions.get_permissions(files.output(src)) control.write_record(files.output(dest), perm, "/etc/permtab") files.cutdir(src, dest) else: colors.show("libabr.file.cut", "perm", "") else: colors.show("libabr.file.cut", "fail", src + ": source not found.") else: colors.show("libabr.file.cut", "perm", "")
def isdir(name): su = files.readall("/proc/info/su") if permissions.check(files.output(name), "r", su): return files.isdir(name) else: colors.show("libabr.file.isdir", "perm", "") return None
def zip (src,dest): su = files.readall("/proc/info/su") ## Get user data base if permissions.check (files.output(src),"r",su): ## Check this user permissions if permissions.check (files.output(dest+".zip"),"r",su): ## Check read only permission if files.isdir (src): ## Check source dir exists if files.isdir (dest+".zip"): ## Check dest dir exists colors.show("libabr.archive.zip", "fail", dest+".zip" + ": dest is a directory.") else: shutil.make_archive(files.input(dest),"zip",files.input(src)) ## Create archive elif files.isfile (src): colors.show("libabr.archive.zip", "fail",src+ ": source is a file.") ## Show error for permissions else: colors.show("libabr.archive.zip", "fail",src+ ": source not found.") else: colors.show("libabr.archive.zip", "perm", "") else: colors.show ("libabr.archive.zip","perm","")
def gzip(src, dest): su = files.readall("/proc/info/su") if permissions.check(files.output(src), "r", su): if permissions.check(files.output(dest + ".gz"), "r", su): if files.isdir(src): if files.isdir(dest + ".gz"): colors.show("libabr.archive.xzip", "fail", dest + ".gz" + ": dest is a directory.") else: shutil.make_archive(files.input(dest), "gz", files.input(src)) elif files.isfile(src): colors.show("libabr.archive.gzip", "fail", src + ": source is a file.") else: colors.show("libabr.archive.gzip", "fail", src + ": source not found.") else: colors.show("libabr.archive.gzip", "perm", "") else: colors.show("libabr.archive.gzip", "perm", "")
def mkdir(name): su = files.readall("/proc/info/su") if permissions.check(files.output(name), "w", su): if isfile(name): colors.show("libabr.file.mkdir", "fail", name + ": is a file.") else: files.makedirs(name) else: colors.show("libabr.file.mkdir", "perm", "")
def mv(src, dest): if files.isdir(src): if files.isfile(dest): colors.show("mv", "fail", dest + ": dest is a file.") else: if permissions.check( files.output(src), "r", files.readall("/proc/info/su")) and permissions.check( files.output(src), "w", files.readall("/proc/info/su")): if permissions.check(files.output(dest), "w", files.readall("/proc/info/su")): perm = permissions.get_permissions(files.output(src)) control.write_record(files.output(dest), perm, "/etc/permtab") files.copydir(src, dest) files.removedirs(src) else: colors.show("mv", "perm", "") else: colors.show("mv", "perm", "") elif files.isfile(src): if files.isdir(dest): colors.show("mv", "fail", dest + ": dest is a directory.") else: if permissions.check( files.output(src), "r", files.readall("/proc/info/su")) and permissions.check( files.output(src), "w", files.readall("/proc/info/su")): if permissions.check(files.output(dest), "w", files.readall("/proc/info/su")): perm = permissions.get_permissions(files.output(src)) control.write_record(files.output(dest), perm, "/etc/permtab") files.copy(src, dest) files.remove(src) else: colors.show("mv", "perm", "") else: colors.show("mv", "perm", "") else: colors.show("mv", "fail", src + ": source not found.")
def append(name, text): su = files.readall("/proc/info/su") if permissions.check(files.output(name), "w", su): if isdir(name): colors.show("libabr.file.append", "fail", name + ": is a directory.") else: files.append(name, text) else: colors.show("libabr.file.append", "perm", "")
def set (name,value): select = files.readall("/proc/info/sel") if not select.startswith ("/proc/"): if permissions.check(files.output(select),"w",files.readall("/proc/info/su")): control.write_record(name, value, select) colors.show('', 'ok', "Set '" + name + "' as '"+value+"'.") else: colors.show ("set","perm","") else: control.write_record(name,value,select)
def sel (database_name): if files.isfile(database_name): if permissions.check (files.output(database_name),"r",files.readall("/proc/info/su")): files.write("/proc/info/sel", database_name) files.create("/proc/selected") colors.show('', 'ok', "Select '" + database_name + "' controller.") else: colors.show ("sel","perm","") else: colors.show("sel", "fail", database_name + ": controller not found.")
def chown(new_owner, name): permowner = permissions.check_owner(files.output(name), files.readall("/proc/info/su")) perm = permissions.get_permissions(files.output(name)) num = permissions.show_number(perm) num = str(num) user_p = int(num[0]) others_p = int(num[1]) guest_p = int(num[2]) if permowner == True: if new_owner == "": permissions.create(files.output(name), user_p, others_p, guest_p, files.readall("/proc/info/su")) else: permissions.create(files.output(name), user_p, others_p, guest_p, new_owner) else: colors.show("chown", "perm", "")
def compile(src, dest): su = files.readall("/proc/info/su") if permissions.check(files.output(src), "r", su): if isfile(src): if permissions.check(files.output(dest), "w", su): if files.isdir(dest): colors.show("libabr.file.compile", "fail", dest + ": dest is a directory.") else: files.compile(src, dest) else: colors.show("libabr.file.compile", "perm", "") elif isdir(src): colors.show("libabr.file.compile", "fail", src + ": source is a directory.") else: colors.show("libabr.file.compile", "fail", src + ": source not found.") else: colors.show("libabr.file.compile", "perm", "")
def unset(name): select = files.readall("/proc/info/sel") if not select.startswith("/proc/"): if permissions.check(files.output(select), "w", files.readall("/proc/info/su")): control.remove_record(name, select) colors.show('', 'ok', "Unset '" + name + "' in '" + select + ' controller.') else: colors.show("unset", "perm", "") else: control.remove_record(name, select)
def remove(name): su = files.readall("/proc/info/su") if permissions.check(files.output(name), "w", su): if isfile(name): files.remove(name) elif isdir(name): files.removedirs(name) else: colors.show("libabr.file.remove", "fail", name + ": file or directory not found.") else: colors.show("libabr.file.remove", "perm", "")
def rm(names): for i in names: if files.isdir(i): if permissions.check(files.output(i), "w", files.readall("/proc/info/su")): files.removedirs(i) colors.show('', 'ok', "Remove '" + i + "' directory.") else: colors.show("rm", "perm", "") sys.exit(0) elif files.isfile(i): if permissions.check(files.output(i), "w", files.readall("/proc/info/su")): files.remove(i) colors.show('', 'ok', "Remove '" + i + "' file.") else: colors.show("rm", "perm", "") sys.exit(0) else: colors.show("rm", "fail", i + ": file or directory not found.") sys.exit(0)
def check(filename): perm = permissions.get_permissions(files.output(filename)) numperm = permissions.show_number(perm) r = permissions.check(files.output(filename), "r", files.readall("/proc/info/su")) w = permissions.check(files.output(filename), "w", files.readall("/proc/info/su")) x = permissions.check(files.output(filename), "x", files.readall("/proc/info/su")) bold = colors.color(1, colors.get_bgcolor(), colors.get_fgcolor()) print(" Seleted path: " + bold + files.output(filename) + colors.get_colors()) print(" Permission: " + bold + perm + colors.get_colors()) print(" Permission Num: " + bold + str(numperm) + colors.get_colors()) if r == True: print(" Read: " + bold + colors.get_ok() + "Yes" + colors.get_colors()) else: print(" Read: " + bold + colors.get_fail() + "No" + colors.get_colors()) if w == True: print(" Write: " + bold + colors.get_ok() + "Yes" + colors.get_colors()) else: print(" Write: " + bold + colors.get_fail() + "No" + colors.get_colors()) if x == True: print(" Execute: " + bold + colors.get_ok() + "Yes" + colors.get_colors()) else: print(" Execute: " + bold + colors.get_fail() + "No" + colors.get_colors())
def readall(name): su = files.readall("/proc/info/su") if permissions.check(files.output(name), "r", su): if files.isfile(name): file = open(files.input(name), "rb") check_bin = str(file.read()) file.close() if check_bin.__contains__("\\x00"): return check_bin else: return files.readall(name) else: colors.show("libabr.file.readall", "fail", name + ": file not found.") else: colors.show("libabr.file.readall", "perm", "")
def getv(): select = files.readall("/proc/info/sel") if not select.startswith("/proc/"): if permissions.check(files.output(select), "w", files.readall("/proc/info/su")): listinfo = files.list("/proc/info") for i in listinfo: control.write_record(i, files.readall("/proc/info/" + i), select) else: colors.show("getv", "perm", "") else: listinfo = files.list("/proc/info") for i in listinfo: control.write_record(i, files.readall("/proc/info/" + i), select) colors.show('', 'ok', 'Insert informations into \'' + select + "\' controller.")
def cd(path): if permissions.check(files.output(path), "r", files.readall("/proc/info/su")): if path == '..': pwd = files.readall('/proc/info/pwd') pwd = pwd.split('/') lens = len(pwd) - 1 pwd.pop(lens) strv = '' for i in pwd: strv += "/" + i pwd = files.output_shell(strv) files.write("/proc/info/pwd", pwd) elif files.isdir(path): files.write("/proc/info/pwd", files.output_shell(path)) else: colors.show("cd", "fail", path + ": directory not found.") else: colors.show("cd", "perm", "")
####################################################################################### # In the name of God, the Compassionate, the Merciful # Pyabr (c) 2020 Pasand team. GNU General Public License v3.0 # # Offical website: http://itpasand.com # Telegram or Gap channel: @pyabr # Telegram or Gap group: @pyabr_community # Git source: github.com/pasandteam/pyabr # ####################################################################################### import sys from libnam import permissions, files, colors user = files.readall("/proc/info/su") select = files.readall("/proc/info/sel") if not select.startswith("/proc/"): if permissions.check(files.output(select), "w", user): files.create(select) text = 'Clean the \'' + select + "' controller." colors.show('', 'ok', text) else: colors.show("clean", "perm", "") else: files.create(select)
def cat(name, option): ## Read files ## if option == '' or option == '-r': if files.isfile(name): if permissions.check(files.output(name), "r", files.readall("/proc/info/su")): file = open(files.input(name), "rb") check_bin = str(file.read()) file.close() if check_bin.__contains__("\\x00"): print(check_bin) else: print(files.readall(name)) else: colors.show("cat", "perm", "") elif files.isdir(name): colors.show("cat", "fail", name + ": is a directory.") else: colors.show("cat", "fail", name + ": file not found.") ## Create files ## elif option == '-c': if files.isdir(name): colors.show("cat", "fail", name + ": is a directory.") else: if permissions.check(files.output(name), "w", files.readall("/proc/info/su")): files.create(name) else: colors.show("cat", "perm", "") ## Write into files ## elif option == '-w': if files.isdir(name): colors.show("cat", "fail", name + ": is a directory.") else: if permissions.check(files.output(name), "w", files.readall("/proc/info/su")): ## Set EOF if cmdln[3:] == []: EOF = 'EOF' else: EOF = cmdln[3] # WRITE COMMAND LINE texts = '' while True: cmd = input('> ') if cmd == EOF: break else: if texts == '': texts = cmd else: texts = texts + '\n' + cmd ## WRITE INTO FILE files.write(cmdln[2], texts) else: colors.show("cat", "perm", "") ## Write into files ## elif option == '-a': if files.isdir(name): colors.show("cat", "fail", name + ": is a directory.") else: if permissions.check(files.output(name), "w", files.readall("/proc/info/su")): ## Set EOF if cmdln[3] == []: EOF = 'EOF' else: EOF = cmdln[3] # WRITE COMMAND LINE texts = '' while True: cmd = input('> ') if cmd == EOF: break else: if texts == '': texts = cmd else: texts = texts + '\n' + cmd ## WRITE INTO FILE files.append(cmdln[2], texts) else: colors.show("cat", "perm", "")
colors.show("kernel", "stop", "") sys.exit(0) colors.argv = argv[0] ## Set color argv ## @core/exec ## if argv[0] == 'exec': user = files.readall("/proc/info/su") if (argv[1:] == [] or argv[1] == "" or argv[1] == " " or argv[1].startswith(";")): print(end='') elif argv[1].__contains__("/"): if files.isfile(argv[1] + ".so"): if permissions.check(files.output(argv[1]) + ".so", "x", user): ## Set args ## sys.argv = argv[1:] appname = argv[1] sys.path.append(files.parentdir(appname)) __import__(files.filename(appname)) sys.path.remove(files.parentdir(appname)) else: colors.show(argv[1], "perm", "") elif files.isfile(argv[1]): if permissions.check(files.output(argv[1]), "x", user): ## command ## command = [files.input(argv[1])]
# Telegram or Gap group: @pyabr_community # Git source: github.com/pasandteam/pyabr # ####################################################################################### import sys, os, hashlib from libnam import files, control, permissions, colors, process from libabr import core if sys.argv[1:] == []: colors.show("saye", "fail", "no inputs.") sys.exit(0) filename = sys.argv[1] if not permissions.check( files.output(filename) + '.sa', "x", files.readall("/proc/info/su")): colors.show("saye", "perm", "") sys.exit(0) if not files.isfile(filename + '.sa'): colors.show("saye", "fail", filename + ": script file not found.") sys.exit(0) cmdall = control.read_list(filename + '.sa') k = 0 for cmd in cmdall: k = k + 1 ## Create cmdln with variables ## cmdln = cmd.split(" ")
# Pyabr (c) 2020 Pasand team. GNU General Public License v3.0 # # Offical website: http://itpasand.com # Telegram or Gap channel: @pyabr # Telegram or Gap group: @pyabr_community # Git source: github.com/pasandteam/pyabr # ####################################################################################### import sys, shutil, os, requests from libnam import files, permissions, colors # https://www.tutorialspoint.com/downloading-files-from-web-using-python ## Check params ## if sys.argv[1:] == [] and sys.argv[2:]: colors.show('wget', 'fail', 'no inputs.') ## Download ## colors.show('', 'ok', 'Download \'' + sys.argv[2] + "\' from (" + sys.argv[1] + ") ...") url = sys.argv[1] r = requests.get(url, allow_redirects=True) ## Check permissions ## if permissions.check(files.output(sys.argv[2]), "w", files.readall("/proc/info/su")): open(files.input(sys.argv[2]), 'wb').write(r.content) else: colors.show("wget", "perm", "")
colors.show("ls", "perm", "") else: colors.show("ls", "fail", path + ": directory not found.") elif options == "-n": if files.isdir(path): if permissions.check(files.output(path), "r", files.readall("/proc/info/su")): list = files.list(path) list.sort() for i in list: if files.isdir(path + "/" + i): perm = permissions.get_permissions(path + "/" + i) perm = str(permissions.show_number(perm)) print(perm + "\t" + colors.get_path() + i + "/" + colors.get_colors()) else: perm = permissions.get_permissions(path + "/" + i) perm = str(permissions.show_number(perm)) print(perm + "\t" + i) else: colors.show("ls", "perm", "") else: colors.show("ls", "fail", path + ": directory not found.") if not sys.argv[1:] == [] and sys.argv[2:] == []: ls(files.output(sys.argv[1]), "") elif not sys.argv[1:] == [] and not sys.argv[2:] == []: ls(files.output(sys.argv[1]), sys.argv[2]) elif sys.argv[1:] == []: ls(files.readall("/proc/info/pwd"), "")