Skip to content

Commit b04c2e4

Browse files
authored
Merge pull request #253 from slimm609/fix_relro
fix: fix relro checks based on gcc and os
2 parents 3e08155 + 9c5c31c commit b04c2e4

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Updates
2222
- golang: real 0m0.691s
2323
- Adds recursive directory support
2424
TODO:
25-
- [ ] Fix Partial RELRO
25+
- [X] Fix Partial RELRO
2626
- [ ] Add fortify file function results
2727
- [ ] Add fortifyProc
2828
- [ ] Add ProcLibs

pkg/checksec/fortify.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@ func Fortify(name string, binary *elf.File) *fortify {
3737

3838
ldd := GetLdd(name)
3939

40-
if ldd == "none" {
41-
res.Output = "N/A"
42-
res.Color = "green"
43-
res.Fortified = "0"
44-
res.Fortifiable = "0"
45-
res.LibcSupport = "N/A"
46-
return &res
47-
} else if ldd == "unk" {
40+
if ldd == "none" || ldd == "unk" {
4841
res.Output = "N/A"
4942
res.Color = "unset"
5043
res.Fortified = "0"

pkg/checksec/relro.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ func RELRO(name string) *relro {
2525
}
2626
defer file.Close()
2727

28-
bind, _ := file.DynValue(24)
29-
if len(bind) > 0 && bind[0] == 0 {
28+
// check both bind and bind_flag.
29+
// if DT_BIND_NOW == 0, then it is set
30+
// if DT_FLAGS == 8, then DF_BIND_NOW is set
31+
// this is depending on the compiler version used.
32+
bind, _ := file.DynValue(elf.DT_BIND_NOW)
33+
bind_flag, _ := file.DynValue(elf.DT_FLAGS)
34+
35+
if (len(bind) > 0 && bind[0] == 0) || (len(bind_flag) > 0 && bind_flag[0] == 8) {
3036
bindNow = true
3137
}
3238

pkg/utils/utils.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import (
77
func PrintLogo() {
88
Red := color.New(color.FgHiRed, color.Bold)
99
asciiLogo := `
10-
_______ _______ _______ _ _______ _______ _______
11-
( ____ \|\ /|( ____ \( ____ \| \ /\( ____ \( ____ \( ____ \
12-
| ( \/| ) ( || ( \/| ( \/| \ / /| ( \/| ( \/| ( \/
13-
| | | (___) || (__ | | | (_/ / | (_____ | (__ | |
14-
| | | ___ || __) | | | _ ( (_____ )| __) | |
15-
| | | ( ) || ( | | | ( \ \ ) || ( | |
16-
| (____/\| ) ( || (____/\| (____/\| / \ \/\____) || (____/\| (____/\
17-
(_______/|/ \|(_______/(_______/|_/ \/\_______)(_______/(_______/
10+
_____ _ _ ______ _____ _ __ _____ ______ _____
11+
/ ____| | | | ____/ ____| |/ // ____| ____/ ____|
12+
| | | |__| | |__ | | | ' /| (___ | |__ | |
13+
| | | __ | __|| | | < \___ \| __|| |
14+
| |____| | | | |___| |____| . \ ____) | |___| |____
15+
\_____|_| |_|______\_____|_|\_\_____/|______\_____|
1816
`
1917
Red.Println(asciiLogo)
2018
}

0 commit comments

Comments
 (0)