ardecy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +24 -8
- data/bin/ardecy +8 -2
- data/lib/ardecy.rb +46 -0
- data/lib/ardecy/guard.rb +16 -0
- data/lib/ardecy/harden.rb +95 -0
- data/lib/ardecy/harden/sysctl.rb +69 -0
- data/lib/ardecy/harden/sysctl/kernel.rb +211 -0
- data/lib/ardecy/harden/sysctl/network.rb +249 -0
- data/lib/ardecy/options.rb +39 -0
- data/lib/ardecy/privacy.rb +4 -0
- data/lib/ardecy/version.rb +3 -1
- data/lib/display.rb +22 -0
- metadata +14 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfee812e31a5a1dc6f31eaa70fb6837459732157ef174fd215eb215ea299f0c7
|
4
|
+
data.tar.gz: 5933831912f0b6770be89ba4bf9821aa12503600ca9e4e23d90df35837d453d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d2145fe504aa730c778092360531ec37da9e72c12e7c1edfcf66f8a459dd7b02188defe1fa3572c1931e7422bad12bdba19ca124f7164025c336c4c340c7f2f
|
7
|
+
data.tar.gz: 9032e9a78441de631fb46bd03ad47fb3770815f229a8c2b2200e161bb12581f95f49e623e7a6d7ef2e69bdd0b18f7034c116f8f9b92b9a58fcc2b9cf51a27637
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
# Ardecy
|
2
|
-
Awesome ruby gem to build: ardecy !
|
3
2
|
|
4
|
-
|
3
|
+
<div align="center">
|
4
|
+
<br/>
|
5
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/ardecy.svg)](https://badge.fury.io/rb/ardecy)
|
7
|
+
</div>
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
## Gem push
|
9
|
-
|
10
|
-
gem login
|
11
|
-
gem push ardecy-0.0.1.gem
|
9
|
+
Ardecy is a security, privacy auditing, fixing and hardening tool for Linux.
|
12
10
|
|
13
11
|
## Install ardecy locally
|
14
12
|
|
13
|
+
With gem:
|
14
|
+
|
15
|
+
gem cert --add <(curl -Ls https://raw.githubusercontent.com/szorfein/ardecy/master/certs/szorfein.pem)
|
15
16
|
gem install ardecy-0.0.1.gem -P HighSecurity
|
17
|
+
ardecy -h
|
18
|
+
|
19
|
+
With github:
|
20
|
+
|
21
|
+
git clone https://github.com/szorfein/ardecy
|
22
|
+
cd ardecy
|
23
|
+
ruby -I lib bin/ardecy -h
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
Audit your system
|
27
|
+
|
28
|
+
ardecy --audit
|
29
|
+
|
30
|
+
Correct errors found
|
16
31
|
|
32
|
+
ardecy --fix
|
data/bin/ardecy
CHANGED
data/lib/ardecy.rb
CHANGED
@@ -1,4 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'ardecy/version'
|
4
|
+
require_relative 'ardecy/options'
|
5
|
+
require_relative 'ardecy/harden'
|
6
|
+
require_relative 'ardecy/privacy'
|
7
|
+
require_relative 'ardecy/guard'
|
8
|
+
|
2
9
|
module Ardecy
|
10
|
+
class Main
|
11
|
+
def initialize(args)
|
12
|
+
@cli = Options.new(args).options
|
13
|
+
show_intent
|
14
|
+
permission
|
15
|
+
end
|
16
|
+
|
17
|
+
def scan
|
18
|
+
Harden.sysctl({
|
19
|
+
audit: @cli[:audit],
|
20
|
+
fix: @cli[:fix]
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
def bye
|
25
|
+
puts
|
26
|
+
puts " -[ Bye - Ardecy v." + Ardecy::VERSION + " ]- "
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
def permission
|
31
|
+
return unless @cli[:fix]
|
32
|
+
|
33
|
+
Ardecy::Guard.perm
|
34
|
+
end
|
35
|
+
|
36
|
+
def show_intent
|
37
|
+
audit = @cli[:audit] ||= false
|
38
|
+
fixing = @cli[:fix] ||= false
|
39
|
+
puts
|
40
|
+
if audit || fixing
|
41
|
+
print ' ====> '
|
42
|
+
print 'Audit ' if audit
|
43
|
+
print 'Fixing ' if fixing
|
44
|
+
print "System\n"
|
45
|
+
end
|
46
|
+
puts
|
47
|
+
end
|
48
|
+
end
|
3
49
|
end
|
4
50
|
|
data/lib/ardecy/guard.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ardecy
|
4
|
+
class BadPerm < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Guard
|
8
|
+
def self.perm
|
9
|
+
uid = Process.uid
|
10
|
+
raise BadPerm, 'Please, run this program as a root.' unless uid === 0
|
11
|
+
rescue BadPerm => e
|
12
|
+
warn "\n#{e.class} > #{e}"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'display'
|
4
|
+
require_relative 'harden/sysctl'
|
5
|
+
|
6
|
+
module Ardecy
|
7
|
+
module Harden
|
8
|
+
extend Display
|
9
|
+
|
10
|
+
def self.sysctl(args)
|
11
|
+
sysctl_kernel(args)
|
12
|
+
puts
|
13
|
+
sysctl_network(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.sysctl_kernel(args)
|
17
|
+
title 'Kernel Hardening'
|
18
|
+
|
19
|
+
Sysctl::Kernel::KPointer.new(args).x
|
20
|
+
Sysctl::Kernel::Dmesg.new(args).x
|
21
|
+
Sysctl::Kernel::Printk.new(args).x
|
22
|
+
Sysctl::Kernel::BpfDisabled.new(args).x
|
23
|
+
Sysctl::Kernel::BpfJitHarden.new(args).x
|
24
|
+
Sysctl::Kernel::LdiskAutoload.new(args).x
|
25
|
+
Sysctl::Kernel::UserFaultFd.new(args).x
|
26
|
+
Sysctl::Kernel::KExecLoadDisabled.new(args).x
|
27
|
+
Sysctl::Kernel::SysRQ.new(args).x
|
28
|
+
Sysctl::Kernel::UsernsClone.new(args).x
|
29
|
+
Sysctl::Kernel::MaxUserNameSpace.new(args).x
|
30
|
+
Sysctl::Kernel::PerfEventParanoid.new(args).x
|
31
|
+
Sysctl::Kernel::YamaPtrace.new(args).x
|
32
|
+
Sysctl::Kernel::VmMmapRndBits.new(args).x
|
33
|
+
Sysctl::Kernel::VmMmapRndCompatBits.new(args).x
|
34
|
+
Sysctl::Kernel::FsProtectedSymlinks.new(args).x
|
35
|
+
Sysctl::Kernel::FsProtectedHardlinks.new(args).x
|
36
|
+
Sysctl::Kernel::FsProtectedFifos.new(args).x
|
37
|
+
Sysctl::Kernel::FsProtectedRegular.new(args).x
|
38
|
+
|
39
|
+
return unless args[:fix]
|
40
|
+
|
41
|
+
conf = '/etc/sysctl.d/ardecy_kernel.conf'
|
42
|
+
puts if args[:audit]
|
43
|
+
puts " ===> Applying at #{conf}..."
|
44
|
+
puts
|
45
|
+
kernel_correct_show Sysctl::KERNEL
|
46
|
+
Sysctl::KERNEL << "\n"
|
47
|
+
if Dir.exist? '/etc/sysctl.d/'
|
48
|
+
File.write(conf, Sysctl::KERNEL.join("\n"), mode: 'w', chmod: 0644)
|
49
|
+
else
|
50
|
+
puts '[-] Directory /etc/sysctl.d/ no found.'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.sysctl_network(args)
|
55
|
+
title 'Network Hardening'
|
56
|
+
|
57
|
+
Sysctl::Network::TcpSynCookie.new(args).x
|
58
|
+
Sysctl::Network::RFC1337.new(args).x
|
59
|
+
Sysctl::Network::AllRpFilter.new(args).x
|
60
|
+
Sysctl::Network::DefaultRpFilter.new(args).x
|
61
|
+
Sysctl::Network::AllAcceptRedirects.new(args).x
|
62
|
+
Sysctl::Network::DefaultAcceptRedirects.new(args).x
|
63
|
+
Sysctl::Network::AllSecureRedirects.new(args).x
|
64
|
+
Sysctl::Network::DefaultSecureRedirects.new(args).x
|
65
|
+
Sysctl::Network::Ipv6AllAcceptRedirects.new(args).x
|
66
|
+
Sysctl::Network::Ipv6DefaultAcceptRedirects.new(args).x
|
67
|
+
Sysctl::Network::AllSendRedirects.new(args).x
|
68
|
+
Sysctl::Network::DefaultSendRedirects.new(args).x
|
69
|
+
Sysctl::Network::IcmpEchoIgnoreAll.new(args).x
|
70
|
+
Sysctl::Network::AllAcceptSourceRoute.new(args).x
|
71
|
+
Sysctl::Network::DefaultAcceptSourceRoute.new(args).x
|
72
|
+
Sysctl::Network::Ipv6AllAcceptSourceRoute.new(args).x
|
73
|
+
Sysctl::Network::Ipv6DefaultAcceptSourceRoute.new(args).x
|
74
|
+
Sysctl::Network::Ipv6ConfAllAcceptRa.new(args).x
|
75
|
+
Sysctl::Network::Ipv6ConfDefaultAcceptRa.new(args).x
|
76
|
+
Sysctl::Network::TcpSack.new(args).x
|
77
|
+
Sysctl::Network::TcpDSack.new(args).x
|
78
|
+
Sysctl::Network::TcpFack.new(args).x
|
79
|
+
|
80
|
+
return unless args[:fix]
|
81
|
+
|
82
|
+
conf = '/etc/sysctl.d/ardecy_network.conf'
|
83
|
+
puts if args[:audit]
|
84
|
+
puts " ===> Applying at #{conf}..."
|
85
|
+
puts
|
86
|
+
kernel_correct_show Sysctl::NETWORK
|
87
|
+
Sysctl::NETWORK << "\n"
|
88
|
+
if Dir.exist? '/etc/sysctl.d/'
|
89
|
+
File.write(conf, Sysctl::NETWORK.join("\n"), mode: 'w', chmod: 0644)
|
90
|
+
else
|
91
|
+
puts '[-] Directory /etc/sysctl.d/ no found.'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'display'
|
4
|
+
|
5
|
+
module Ardecy
|
6
|
+
module Harden
|
7
|
+
module Sysctl
|
8
|
+
KERNEL = []
|
9
|
+
NETWORK = []
|
10
|
+
|
11
|
+
class SysKern
|
12
|
+
include Display
|
13
|
+
|
14
|
+
def scan
|
15
|
+
kernel_show(@line, @exp) if @args[:audit]
|
16
|
+
if File.exist? @file
|
17
|
+
if File.readable? @file
|
18
|
+
value = File.read(@file).chomp
|
19
|
+
@res = value.to_s =~ /#{@exp}/ ? 'OK' : 'FAIL'
|
20
|
+
else
|
21
|
+
@res = 'PROTECTED'
|
22
|
+
end
|
23
|
+
else
|
24
|
+
@res = 'NO FOUND'
|
25
|
+
end
|
26
|
+
if @tab
|
27
|
+
kernel_res(@res, @tab) if @args[:audit]
|
28
|
+
elsif @args[:audit]
|
29
|
+
kernel_res(@res)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def fix
|
34
|
+
return unless File.exist? @file
|
35
|
+
|
36
|
+
KERNEL << "#{@line} = #{@exp}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def repair
|
40
|
+
return unless @args[:fix]
|
41
|
+
|
42
|
+
Ardecy::Guard.perm
|
43
|
+
if @res != 'OK' && @res != 'PROTECTED'
|
44
|
+
if File.exist? @file
|
45
|
+
File.write(@file, @exp, mode: 'w', preserve: true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def x
|
51
|
+
scan
|
52
|
+
fix
|
53
|
+
repair
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class SysNet < SysKern
|
58
|
+
def fix
|
59
|
+
return unless File.exist? @file
|
60
|
+
|
61
|
+
NETWORK << "#{@line} = #{@exp}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
require_relative 'sysctl/kernel'
|
69
|
+
require_relative 'sysctl/network'
|
@@ -0,0 +1,211 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ardecy
|
4
|
+
module Harden
|
5
|
+
module Sysctl
|
6
|
+
module Kernel
|
7
|
+
class KPointer < Sysctl::SysKern
|
8
|
+
def initialize(args)
|
9
|
+
@file = '/proc/sys/kernel/kptr_restrict'
|
10
|
+
@exp = '2'
|
11
|
+
@res = 'FALSE'
|
12
|
+
@line = 'kernel.kptr_restrict'
|
13
|
+
@args = args
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Dmesg < Sysctl::SysKern
|
18
|
+
def initialize(args)
|
19
|
+
@file = '/proc/sys/kernel/dmesg_restrict'
|
20
|
+
@exp = '1'
|
21
|
+
@res = 'FALSE'
|
22
|
+
@line = 'kernel.dmesg_restrict'
|
23
|
+
@args = args
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Printk < Sysctl::SysKern
|
28
|
+
def initialize(args)
|
29
|
+
@file = '/proc/sys/kernel/printk'
|
30
|
+
@exp = '3 3 3 3'
|
31
|
+
@res = 'FALSE'
|
32
|
+
@line = 'kernel.printk'
|
33
|
+
@args = args
|
34
|
+
end
|
35
|
+
|
36
|
+
def scan
|
37
|
+
kernel_show(@line, @exp) if @args[:audit]
|
38
|
+
value = File.read(@file).chomp
|
39
|
+
@res = 'OK' if value =~ /3\s+3\s+3\s+3/
|
40
|
+
kernel_res(@res) if @args[:audit]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class BpfDisabled < Sysctl::SysKern
|
45
|
+
def initialize(args)
|
46
|
+
@file = '/proc/sys/kernel/unprivileged_bpf_disabled'
|
47
|
+
@exp = '1'
|
48
|
+
@res = 'FALSE'
|
49
|
+
@line = 'kernel.unprivileged_bpf_disabled'
|
50
|
+
@tab = 2
|
51
|
+
@args = args
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class BpfJitHarden < Sysctl::SysKern
|
56
|
+
def initialize(args)
|
57
|
+
@file = '/proc/sys/net/core/bpf_jit_harden'
|
58
|
+
@exp = '2'
|
59
|
+
@res = 'FALSE'
|
60
|
+
@line = 'net.core.bpf_jit_harden'
|
61
|
+
@args = args
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class LdiskAutoload < Sysctl::SysKern
|
66
|
+
def initialize(args)
|
67
|
+
@file = '/proc/sys/dev/tty/ldisc_autoload'
|
68
|
+
@exp = '0'
|
69
|
+
@res = 'FALSE'
|
70
|
+
@line = 'dev.tty.ldisc_autoload'
|
71
|
+
@args = args
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class UserFaultFd < Sysctl::SysKern
|
76
|
+
def initialize(args)
|
77
|
+
@file = '/proc/sys/vm/unprivileged_userfaultfd'
|
78
|
+
@exp = '0'
|
79
|
+
@res = 'FALSE'
|
80
|
+
@line = 'vm.unprivileged_userfaultfd'
|
81
|
+
@args = args
|
82
|
+
@tab = 2
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class KExecLoadDisabled < Sysctl::SysKern
|
87
|
+
def initialize(args)
|
88
|
+
@file = '/proc/sys/kernel/kexec_load_disabled'
|
89
|
+
@exp = '1'
|
90
|
+
@res = 'FALSE'
|
91
|
+
@line = 'kernel.kexec_load_disabled'
|
92
|
+
@args = args
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class SysRQ < Sysctl::SysKern
|
97
|
+
def initialize(args)
|
98
|
+
@file = '/proc/sys/kernel/sysrq'
|
99
|
+
@exp = '0'
|
100
|
+
@res = 'FALSE'
|
101
|
+
@line = 'kernel.sysrq'
|
102
|
+
@args = args
|
103
|
+
@tab = 4
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class UsernsClone < Sysctl::SysKern
|
108
|
+
def initialize(args)
|
109
|
+
@file = '/proc/sys/kernel/unprivileged_userns_clone'
|
110
|
+
@exp = '0'
|
111
|
+
@res = 'FALSE'
|
112
|
+
@line = 'unprivileged_userns_clone'
|
113
|
+
@args = args
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class MaxUserNameSpace < Sysctl::SysKern
|
118
|
+
def initialize(args)
|
119
|
+
@file = '/proc/sys/user/max_user_namespaces'
|
120
|
+
@exp = '0'
|
121
|
+
@res = 'FALSE'
|
122
|
+
@line = 'user.max_user_namespaces'
|
123
|
+
@args = args
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class PerfEventParanoid < Sysctl::SysKern
|
128
|
+
def initialize(args)
|
129
|
+
@file = '/proc/sys/kernel/perf_event_paranoid'
|
130
|
+
@exp = '3'
|
131
|
+
@res = 'FALSE'
|
132
|
+
@line = 'kernel.perf_event_paranoid'
|
133
|
+
@args = args
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class YamaPtrace < Sysctl::SysKern
|
138
|
+
def initialize(args)
|
139
|
+
@file = '/proc/sys/kernel/yama/ptrace_scope'
|
140
|
+
@exp = '2'
|
141
|
+
@res = 'FALSE'
|
142
|
+
@line = 'kernel.yama.ptrace_scope'
|
143
|
+
@args = args
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
class VmMmapRndBits < Sysctl::SysKern
|
148
|
+
def initialize(args)
|
149
|
+
@file = '/proc/sys/vm/mmap_rnd_bits'
|
150
|
+
@exp = '32'
|
151
|
+
@res = 'FALSE'
|
152
|
+
@line = 'vm.mmap_rnd_bits'
|
153
|
+
@args = args
|
154
|
+
@tab = 4
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
class VmMmapRndCompatBits < Sysctl::SysKern
|
159
|
+
def initialize(args)
|
160
|
+
@file = '/proc/sys/vm/mmap_rnd_compat_bits'
|
161
|
+
@exp = '16'
|
162
|
+
@res = 'FALSE'
|
163
|
+
@line = 'vm.mmap_rnd_compat_bits'
|
164
|
+
@args = args
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
class FsProtectedSymlinks < Sysctl::SysKern
|
169
|
+
def initialize(args)
|
170
|
+
@file = '/proc/sys/fs/protected_symlinks'
|
171
|
+
@exp = '1'
|
172
|
+
@res = 'FALSE'
|
173
|
+
@line = 'fs.protected_symlinks'
|
174
|
+
@args = args
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class FsProtectedHardlinks < Sysctl::SysKern
|
179
|
+
def initialize(args)
|
180
|
+
@file = '/proc/sys/fs/protected_hardlinks'
|
181
|
+
@exp = '1'
|
182
|
+
@res = 'FALSE'
|
183
|
+
@line = 'fs.protected_hardlinks'
|
184
|
+
@args = args
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
class FsProtectedFifos < Sysctl::SysKern
|
189
|
+
def initialize(args)
|
190
|
+
@file = '/proc/sys/fs/protected_fifos'
|
191
|
+
@exp = '2'
|
192
|
+
@res = 'FALSE'
|
193
|
+
@line = 'fs.protected_fifos'
|
194
|
+
@args = args
|
195
|
+
@tab = 4
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class FsProtectedRegular < Sysctl::SysKern
|
200
|
+
def initialize(args)
|
201
|
+
@file = '/proc/sys/fs/protected_regular'
|
202
|
+
@exp = '2'
|
203
|
+
@res = 'FALSE'
|
204
|
+
@line = 'fs.protected_regular'
|
205
|
+
@args = args
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ardecy
|
4
|
+
module Harden
|
5
|
+
module Sysctl
|
6
|
+
module Network
|
7
|
+
class TcpSynCookie < Sysctl::SysNet
|
8
|
+
def initialize(args)
|
9
|
+
@file = '/proc/sys/net/ipv4/tcp_syncookies'
|
10
|
+
@exp = '1'
|
11
|
+
@res = 'FALSE'
|
12
|
+
@line = 'net.ipv4.tcp_syncookies'
|
13
|
+
@args = args
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class RFC1337 < Sysctl::SysNet
|
18
|
+
def initialize(args)
|
19
|
+
@file = '/proc/sys/net/ipv4/tcp_rfc1337'
|
20
|
+
@exp = '1'
|
21
|
+
@res = 'FALSE'
|
22
|
+
@line = 'net.ipv4.tcp_rfc1337'
|
23
|
+
@args = args
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class AllRpFilter < Sysctl::SysNet
|
28
|
+
def initialize(args)
|
29
|
+
@file = '/proc/sys/net/ipv4/conf/all/rp_filter'
|
30
|
+
@exp = '1'
|
31
|
+
@res = 'FALSE'
|
32
|
+
@line = 'net.ipv4.conf.all.rp_filter'
|
33
|
+
@args = args
|
34
|
+
@tab = 2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class DefaultRpFilter < Sysctl::SysNet
|
39
|
+
def initialize(args)
|
40
|
+
@file = '/proc/sys/net/ipv4/conf/default/rp_filter'
|
41
|
+
@exp = '1'
|
42
|
+
@res = 'FALSE'
|
43
|
+
@line = 'net.ipv4.conf.default.rp_filter'
|
44
|
+
@args = args
|
45
|
+
@tab = 2
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class AllAcceptRedirects < Sysctl::SysNet
|
50
|
+
def initialize(args)
|
51
|
+
@file = '/proc/sys/net/ipv4/conf/all/accept_redirects'
|
52
|
+
@exp = '0'
|
53
|
+
@res = 'FALSE'
|
54
|
+
@line = 'net.ipv4.conf.all.accept_redirects'
|
55
|
+
@args = args
|
56
|
+
@tab = 2
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class DefaultAcceptRedirects < Sysctl::SysNet
|
61
|
+
def initialize(args)
|
62
|
+
@file = '/proc/sys/net/ipv4/conf/default/accept_redirects'
|
63
|
+
@exp = '0'
|
64
|
+
@res = 'FALSE'
|
65
|
+
@line = 'net.ipv4.conf.default.accept_redirects'
|
66
|
+
@args = args
|
67
|
+
@tab = 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class AllSecureRedirects < Sysctl::SysNet
|
72
|
+
def initialize(args)
|
73
|
+
@file = '/proc/sys/net/ipv4/conf/all/secure_redirects'
|
74
|
+
@exp = '0'
|
75
|
+
@res = 'FALSE'
|
76
|
+
@line = 'net.ipv4.conf.all.secure_redirects'
|
77
|
+
@args = args
|
78
|
+
@tab = 2
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class DefaultSecureRedirects < Sysctl::SysNet
|
83
|
+
def initialize(args)
|
84
|
+
@file = '/proc/sys/net/ipv4/conf/default/secure_redirects'
|
85
|
+
@exp = '0'
|
86
|
+
@res = 'FALSE'
|
87
|
+
@line = 'net.ipv4.conf.default.secure_redirects'
|
88
|
+
@args = args
|
89
|
+
@tab = 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Ipv6AllAcceptRedirects < Sysctl::SysNet
|
94
|
+
def initialize(args)
|
95
|
+
@file = '/proc/sys/net/ipv6/conf/all/accept_redirects'
|
96
|
+
@exp = '0'
|
97
|
+
@res = 'FALSE'
|
98
|
+
@line = 'net.ipv6.conf.all.accept_redirects'
|
99
|
+
@args = args
|
100
|
+
@tab = 2
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class Ipv6DefaultAcceptRedirects < Sysctl::SysNet
|
105
|
+
def initialize(args)
|
106
|
+
@file = '/proc/sys/net/ipv6/conf/default/accept_redirects'
|
107
|
+
@exp = '0'
|
108
|
+
@res = 'FALSE'
|
109
|
+
@line = 'net.ipv6.conf.default.accept_redirects'
|
110
|
+
@args = args
|
111
|
+
@tab = 1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class AllSendRedirects < Sysctl::SysNet
|
116
|
+
def initialize(args)
|
117
|
+
@file = '/proc/sys/net/ipv4/conf/all/send_redirects'
|
118
|
+
@exp = '0'
|
119
|
+
@res = 'FALSE'
|
120
|
+
@line = 'net.ipv4.conf.all.send_redirects'
|
121
|
+
@args = args
|
122
|
+
@tab = 2
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class DefaultSendRedirects < Sysctl::SysNet
|
127
|
+
def initialize(args)
|
128
|
+
@file = '/proc/sys/net/ipv4/conf/default/send_redirects'
|
129
|
+
@exp = '0'
|
130
|
+
@res = 'FALSE'
|
131
|
+
@line = 'net.ipv4.conf.default.send_redirects'
|
132
|
+
@args = args
|
133
|
+
@tab = 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class IcmpEchoIgnoreAll < Sysctl::SysNet
|
138
|
+
def initialize(args)
|
139
|
+
@file = '/proc/sys/net/ipv4/icmp_echo_ignore_all'
|
140
|
+
@exp = '1'
|
141
|
+
@res = 'FALSE'
|
142
|
+
@line = 'net.ipv4.icmp_echo_ignore_all'
|
143
|
+
@args = args
|
144
|
+
@tab = 2
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class AllAcceptSourceRoute < Sysctl::SysNet
|
149
|
+
def initialize(args)
|
150
|
+
@file = '/proc/sys/net/ipv4/conf/all/accept_source_route'
|
151
|
+
@exp = '0'
|
152
|
+
@res = 'FALSE'
|
153
|
+
@line = 'net.ipv4.conf.all.accept_source_route'
|
154
|
+
@args = args
|
155
|
+
@tab = 1
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class DefaultAcceptSourceRoute < Sysctl::SysNet
|
160
|
+
def initialize(args)
|
161
|
+
@file = '/proc/sys/net/ipv4/conf/default/accept_source_route'
|
162
|
+
@exp = '0'
|
163
|
+
@res = 'FALSE'
|
164
|
+
@line = 'net.ipv4.conf.default.accept_source_route'
|
165
|
+
@args = args
|
166
|
+
@tab = 1
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class Ipv6AllAcceptSourceRoute < Sysctl::SysNet
|
171
|
+
def initialize(args)
|
172
|
+
@file = '/proc/sys/net/ipv6/conf/all/accept_source_route'
|
173
|
+
@exp = '0'
|
174
|
+
@res = 'FALSE'
|
175
|
+
@line = 'net.ipv6.conf.all.accept_source_route'
|
176
|
+
@args = args
|
177
|
+
@tab = 1
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
class Ipv6DefaultAcceptSourceRoute < Sysctl::SysNet
|
182
|
+
def initialize(args)
|
183
|
+
@file = '/proc/sys/net/ipv6/conf/default/accept_source_route'
|
184
|
+
@exp = '0'
|
185
|
+
@res = 'FALSE'
|
186
|
+
@line = 'net.ipv6.conf.default.accept_source_route'
|
187
|
+
@args = args
|
188
|
+
@tab = 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
class Ipv6ConfAllAcceptRa < Sysctl::SysNet
|
193
|
+
def initialize(args)
|
194
|
+
@file = '/proc/sys/net/ipv6/conf/all/accept_ra'
|
195
|
+
@exp = '0'
|
196
|
+
@res = 'FALSE'
|
197
|
+
@line = 'net.ipv6.conf.all.accept_ra'
|
198
|
+
@args = args
|
199
|
+
@tab = 2
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
class Ipv6ConfDefaultAcceptRa < Sysctl::SysNet
|
204
|
+
def initialize(args)
|
205
|
+
@file = '/proc/sys/net/ipv6/conf/default/accept_ra'
|
206
|
+
@exp = '0'
|
207
|
+
@res = 'FALSE'
|
208
|
+
@line = 'net.ipv6.conf.default.accept_ra'
|
209
|
+
@args = args
|
210
|
+
@tab = 2
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class TcpSack < Sysctl::SysNet
|
215
|
+
def initialize(args)
|
216
|
+
@file = '/proc/sys/net/ipv4/tcp_sack'
|
217
|
+
@exp = '0'
|
218
|
+
@res = 'FALSE'
|
219
|
+
@line = 'net.ipv4.tcp_sack'
|
220
|
+
@args = args
|
221
|
+
@tab = 4
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
class TcpDSack < Sysctl::SysNet
|
226
|
+
def initialize(args)
|
227
|
+
@file = '/proc/sys/net/ipv4/tcp_dsack'
|
228
|
+
@exp = '0'
|
229
|
+
@res = 'FALSE'
|
230
|
+
@line = 'net.ipv4.tcp_dsack'
|
231
|
+
@args = args
|
232
|
+
@tab = 4
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class TcpFack < Sysctl::SysNet
|
237
|
+
def initialize(args)
|
238
|
+
@file = '/proc/sys/net/ipv4/tcp_fack'
|
239
|
+
@exp = '0'
|
240
|
+
@res = 'FALSE'
|
241
|
+
@line = 'net.ipv4.tcp_fack'
|
242
|
+
@args = args
|
243
|
+
@tab = 4
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module Ardecy
|
6
|
+
class Options
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
def initialize(args)
|
10
|
+
@options = {}
|
11
|
+
parse(args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse(args)
|
15
|
+
OptionParser.new do |opts|
|
16
|
+
opts.on('--audit', 'Perform local security scan.') do
|
17
|
+
@options[:audit] = true
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on('--fix', 'Fix problems.') do
|
21
|
+
@options[:fix] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on('-h', '--help', 'Show this message.') do
|
25
|
+
puts opts
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
args.push('-h') if args.empty?
|
31
|
+
opts.parse!(args)
|
32
|
+
rescue OptionParser::ParseError => e
|
33
|
+
warn e.message, "\n", opts
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/ardecy/version.rb
CHANGED
data/lib/display.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Display
|
4
|
+
def title(name)
|
5
|
+
l = name.length
|
6
|
+
puts " [+] #{name} "
|
7
|
+
puts '-' * l * 2.9
|
8
|
+
puts
|
9
|
+
end
|
10
|
+
|
11
|
+
def kernel_show(line, exp)
|
12
|
+
print " - #{line} (exp: #{exp})"
|
13
|
+
end
|
14
|
+
|
15
|
+
def kernel_res(res, ntab = 3)
|
16
|
+
puts "\t" * ntab + "[ #{res} ]"
|
17
|
+
end
|
18
|
+
|
19
|
+
def kernel_correct_show(list)
|
20
|
+
list.each { |l| puts " - #{l}" }
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ardecy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -35,9 +35,10 @@ cert_chain:
|
|
35
35
|
F9Dl4EPzjBJOgQWf+NxzxNuNKI46Lp5Q8AI+xtDUHAPbSswHa40BA6ChFehP+j0L
|
36
36
|
fg==
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-07-
|
38
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
|
-
description: "
|
40
|
+
description: " Ardecy is a security, privacy auditing, fixing and hardening tool
|
41
|
+
for GNU/Linux.\n"
|
41
42
|
email: szorfein@protonmail.com
|
42
43
|
executables:
|
43
44
|
- ardecy
|
@@ -48,7 +49,15 @@ files:
|
|
48
49
|
- README.md
|
49
50
|
- bin/ardecy
|
50
51
|
- lib/ardecy.rb
|
52
|
+
- lib/ardecy/guard.rb
|
53
|
+
- lib/ardecy/harden.rb
|
54
|
+
- lib/ardecy/harden/sysctl.rb
|
55
|
+
- lib/ardecy/harden/sysctl/kernel.rb
|
56
|
+
- lib/ardecy/harden/sysctl/network.rb
|
57
|
+
- lib/ardecy/options.rb
|
58
|
+
- lib/ardecy/privacy.rb
|
51
59
|
- lib/ardecy/version.rb
|
60
|
+
- lib/display.rb
|
52
61
|
homepage: https://github.com/szorfein/ardecy
|
53
62
|
licenses:
|
54
63
|
- MIT
|
@@ -72,11 +81,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
81
|
- - ">="
|
73
82
|
- !ruby/object:Gem::Version
|
74
83
|
version: '0'
|
75
|
-
requirements:
|
76
|
-
- 'TODO change: libmagick, v6.0'
|
77
|
-
- 'TODO change: A good graphics card'
|
84
|
+
requirements: []
|
78
85
|
rubygems_version: 3.0.9
|
79
86
|
signing_key:
|
80
87
|
specification_version: 4
|
81
|
-
summary:
|
88
|
+
summary: Ardecy is a security | privacy auditing tools.
|
82
89
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|