Skip to content

Commit

Permalink
remove root check
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousm4x committed Jan 29, 2023
1 parent a182f7b commit 18ef9f8
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions backend/pb/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package pb

import (
"encoding/xml"
"errors"
"net"
"net/http"
"os"
"os/exec"
"runtime"
"strconv"
"strings"

Expand Down Expand Up @@ -59,25 +56,6 @@ type Nmaprun struct {
}

func HandlerScan(c echo.Context) error {
if runtime.GOOS == "windows" {
// check for admin on windows by trying to open physicaldrive
_, err := os.Open("\\\\.\\PHYSICALDRIVE0")
if err != nil {
err := errors.New("network scan requires upsnap to be run as administrator")
return apis.NewBadRequestError(err.Error(), nil)
}
} else {
// check for root on anything else
uid, err := exec.Command("id", "-u").Output()
if err != nil {
return err
}
if string(uid) != "0" {
err := errors.New("network scan requires upsnap to be run as root")
return apis.NewBadRequestError(err.Error(), nil)
}
}

// check if nmap installed
if _, err := exec.LookPath("nmap"); err != nil {
return apis.NewBadRequestError(err.Error(), nil)
Expand Down

0 comments on commit 18ef9f8

Please sign in to comment.