Skip to content

Commit

Permalink
Improve libcdb fetch default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
the-soloist committed Oct 7, 2024
1 parent 4021bb4 commit 92bb948
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pwnlib/commandline/libcdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
fetch_parser = libc_commands.add_parser(
'fetch',
help = 'Fetch libc database',
description = 'Fetch libc database'
description = 'Fetch libc database. If no argument passed, it will init and upgrade libc-database repository',
)

fetch_parser.add_argument(
Expand All @@ -149,13 +149,6 @@
help = 'Set libc-database path, If it is empty, the default path will be `context.local_libcdb` (%s)' % context.local_libcdb
)

fetch_parser.add_argument(
'-i', '--init',
action = 'store_true',
default = False,
help = 'Init libc-database'
)

fetch_parser.add_argument(
'-u', '--update',
metavar = 'update',
Expand Down Expand Up @@ -280,12 +273,18 @@ def main(args):

elif args.libc_command == 'fetch':

if args.init:
subprocess.check_call(['git', 'clone', "https://github.com/niklasb/libc-database/", args.path])

elif args.update:
if args.update:
subprocess.check_call(['./get'] + args.update, cwd=args.path)

else:
if not Path(args.path).exists() and yesno("Would you like to initialize the libc-database repository? "
"If the path already exists, this prompt will not display, and automatically update repository."):
log.waitfor("init libc-database repository")
subprocess.check_call(['git', 'clone', 'https://github.com/niklasb/libc-database/', args.path])

log.waitfor("upgrade libc-database repository")
subprocess.check_call(['git', 'pull'], cwd=args.path)


if __name__ == '__main__':
pwnlib.commandline.common.main(__file__)

0 comments on commit 92bb948

Please sign in to comment.