Skip to content

Commit

Permalink
mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
OBarronCS committed Feb 17, 2025
1 parent 1293573 commit a425423
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bin/pwnbox
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def main():
create_parser = toplevel_parser.add_parser("create")
create_parser.add_argument("name")
create_parser.add_argument("--image", dest="image", default=None, required=False, help="Choose image")
create_parser.add_argument("-v", dest="volumes", nargs='*', default=[], action="extend", help="Add mounts")

# Enter
enter_parser = toplevel_parser.add_parser("enter")
Expand Down Expand Up @@ -84,7 +85,7 @@ def main():


if args.command == "create":
create(args.name, args.image)
create(args.name, args.volumes, args.image)
elif args.command == "enter":
enter(args.name)
elif args.command in {"remove","rm","kill"}:
Expand Down Expand Up @@ -141,7 +142,7 @@ def get_image_name(image: str | None) -> str:



def create(name: str, image: str | None):
def create(name: str, volumes: list[str], image: str | None):

test = subprocess.run(
[
Expand All @@ -162,6 +163,19 @@ def create(name: str, image: str | None):

print(f"Creating pwnbox with image '{image}'")

extra_mounts: list[str] = []

for v in volumes:
try:
a,b = v.split(":",maxsplit=1)
except ValueError as e:
print("A mount requires a ':'")
sys.exit(1)

host_path = pathlib.Path(a).resolve()

extra_mounts += ["-v",f"{host_path}:{b}"]

hostname = f"pwnbox-{name}"
result = subprocess.run(
[
Expand All @@ -176,6 +190,7 @@ def create(name: str, image: str | None):
"-d",
"-w", "/mount/",
"-v", f"{os.getcwd()}:/mount/",
*extra_mounts,
"--name", f"{name}",
image,
"/bin/bash",
Expand Down

0 comments on commit a425423

Please sign in to comment.