Skip to content

Commit

Permalink
Merge pull request #253 from slimm609/fix_relro
Browse files Browse the repository at this point in the history
fix: fix relro checks based on gcc and os
  • Loading branch information
slimm609 authored Jun 24, 2024
2 parents 3e08155 + 9c5c31c commit b04c2e4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Updates
- golang: real 0m0.691s
- Adds recursive directory support
TODO:
- [ ] Fix Partial RELRO
- [X] Fix Partial RELRO
- [ ] Add fortify file function results
- [ ] Add fortifyProc
- [ ] Add ProcLibs
Expand Down
9 changes: 1 addition & 8 deletions pkg/checksec/fortify.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ func Fortify(name string, binary *elf.File) *fortify {

ldd := GetLdd(name)

if ldd == "none" {
res.Output = "N/A"
res.Color = "green"
res.Fortified = "0"
res.Fortifiable = "0"
res.LibcSupport = "N/A"
return &res
} else if ldd == "unk" {
if ldd == "none" || ldd == "unk" {
res.Output = "N/A"
res.Color = "unset"
res.Fortified = "0"
Expand Down
10 changes: 8 additions & 2 deletions pkg/checksec/relro.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ func RELRO(name string) *relro {
}
defer file.Close()

bind, _ := file.DynValue(24)
if len(bind) > 0 && bind[0] == 0 {
// check both bind and bind_flag.
// if DT_BIND_NOW == 0, then it is set
// if DT_FLAGS == 8, then DF_BIND_NOW is set
// this is depending on the compiler version used.
bind, _ := file.DynValue(elf.DT_BIND_NOW)
bind_flag, _ := file.DynValue(elf.DT_FLAGS)

if (len(bind) > 0 && bind[0] == 0) || (len(bind_flag) > 0 && bind_flag[0] == 8) {
bindNow = true
}

Expand Down
14 changes: 6 additions & 8 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import (
func PrintLogo() {
Red := color.New(color.FgHiRed, color.Bold)
asciiLogo := `
_______ _______ _______ _ _______ _______ _______
( ____ \|\ /|( ____ \( ____ \| \ /\( ____ \( ____ \( ____ \
| ( \/| ) ( || ( \/| ( \/| \ / /| ( \/| ( \/| ( \/
| | | (___) || (__ | | | (_/ / | (_____ | (__ | |
| | | ___ || __) | | | _ ( (_____ )| __) | |
| | | ( ) || ( | | | ( \ \ ) || ( | |
| (____/\| ) ( || (____/\| (____/\| / \ \/\____) || (____/\| (____/\
(_______/|/ \|(_______/(_______/|_/ \/\_______)(_______/(_______/
_____ _ _ ______ _____ _ __ _____ ______ _____
/ ____| | | | ____/ ____| |/ // ____| ____/ ____|
| | | |__| | |__ | | | ' /| (___ | |__ | |
| | | __ | __|| | | < \___ \| __|| |
| |____| | | | |___| |____| . \ ____) | |___| |____
\_____|_| |_|______\_____|_|\_\_____/|______\_____|
`
Red.Println(asciiLogo)
}
Expand Down

0 comments on commit b04c2e4

Please sign in to comment.