pwninit: add module
This addition of the module adds some possibility to configure an automated way to use a template with pwninit.
This commit is contained in:
parent
e3ad5108f5
commit
271523ff50
|
@ -259,6 +259,12 @@
|
|||
github = "silmarp";
|
||||
githubID = 67292496;
|
||||
};
|
||||
soratenshi = {
|
||||
email = "dream@neoncity.dev";
|
||||
github = "soratenshi";
|
||||
githubId = 13474089;
|
||||
name = "Sora";
|
||||
};
|
||||
fendse = {
|
||||
email = "46252070+Fendse@users.noreply.github.com";
|
||||
github = "Fendse";
|
||||
|
|
|
@ -194,6 +194,7 @@ let
|
|||
./programs/powerline-go.nix
|
||||
./programs/pqiv.nix
|
||||
./programs/pubs.nix
|
||||
./programs/pwninit.nix
|
||||
./programs/pyenv.nix
|
||||
./programs/pylint.nix
|
||||
./programs/qcal.nix
|
||||
|
|
76
modules/programs/pwninit.nix
Normal file
76
modules/programs/pwninit.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkPackageOption mkOption mkIf types;
|
||||
cfg = config.programs.pwninit;
|
||||
in {
|
||||
meta.maintainers = [ lib.hm.maintainer.soratenshi ];
|
||||
|
||||
options = {
|
||||
programs.pwninit = {
|
||||
enable = mkEnableOption
|
||||
"A tool for automating starting binary exploit challenges";
|
||||
package = mkPackageOption pkgs "pwninit" { };
|
||||
|
||||
template = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "The pwninit template.";
|
||||
example = ''
|
||||
#!/usr/bin/env python3
|
||||
from pwn import *
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings(action='ignore', category=BytesWarning)
|
||||
|
||||
{bindings}
|
||||
|
||||
context.binary = {bin_name}
|
||||
|
||||
IP, PORT = "address", 12345
|
||||
|
||||
gdbscript = '''
|
||||
tbreak main
|
||||
continue
|
||||
'''
|
||||
|
||||
def start():
|
||||
if args.GDB:
|
||||
return gdb.debug([elf.path], gdbscript)
|
||||
elif args.REMOTE:
|
||||
return remote(IP, PORT)
|
||||
else:
|
||||
return elf.process()
|
||||
|
||||
p = start()
|
||||
|
||||
# ----- Exploit ----- #
|
||||
|
||||
p.interactive()
|
||||
'';
|
||||
};
|
||||
|
||||
templateAlias = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description =
|
||||
"Creates an alias for 'pwninit --template-path {template}' as 'pwninit'.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
assertions = mkIf cfg.templateAlias [{
|
||||
assertion = cfg.template != null;
|
||||
message =
|
||||
"The 'programs.pwninit.template' option must be set when 'programs.pwninit.templateAlias' is true.";
|
||||
}];
|
||||
|
||||
home.shellAliases = mkIf (cfg.templateAlias && cfg.template != null) {
|
||||
pwninit = "${cfg.package}/bin/pwninit --template-path ${
|
||||
(pkgs.writeText "template.py" cfg.template)
|
||||
}";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -126,6 +126,7 @@ in import nmtSrc {
|
|||
./modules/programs/poetry
|
||||
./modules/programs/powerline-go
|
||||
./modules/programs/pubs
|
||||
./modules/programs/pwninit
|
||||
./modules/programs/pyenv
|
||||
./modules/programs/qcal
|
||||
./modules/programs/qutebrowser
|
||||
|
|
17
tests/modules/programs/pwninit/basic-configuration.nix
Normal file
17
tests/modules/programs/pwninit/basic-configuration.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ config, ... }: {
|
||||
config = {
|
||||
programs.bash.enable = true;
|
||||
|
||||
programs.pwninit = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
template = "A simple test";
|
||||
templateAlias = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileRegex home-files/.bashrc \
|
||||
'pwninit --template-path.*template.py'
|
||||
'';
|
||||
};
|
||||
}
|
1
tests/modules/programs/pwninit/default.nix
Normal file
1
tests/modules/programs/pwninit/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ pwninit-basic-configuration = ./basic-configuration.nix; }
|
Loading…
Reference in a new issue