Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fortifyProc #256

Merged
merged 1 commit into from
Aug 25, 2024
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ jobs:
exit 1
fi
- name: ubuntu checksec
run: docker-compose run checksec-ubuntu
run: |
curl -L "https://github.com/docker/compose/releases/download/v2.29.2/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose run checksec-ubuntu
6 changes: 6 additions & 0 deletions cmd/fortifyFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"checksec/pkg/checksec"
"checksec/pkg/utils"
"fmt"
"os"

"github.com/spf13/cobra"
)
Expand All @@ -12,6 +14,10 @@ var fortifyFileCmd = &cobra.Command{
Use: "fortifyFile",
Short: "Check Fortify for binary file",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Printf("Error: no filename provided")
os.Exit(1)
}
file := args[0]

utils.CheckElfExists(file)
Expand Down
63 changes: 52 additions & 11 deletions cmd/fortifyProc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package cmd

import (
"checksec/pkg/checksec"
"checksec/pkg/utils"
"fmt"
"os"
"path/filepath"

"github.com/spf13/cobra"
)
Expand All @@ -11,20 +15,57 @@ var fortifyProcCmd = &cobra.Command{
Use: "fortifyProc",
Short: "Check Fortify for running process",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("fortifyProc called")
if len(args) != 1 {
fmt.Printf("Error: no process id provided")
os.Exit(1)
}
proc := args[0]

file, err := os.Readlink(filepath.Join("/proc", proc, "exe"))
if err != nil {
fmt.Printf("Error: Pid %s not found", proc)
os.Exit(1)
}

utils.CheckElfExists(file)
binary := utils.GetBinary(file)
fortify := checksec.Fortify(file, binary)
output := []interface{}{
map[string]interface{}{
"name": file,
"checks": map[string]interface{}{
"fortify_source": fortify.Output,
"fortified": fortify.Fortified,
"fortifyable": fortify.Fortifiable,
"noFortify": fortify.NoFortify,
"libcSupport": fortify.LibcSupport,
"numLibcFunc": fortify.NumLibcFunc,
"numFileFunc": fortify.NumFileFunc,
},
},
}
color := []interface{}{
map[string]interface{}{
"name": file,
"checks": map[string]interface{}{
"fortified": fortify.Fortified,
"fortifiedColor": "unset",
"noFortify": fortify.NoFortify,
"fortifyable": fortify.Fortifiable,
"fortifyableColor": "unset",
"fortify_source": fortify.Output,
"fortify_sourceColor": fortify.Color,
"libcSupport": fortify.LibcSupport,
"libcSupportColor": fortify.LibcSupportColor,
"numLibcFunc": fortify.NumLibcFunc,
"numFileFunc": fortify.NumFileFunc,
},
},
}
utils.FortifyPrinter(outputFormat, output, color)
},
}

func init() {
rootCmd.AddCommand(fortifyProcCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// fortifyProcCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// fortifyProcCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
10 changes: 0 additions & 10 deletions cmd/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,4 @@ var kernelCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(kernelCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// kernelCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// kernelCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
10 changes: 0 additions & 10 deletions cmd/procLibs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ var procLibsCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(procLibsCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// procLibsCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// procLibsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
Loading