示例#1
0
def exit_error(error=0, line=None, file=None):
    """Exits the interreter with a error state."""
    if error == 0:
        print(file, "is a directory \nUSAGE: monty file", file=stderr)
    if error == 1:
        print("USAGE: monty file", file=stderr)
    if error == 2:
        print("Error: Can't open file", file)
    if error == 3:
        print("L" + str(line) + ": unknown instruction", file, file=stderr)
    if error == 4:
        print("L" + str(line) + ": usage: push integer", file=stderr)
    if error == 5:
        print("L" + str(line) + ": can't pint, stack empty", file=stderr)
    if error == 6:
        print("L" + str(line) + ": can't pop an empty stack", file=stderr)
    if error == 7:
        print("L" + str(line) + ": can't swap, stack too short", file=stderr)
    if error == 8:
        print("L" + str(line) + ": can't add, stack too short", file=stderr)
    if error == 9:
        print("L" + str(line) + ": can't sub, stack too short", file=stderr)
    if error == 10:
        print("L" + str(line) + ": division by zero", file=stderr)
    if error == 11:
        print("L" + str(line) + ": can't div, stack too short", file=stderr)
    if error == 12:
        print("L" + str(line) + ": can't mul, stack too short", file=stderr)
    if error == 13:
        print("L" + str(line) + ": division by zero", file=stderr)
    if error == 14:
        print("L" + str(line) + ": can't mod, stack too short", file=stderr)
    exit_(1)
def check_firmware():
    """
    Checks firmware existence
    """
    if not path.exists('tmp/META-INF/com/google/android/update-binary') \
            or not path.exists('tmp/META-INF/com/google/android/updater-script'):
        print("This zip isn't a valid ROM!")
        rmtree("tmp")
        exit_(2)
def main():
    """
    Xiaomi Flashable Firmware Creator
    """
    rom, process = arg_parse()
    init()
    fw_type = firmware_type(rom)
    if fw_type == 'qcom':
        if process == "firmware":
            print(f"Unzipping MIUI... ({fw_type}) device")
            firmware_extract(rom, process)
            firmware_updater()
        elif process == "nonarb":
            print("Unzipping MIUI..")
            firmware_extract(rom, process)
            print("Generating updater-script..")
            nonarb_updater()
        elif process == "firmwareless":
            print("Unzipping MIUI..")
            rom_extract(rom)
            print("Generating updater-script..")
            firmwareless_updater()
        elif process == "vendor":
            print("Unzipping MIUI..")
            vendor_extract(rom)
            print("Generating updater-script..")
            vendor_updater()
    elif fw_type == 'mtk':
        if process == "firmware":
            print(f"Unzipping MIUI... ({fw_type}) device")
            mtk_firmware_extract(rom)
            mtk_firmware_updater()
        elif process == "vendor":
            print("Unzipping MIUI..")
            vendor_extract(rom)
            print("Generating updater-script..")
            mtk_vendor_updater()
        else:
            print('Unsupported operation for MTK. Exiting!')
            exit_(3)
    else:
        print("I couldn't find firmware! Exiting.")
        exit_(4)
    make_zip(rom, process)
示例#4
0
def main():
    """Find all files to commit and normalize them before the commit takes place."""
    action = retrieveActionType()
    ignore = retrieveIgnoreList()
    normalize_fn = retrieveNormalizationFunction()
    required = copyrightHeaderMustExist()
    # We always want to extend the copyright year range with the current
    # year.
    year = datetime.now().year

    for file_git_path in filter(isValidFile, changedFiles()):
        # When amending commits it is possible that all changes to a file
        # are reverted. In this case we want to omit this file from
        # normalization because we effectively made no changes to the file
        # and, hence, we should not touch the copyright header either.
        # Unfortunately, we have no way of knowing whether we are dealing
        # with an amendment or a new commit.
        if stagedChangesRevertFileContent(file_git_path):
            continue

        try:
            found = normalizeStagedFile(file_git_path,
                                        normalize_fn,
                                        year,
                                        action,
                                        ignore=ignore)
            # If a copyright header is required but we did not find one we
            # signal that to the user and abort.
            if required and found <= 0:
                print("Error: No copyright header found in %s" % file_git_path,
                      file=stderr)
                exit_(1)
        except UnicodeDecodeError:
            # We may get a decode error in case of a binary file that we
            # simply cannot handle properly. We want to ignore those files
            # silently.
            pass
        except Exception as e:
            print("The copyright pre-commit hook encountered an error while "
                  "processing file %s: \"%s\"" % (file_git_path, e),
                  file=stderr)
            print_exc(file=stderr)
            exit_(1)
示例#5
0
# WORK
ssh = SSHClient()
ssh.set_missing_host_key_policy(AutoAddPolicy())

for idx, s in enumerate(passwords):
    try:
        ssh.connect(hostname=server,
                    username=login,
                    password=s,
                    port=port,
                    timeout=timeout)
    except:
        if idx == len(passwords) - 1:
            print(returns["ConnFailed"])
            exit_()
        else:
            continue
    else:
        break

try:
    stdin, stdout, stderr = ssh.exec_command("printPart")

    data = stdout.read().decode()
    data = data[data.index("lastWriteTime"):data.index("wrFiles")]
    data = data.split()

    date1 = data[0].split(":")[1]
    date1 = date1.split("-")
    date1 = [int(s) for s in date1]
