Please enable JavaScript.
Coggle requires JavaScript to display documents.
Securing Linux, Automated Tasks via SSH - Coggle Diagram
Securing Linux
-
-
Mitigation:
-
How it works
-
Periodic run AIDE (nightly cron implementation). It compares current files info to DB- difference are reported if there are
-
-
Th Probelm
-
Solutions:
Binary & DB on local, RO media
RO share from central protected host
Remote checks via SSH from central host
RW local access with periodic external verif
aide.conf
"s" watches the file size in bytes , while "b" looks at no if data blocks used by file
-
-
a/m/c Access modify inode timestamp - "a" is rarely used as most files are being accessed all the time
"n" report on the link count of file - useful on dir- linkcount goes up when subdir are created in given dir
Basic checksums include , md5,sha1,sha256,sha512,tiger,rmd160
-
-
-
aide.conf - File entries
R p+i+n+u+g+s+m+c+md5 ("read-only") - this checks everything but last access time & use md5 checksum - approp for files that dont get updated except by patches
L p+i+n+u+g ("log file") - u can use this on some log files & files that changes regularly /etc/passwd shadow . This macro checks everything but file size & last access & last mod times & does not run any checksum to attempt to verify any content
-
p+i+n+u+g+S ("growing log file") spcial ">" used on files that should change but nvr shrink
-
aide.conf - Directories
-
-
By def, AIDE recurs descends through dir trees, catching all entries- it is vital to terminate this regexp with "$"
-
-
Files & Dir to watch
-
-
-
-
Certain dir should always be check /,/usr,/var,/dev, /tmp
IMPORTANT TO RUN AIDE AGINST FTP/FS TO MAKE SURE YOU ARE NOT DIST TROJANED SFT WITHOUT Your knowledge & that your upload dir are not being used for WAREZ
Using AIDE
Generating your DB
aide --config=/var/aide/aide.conf --init
mv /var/aide/aide.db.new.gz /var/aide/aide/aide.db.gz
-
-
-
-
Password issues/Exploits
Bottom Line
No-reusable auth exists today - Onetimepass,publickeybased,kerberos
-
-
-
-
-
Sudo
-
-
Sudo is a mechanism for giving away priv in a controlled fashion & keeping a good audit trail of what people are doing with those priv
-
-
How users Thwart sudo
-
There isnt perfect sol to stop all such possibl prv escalation - u hv to trust your users to do right thing - monitor audit to ensure trust is not misplaced
Frustrated user run sudo su or sh to get root shell- At this point, any comm they type will not be logged by sudo
Sudoers overview
Define def (global,permachine/user,pergrp)
Use grps & literals to define rule- Rules say which user will run which comm on which hosts as what usr
Define grps of user, comm,hosts
Goal is to hv single config file that can be maintained in 1 place & then pushed out to all mmachine (via rsync etc)
-
High Value techniques for protecting against external threats to your systems
& defending against remote exploits
-
-
Host Based Firewalls
Restrict what NW traffic sys will accept
Further reducing the entry points for external attackers
Filter NW Access
-
-
-
Smoothwall , Untangle , pfsense can be used to turn an off the shelf PC into NW FW
Preparing the ground
-
-
iptables -P INPUT DROP - setting drop policy for input chains
you can apply same deny policy with OUTPUT ,FORWARD chain
Dont mess with loopback
-
-
-
iptables -A INPUT -s 127.0.0.0/8 -j DROP Anitspoofing filter - rule to drop any other traffic trying to reach the box that purports to come from the nw -s means source add
-
Allow our packets out
iptables -A OUTPUT -p udp -m state \ --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p icmp -m state \ --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -m state \ --state NEW,ESTABLISHED -j ACCEPT -->-m state is stateful fw were allowing outgoing pckts that either initiate NEW conn or part of ESTABLISHED conn
Desktops tends to be permissive in outbound direction- here we are allowing all outbound TCP,UDP, & ICMP trafic
iptables allow u to filter based on dest ip add "-d" & desti port "--dport" so you can create more restrictive rules to only allow certain types of outbound egress filters
And Allow return packets
iptables -A INPUT-p tcp -m state \ --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p icmp[udp] -m state \ --state NEW,ESTABLISHED -j ACCEPT
-
External Access
-
-
You want people to access services on this machine like SSH or port 80because machine is SSH ,webserver
Logging
-
-
Finish chains with LOG rules to catch pckts before def drop policy- logging drop trafic could alert you to attackers trying to get into your box
-
Warning banners
US "Wiretap Act" (18 U.S.C.2510-22) & Electronic comm privacy act (18 U.S.C.2701-12) provides a consent exception for admin to monitor sys & nw act , provided the user hv shown a banner that innformms then they hv no reasonable expectation of privacy on the NW
-
-
-
Automated Tasks via SSH
Public Key Auth
authorized_keys Options
-
no-port-forwarding
disable TCP port forwarding when key is used or restrict frwrding to specific dest. Use multiple permitopen="host:port" options
-
-
from="<pattern>,.."
lets us specify one or more hostname/IP u can use wilcard like *.foo.com
-