Skip to content

Commit

Permalink
Workspace: Add python-dojo-suid
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Sep 7, 2024
1 parent 0bfdb54 commit d27986e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion workspace/core/sudo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pkgs.stdenv.mkDerivation {
installPhase = ''
runHook preInstall
mkdir -p $out/bin
echo "#!/usr/bin/env python-suid" > $out/bin/sudo
echo "#!/usr/bin/env python-dojo-suid" > $out/bin/sudo
cat ${./sudo.py} >> $out/bin/sudo
chmod +x $out/bin/sudo
runHook postInstall
Expand Down
1 change: 1 addition & 0 deletions workspace/core/suid-interpreter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let
in pkgs.symlinkJoin {
name = "suid-interpreter";
paths = with pkgs; [
(buildSuid "python-dojo-suid" "SUID_PYTHON_DOJO")
(buildSuid "python-suid" "SUID_PYTHON")
(buildSuid "bash-suid" "SUID_BASH")
(buildSuid "sh-suid" "SUID_SH")
Expand Down
8 changes: 7 additions & 1 deletion workspace/core/suid_interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ int main(int argc, char **argv, char **envp)
fgets(first_line, PATH_MAX, file);
fclose(file);

#ifdef SUID_PYTHON_DOJO
char *child_argv_prefix[] = { "/run/dojo/bin/python", "-I", "--", NULL };
if (strcmp(first_line, "#!/usr/bin/env python-suid\n"))
return ERROR_BAD_SHEBANG;
#endif

#ifdef SUID_PYTHON
char *child_argv_prefix[] = { "/usr/bin/python", "-I", "--", NULL };
if (strcmp(first_line, "#!/opt/pwn.college/python\n") &&
Expand Down Expand Up @@ -105,7 +111,7 @@ int main(int argc, char **argv, char **envp)
int child_argc = 0;
for (int i = 0; child_argv_prefix[i]; i++)
child_argv[child_argc++] = child_argv_prefix[i];
#ifdef SUID_PYTHON
#ifdef SUID_PYTHON || SUID_PYTHON_DOJO
child_argv[child_argc++] = path;
#endif
for (int i = 2; i < argc; i++)
Expand Down

0 comments on commit d27986e

Please sign in to comment.