Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

a usb-based dead man's switch for your computer.

****DO NOT USE THIS IN IT'S CURRENT STATE AS AN ANTI-FORENSICS/COMPULSION TOOL THERE ARE CRITICAL EDGE CASES THAT COULD COMPROMISE YOUR FREEDOM OR MORE...**

## Usage
```
sudo ./deadman
Expand Down
50 changes: 48 additions & 2 deletions filecheck.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,57 @@
package main

import (
"bytes"
"log"
"os"
"os/exec"
)

func checkExe(path string) error {
_, err := exec.LookPath(path)
return err
//TODO: check for executability
if err != nil {
return err
}

cmd := "which"
args := []string{path}
execCmd := exec.Command(cmd, args...)

var out bytes.Buffer
var stderr bytes.Buffer

execCmd.Stdout = &out
execCmd.Stderr = &stderr

err = execCmd.Run()
if err != nil {
log.Println("out: " + out.String())
log.Println("stderr: " + stderr.String())
log.Println(err)
}

info, err := os.Stat("/usr/bin/lsusb")
if err != nil {
return err
}

m := info.Mode()

/*
// Bitshift to check if any user can execute given binary
log.Println(m&(2>>1))

// Bitshift to check if group can execute given binary
log.Println(m&(1<<3))

// Bitshift to check if owner can execute given binary
log.Println(m&(1<<6))
*/

// Bitshift to check if any user can execute given binary
if m&(2>>1) != 0 {
return nil
} else {
return nil
}
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
// Look to see if there are any new devicies
// Look to see if there are any new devices
for _, d := range devices {
if _, ok := deviceMap[d]; !ok {
log.Printf("New device: %s [%s]\n", d.Name, d.ID)
shutdownSequence(conf)
}

deviceMap[d] = now
}

Expand All @@ -74,6 +75,7 @@ func main() {
log.Printf("Device %s [%s] has been removed\n", d.Name, d.ID)
shutdownSequence(conf)
}

}
case <-sigint:
log.Println("SIGINT received")
Expand Down