feat: First commit
This commit is contained in:
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Matte23
|
||||
Copyright (c) 2025 Matteo Schiff
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# solvertools
|
||||
|
||||
A bunch of tools to integrate a solver with ctfcli
|
||||
23
pyproject.toml
Normal file
23
pyproject.toml
Normal file
@@ -0,0 +1,23 @@
|
||||
[build-system]
|
||||
requires = ["hatchling >= 1.26"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "solvertools"
|
||||
version = "0.0.1"
|
||||
authors = [
|
||||
{ name="Matte23", email="matteo@underdesk.net" },
|
||||
]
|
||||
description = "A bunch of tools to integrate a solver with ctfcli"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
license = "MIT"
|
||||
license-files = ["LICEN[CS]E*"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://git.underdesk.net/Matte23/solvertools"
|
||||
Issues = "https://git.underdesk.net/Matte23/solvertools/issues"
|
||||
2
src/solvertools/__init__.py
Normal file
2
src/solvertools/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .connect import *
|
||||
from .flags import *
|
||||
23
src/solvertools/connect.py
Normal file
23
src/solvertools/connect.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from pwn import log, remote, process
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
||||
|
||||
def connect_tcp(local_path):
|
||||
# Argument parsing
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("--connection-info", required=True, help="nc HOST PORT")
|
||||
parser.add_argument("--local", action="store_true", help="Run locally")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Parse HOST and PORT
|
||||
try:
|
||||
_, HOST, PORT = args.connection_info.split(" ")
|
||||
PORT = int(PORT)
|
||||
except ValueError:
|
||||
log.error("Invalid --connection-info format. Use 'nc HOST PORT'")
|
||||
sys.exit(1)
|
||||
|
||||
# Connect to process or remote host
|
||||
conn = process(["python", local_path]) if args.local else remote(HOST, PORT)
|
||||
return conn
|
||||
13
src/solvertools/flags.py
Normal file
13
src/solvertools/flags.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from pwn import log
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def extract_flag(data, regex):
|
||||
match = re.findall(regex, data)
|
||||
if match:
|
||||
log.success(f"Flag found: {match[0]}")
|
||||
sys.exit(0)
|
||||
else:
|
||||
log.failure("Flag not found.")
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user