示例#6
0
argc = len(argv)
filename = None
step = 4096
args = argv[1:]
argc -= 1
zstd_path = None

for i in range(argc):
    lowered = args[i].lower()
    is_last = i == argc - 1
    if lowered == '--help' or lowered == '-h':
        print('--help - Display information.')
        print('--step {int} - Set step')
        print('--filename {path} - Set file path')
        print('--zstd_path {path} - Set path to zstd and use it')
        exit_(0)
    elif lowered == '--step' or lowered == '-s':
        if is_last:
            print('Argument required!')
            exit_(1)
        else:
            step = int(args[i + 1])
    elif lowered == '--filename' or lowered == '-f':
        if is_last:
            print('Argument required!')
            exit_(1)
        else:
            filename = args[i + 1]
    elif lowered == '--zstd_path' or lowered == '-z':
        if os.name == 'posix':
            zstd_path = 'zstd'
示例#7
0
def normalizeStagedFile(path, normalize_fn, year, action, ignore=None):
    """Normalize a file in a git repository staged for commit."""
    # The procedure for normalizing an already staged file is not as
    # trivial as it might seem at first glance. Things get complicated
    # when considering that only parts of the changes to a file might be
    # staged for commit and others were not yet considered (yet, they
    # exist in the file on disk).
    # The approach we take is to first create a temporary copy of the full
    # file. Next, we ask git for the content of the file without the
    # unstaged changes, normalize it, and write it into the original file.
    # Afterwards we staged this file's new contents. Last we take the
    # original content (including any unstaged changes), normalize it as
    # well, and write that into the original file.

    # We use a temporary file for backing up the original content of the
    # file we work on in the git repository. We could keep the content
    # in memory only, but as a safety measure (in case Python crashes in
    # which case proper exception handling does not help) it might be
    # worthwhile to have it on disk (well, in a file; it could just reside
    # in a ramdisk, but that really is out of our control and not that
    # important).
    # Note that we open all files in text mode (as opposed to binary
    # mode). That is because we only want to work on text files. If a
    # binary file is committed we will get some sort of decoding error and
    # bail out.
    with NamedTemporaryFile(mode="w", prefix=basename(path)) as file_tmp:
        staged_content = stagedFileContent(path)
        normalized_content, found = normalize_fn(staged_content,
                                                 year=year,
                                                 ignore=ignore)

        # In many cases we expect the normalization to cause no change to
        # the content. We essentially special-case for that expectation and
        # only cause additional I/O if something truly changed.
        if found > 0 and normalized_content != staged_content:
            if action == Action.Check or action == Action.Warn:
                print("Copyright years in %s are not properly normalized" %
                      path,
                      file=stderr)
                if action == Action.Check:
                    exit_(1)

            # We need to copy the file of interest from the git repository
            # into some other location.
            with open(path, "r+") as file_git:
                original_content = file_git.read()
                file_tmp.write(original_content)
                file_git.seek(0)
                file_git.write(normalized_content)
                file_git.truncate()

            # Stage the normalized file. It is now in the state we want it to
            # be committed.
            stageFile(file_git.name)

            with open(path, "w") as file_git:
                # Last we need to write back the original content. However, we
                # normalize it as well.
                content, _ = normalize_fn(original_content,
                                          year=year,
                                          ignore=ignore)
                file_git.write(content)
                file_git.truncate()

        return found
示例#8
0
def setup_ui():
    ui.ahkbhopButton.clicked.connect(toggle_bunny_hop)
    ui.crosshairButton.clicked.connect(toggle_cross_hair)
    ui.ahkfastzoomButton.clicked.connect(toggle_fast_zoom)
    ui.ahknorecoilButton.clicked.connect(toggle_no_recoil)
    ui.ahkshakeButton.clicked.connect(toggle_shake)
    ui.ahktriggerButton.clicked.connect(toggle_trigger)
    ui.ahkzeusButton.clicked.connect(toggle_zeus)


if __name__ == '__main__':
    app = Widgets.QApplication([__name__])
    MainWindow = Widgets.QMainWindow()
    ui = NewMainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    if csgo_is_not_ran():
        msg = MessageBox()
        msg.setIcon(MessageBox.Warning)
        msg.setWindowTitle('Warning!')
        msg.setText('CSGO is not launched!')
        msg.show()
    setup_ui()
    NewThread(target=check_window).start()
    result = app.exec_()
    running = False
    kill_all()
    clear_cache()
    exit_(result)
示例#9
0

if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument('-f',
                        '--file',
                        type=str,
                        help='Target encrypted zip file.')
    parser.add_argument('-w',
                        '--word-list',
                        type=str,
                        help='Wordlist to be used.')
    parser.add_argument('-t',
                        '--threads',
                        type=int,
                        default=4,
                        help='Thread count.')
    args = parser.parse_args()

    if not args.file or not args.word_list:
        exit_(1)

    if not is_zipfile(args.file):
        exit_(1)

    if not isfile(args.word_list):
        exit_(1)

    bruter = ZipBruter(args.file, args.word_list, args.threads)
    bruter.main()