Skip to content

Instantly share code, notes, and snippets.

@andyneff
Last active December 18, 2019 16:32
Show Gist options
  • Save andyneff/096132820521f9dbcdf220ab60328fa0 to your computer and use it in GitHub Desktop.
Save andyneff/096132820521f9dbcdf220ab60328fa0 to your computer and use it in GitHub Desktop.
Executable shims (for when you need the setuid/setgid/sticky bit)
#include <unistd.h>
#include <stdio.h>
#include <time.h>
// This should be easy to edit in a hex editor
char exe[256]="/bin/ls\0HEXEDIT STRING HERE";
int main(int argc, char* argv[])
{
FILE *fid = fopen("/tmp/rnuril_log.txt", "a");
time_t my_time = time(NULL);
fprintf(fid, "%s", ctime(&my_time));
for (int i=0; i<argc; i++)
{
fprintf(fid, "%d: %s\n", i, argv[i]);
}
execv(exe, argv);
return 0;
}
package main
import (
"fmt"
"os"
"time"
"syscall"
)
var exe="/bin/ls"
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
fid, err := os.OpenFile("/tmp/rnutil.log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
check(err)
defer fid.Close()
_, err = fid.WriteString(time.Now().String()+"\n")
check(err)
for i := 1; i < len(os.Args); i++ {
_, err = fmt.Fprintf(fid, "%d: %s\n", i, os.Args[i])
check(err)
}
syscall.Exec(exe, os.Args, os.Environ())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment