Outils pour utilisateurs

Outils du site


blog

Notes sed grep regex

grep

Grep autres

--line-buffered

tail -F /var/log/apache2/access.log | grep --line-buffered "POST /wp-login"

Regex

Exclude

^((?!motif).)*$

Grepper sur plusieurs lignes (match grep with line break)

grep -zP '\S{64}\n\S{64}'
Extended regular expressions

Source : https://www.gnu.org/software/sed/manual/html_node/Extended-regexps.html

The only difference between basic and extended regular expressions is in the behavior of a few characters: ?, +, parentheses, and braces {}. While basic regular expressions require these to be escaped if you want them to behave as special characters, when using extended regular expressions you must escape them if you want them to match a literal character .

Examples:

abc?
    becomes ‘abc\?’ when using extended regular expressions. It matches the literal string ‘abc?’.
c\+
    becomes ‘c+’ when using extended regular expressions. It matches one or more ‘c’.
a\{3,\}
    becomes ‘a{3,}’ when using extended regular expressions. It matches three or more ‘a’.
\(abc\)\{2,3\}
    becomes ‘(abc){2,3}’ when using extended regular expressions. It matches either ‘abcabc’ or ‘abcabcabc’.
\(abc*\)\1
    becomes ‘(abc*)\1’ when using extended regular expressions. Backreferences must still be escaped when using extended regular expressions. 

Trouver des tabulations dans un fichier (GNU grep) you can use the Perl-style regexp

grep -P '\t' *
Pb
Pb binary file matches
# grep -i -e '2020-11-24' daemon.log
Binary file daemon.log matches

Solution

grep -a -i -e '2020-11-24' daemon.log

Bash

Pour plus de lisibilité il est recommandé de mettre les regex dans des fonctions bien nommées et commentées

regex_keep_only_file_extension() {
    # Ex: in  'plop.txt'
    #     out 'txt'
    sed -e 's/^.*\.//'
}
 
get_list() {
    local File
    for File in $(get_files_from_list); do
        echo "${File}.${PRESUFFIX_FOR_FILENAMES}".* | xargs -n 1 basename
    done | regex_keep_only_file_extension | sort -u
}

head / tail

Supprimer les deux dernières lignes

head -n -2 myfile.txt

Supprimer les 4 primières lignes

tail -n +4 myfile.txt

sed

Voir :

Matched text

sed -i -e 's/^LoadModule mod_unique_id.c/#&/' /etc/proftpd/modules.conf

Commenter tout un fichier

sed -i -e 's/^[^#]/#&/' /etc/snmp/snmp.conf

Supprimer tous les espaces en début de ligne

sed -e 's/^\s\+//g'

Première lettre en majuscule

sed -e 's/^./\U&/'

Insérer une ligne au début d'un fichier

sed -i '1i/dev/mapper/vg_os-root   /    xfs    defaults,noatime    1    1' /etc/fstab

Ou pour insérer le caractère '{' en première ligne

sed -e '1 i\{' 

Strip HTML

sed -e 's/<[^>]*>//g'

Colonnes

df -PhT | column -t
grep -v -e '^#' /etc/fstab | column -t

Adresse IP

rgrep -E --color -e '([0-9]{1,3}\.){3}[0-9]{1,3}' /var/www/plop/www.acme.fr/htdocs/

Supprimer une ligne

sed -i -e '/\/data/d' /etc/fstab

Supprimer toutes les lignes à partir du motif

sed -e '/MODIF/,/$$/d' plop.txt

$$ : jusqu'à la fin du fichier

Supprimer les fins de ligne

Source et explications : https://stackoverflow.com/questions/1251999/how-can-i-replace-a-newline-n-using-sed

sed ':a;N;$!ba;s/\n/ /g' file

Afficher de la ligne n à la ligne m :

cat -n launch.sh
# ou
grep -n -A7 my_function launch.sh
 
# Puis (de la ligne 46 à la ligne 68)
cat launch.sh | sed -n -e '46,68p' >> build.sh
Character Classes

how to represent “alphanumeric or _ or -”

That will be this character class:

[[:alnum:]_-]

Which means allow one of these:

  • Alpha numeric
  • Underscore
  • Hyphen

It is important to keep hyphen at 1st or last position in character class to avoid escaping.

sort

sort -t, -nk3 user.csv
    -t, - defines your delimiter as ,.

    -n - gives you numerical sort. Added since you added it in your attempt. If your user field is text only then you dont need it.

    -k3 - defines the field (key). user is the third field.

Exemple

# sa -u --other-acct-file /var/account/pacct-20260917 | sort  -nk4 | tail -3
root       0.93 cpu   121072k mem      0 io tuned
root       0.00 cpu   370816k mem      0 io runc
polkitd    0.05 cpu   435840k mem      0 io JS Helper

awk

Voir :

Utiliser les variables d'environement dans awk :

awk -v a="$var1" -v b="$var2" 'BEGIN {print a,b}'

Dernier champ ; avant dernier champ

awk '{print $NF}'
 
awk '{print $(NF - 1)}'

Mettre en majuscule/minuscule et grepper

awk '/sAMAccountName/ {print tolower($2)}'

Exemple ligne commençant par opencv ou libopencv

apt-cache search opencv | awk '/^(lib)*opencv/ {print $1}'

Trouver les zombies

ps aux | awk '$8 ~ /^[Zz]/'

Remplacer un motif par un autre

$ echo "Bobby is cool" | awk '{sub("Bobby","Teddy"); print}'
Teddy is cool

Exemple

ip link | awk '/: br-/ { gsub(":", "") ; print $2 }'

Awk One-Liners - Remove duplicate, nonconsecutive lines

iptables-save | awk ' !x[$0]++' | iptables-restore

sum - total - faire l'addition / la somme de nombres séparés par des sauts de ligne

awk '{s+=$1} END {printf "%.0f", s}' fichiers.txt

if greater / less than

awk -F':' '$3 >=1000 && $3 <=65534 {print $3}' /etc/passwd

Avant-dernier champs

awk '{ print ( $(NF-1) ) }'

Remplacer un motif par un autre (remplace)

awk '/^gpg: key / {gsub(":", "") ; print $3 ;}')

Lire une valeur dans un fichier ini en supprimant les espaces config.ini

process_name = appsrvd
awk -F= '/process_name/ { gsub (" ", "", $0) ; print $2 }' config.ini

Calcul

calc() { awk "BEGIN { print $* }"; }
 
calc_sum() { awk '{s+=$1} END {printf "%.0f", s}' "$*" }
Awk autres

/etc/auto.smb

# .........
$SMBCLIENT -gNL $key 2>/dev/null | awk -v key="$key" -v opts="$opts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /Disk/  {
                  if (first)
                        print opts; first=0
                  dir = $2
                  loc = $2
                  # Enclose mount dir and location in quotes
                  # Double quote "$" in location as it is special
                  gsub(/\$$/, "\\$", loc);
                  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
                }
        END     { if (!first) print "\n"; else exit 1 }
        '

Python

re.match \ La méthode match recherche une correspondance uniquement au début de la chaîne

re.search \ search() La fonction recherchera le modèle d’expression régulière et renverra la première occurrence. \ Contrairement à Python re.match(), il vérifiera toutes les lignes de la chaîne d'entrée. La fonction Python re.search() renvoie un objet match lorsque le modèle est trouvé et « nul » si le modèle n'est pas trouvé

re.findall \ findall() Le module est utilisé pour rechercher « toutes » les occurrences qui correspondent à un modèle donné. En revanche, le module search() ne renverra que la première occurrence correspondant au modèle spécifié. \ findall() parcourra toutes les lignes du fichier et renverra toutes les correspondances de modèle qui ne se chevauchent pas en une seule étape.

Exemple de regex

email_re = re.compile(r'([a-zA-Z0-9_\+\-\.]+)@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)')

Autres

Tr

SC1017 (error): Literal carriage return. Run script through

tr -d '\r' .

Convertir les fins de ligne en null char

tr '\n' '\0'
Preserve file timestamp in multifile string replace

Source : https://gist.github.com/u0d7i/c03e34e57802d0b6347a#file-preserve_date_in_replace-txt

# -I to grep ignores binary files,
# @ in sed works as separator for strings with /
# -r in touch uses existing file timestap as a reference
 
grep -IR aaaa /somepath/ | awk -F: '{print $1}' | while read line; do touch -r $line /tmp/timeref; sed -i 's@aaaa@bbbb@' $line; touch -r /tmp/timeref $line; done
2025/03/24 15:06

Notes sécurité

Matériel / Hardware

Protocole

Texto / SMS : \ Signaling System #7

Failles CVE

Voir :

Failles

Logiciel / Application

Logiciels / Applications “sécurisées”

https://fr.m.wikipedia.org/wiki/ANOM_Operation_Trojan_Shield

Antivirus et autres cochonneries :

Autres

JumpServer / Wallix access Manager / CyberArk et autres

Hardening

Web HTTP / HTTPS

Crypto

Générateur de nombres pseudo aléatoire

Attaque de la chaîne d'approvisionnement - Power supplies to attack

https://linuxfr.org/news/xz-et-liblzma-faille-de-securite-volontairement-introduite-depuis-au-moins-deux-mois

De plus en plus nous constatons des commits non pas pour corrigés mais pour inclure volontairement des failles de sécurité. Cela avait conduit Linus Torvald à refuser dans le noyau toutes les contributions de l'université du Minnesota https://linux.developpez.com/actu/314666/La-Fondation-Linux-veut-des-details-sur-toutes-les-contributions-au-noyau-Linux-faites-par-l-universite-du-Minnesota-avant-qu-elle-ne-soit-autorisee-a-contribuer-a-nouveau-au-noyau/ Il y avait aussi eu l'affaire node-ipc https://www.lemondeinformatique.fr/actualites/lire-avec-le-sabotage-de-node-ipc-la-protestation-dans-l-open-source-inquiete-86188.html Il y a encore peu de temps nous considérions systématiquement un système à jour comme plus fiable qu'un système pas à jour. Cela n’est pas forcément vrai à présent. La simplicité, le coût et la portée considérable d’une attaque de la chaîne d'approvisionnement laisse à penser que ce genre d’attaque va encore s’accroitre.

Code

Pishing

client-side scanning (CSS)

Cell-Site Simulators

Notes techniques

~/.mysql_history

Howto

Audit sécurité

Vérif toutes les urls si setup.php etc….

Kernel LINUX

Kernel Linux MAC LSM

/sys/kernel/security/lsm

Spectre / Meltdown / Retbleed

Autres

URLs à bloquer / WAF reverse proxy / firewall applicatif

Passer à bloquer les URLs suivantes :

*/nohup.out

Frameworks

Template Description
CIS CSC v8.1 Center for Internet Security Controls v8.1 framework covering foundational, foundational, and organizational security controls.
CSA CCM v4 Cloud Security Alliance Cloud Controls Matrix v4 framework for cloud security assurance.
Cyber Essentials UK government-backed Cyber Essentials scheme covering five key technical controls.
DORA Digital Operational Resilience Act framework for financial sector ICT risk management.
FedRAMP High Federal Risk and Authorization Management Program High baseline for US federal cloud services.
FedRAMP Low Federal Risk and Authorization Management Program Low baseline for US federal cloud services.
FedRAMP Moderate Federal Risk and Authorization Management Program Moderate baseline for US federal cloud services.
IRAP Official Australian Information Security Registered Assessors Program Official classification framework.
IRAP Protected Australian Information Security Registered Assessors Program Protected classification framework.
IRAP Secret Australian Information Security Registered Assessors Program Secret classification framework.
IRAP Top Secret Australian Information Security Registered Assessors Program Top Secret classification framework.
ISMAP Japanese Information System Security Management and Assessment Program framework.
ISO 27001:2022 International standard for information security management systems.
NIS 2 EU Network and Information Security Directive 2 framework for critical infrastructure.
NIST 800-171 Rev. 3 CMMC NIST SP 800-171 Revision 3 Cybersecurity Maturity Model Certification framework.
NIST SP 800-218 NIST Secure Software Development Framework (SSDF) v1.1.
NIST 800-53 Revision 5 NIST SP 800-53 Rev. 5 security and privacy controls for information systems.
SOC 2 System and Organization Controls 2 framework with requirements mapped to COSO principles, covering vulnerability scanning, access controls, and change management.
TISAX Trusted Information Security Assessment Exchange framework for automotive industry information security requirements

Source : https://docs.gitlab.com/user/compliance/compliance_frameworks/

2025/03/24 15:06

Caractère spéciaux Unicode / UTF8

Voir :

Voir aussi :

  • convmv
  • textconv
  • unaccent

Sous ouindoze il suffit de maintenir la touche Alt puis de taper le code ASCII Étendu en décimal avec le pavé numérique.

Ce n'est pas sans faire rappeler “La Matrice” avec la fameuse Libcaca.

Quand est-il sous GNU/Linux ?

Ben, ça fait longtemps que la plupart des distributions sont en UTF-8, donc nous pouvons insérer des caractères Unicode.

Voici comment :

Maintenir simultanément enfoncés les touches Ctrl + Shift + U

Ne marche que sur les applications GTK

Puis tapez le numéro Unicode du symbole souhaité.

Par exemple pour le symbole coché :

Ctrl + Shift + U
Puis 2713
Donne: ✓

Ctrl + Shift + U
Puis 2717
Donne : ✗

Voir :

Pb

Pb si certains caractères unicode sous Debian ne sont pas afficher correctement

Solution

apt-get install unifont
Avec l'interface graphique

Sinon en outil graphique il existe Gucharmap

apt-get install gucharmap
Pb 'ascii' codec can't encode character

Non 7-Bit ASCII

ERROR keystone.common.wsgi UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 27: ordinal not in range(128)
printf '\ue9' | grep -P '\xe9'
#grep '\\C3\\A9'
Pb vim characters "[0m|"

How to remove “[0m|” ? \ Wrong locale

Try

env LC_ALL=en_US.UTF-8 vim README.md
# LC_ALL=C.UTF-8

Ou

export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="en_US.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="en_US.UTF-8"
export LC_MEASUREMENT="en_US.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"
export LC_ALL=
Pb accent - grep ou diff

Diff NOK lors de :

docker exec 171daa9d9f62 cat plop.txt > /tmp/plop.txt
diff /tmp/plop.txt <(docker exec 171daa9d9f62 cat plop.txt)

Et grep message binary file matches alors qu'il s'agit bien d'un fichier texte.

$ grep red /tmp/plop.txt
grep: /tmp/plop.txt: binary file matches

$ file plop.txt
plop.txt: ISO-8859 text

$ grep --text red /tmp/plop.txt | cat -A
## environnement redondM-i$

$ grep --text red /tmp/plop.txt | grep red
grep: (standard input): binary file matches

$ grep --text red /tmp/plop.txt | sed -e 's/\xe9//g' | grep red
## environnement redond

Le caractère E9 est pourtant un caractère correcte en ASCII étendue

Solution

  • Supprimer les caracères non ASCII
  • Ou utiliser unaccent
unaccent ISO-8859-1 /tmp/plop.txt

CRLF

Voir aussi CRNL : Carriage return (to) newline

https://docs.ansible.com/projects/ansible/latest/dev_guide/testing/sanity/line-endings.html

All files must use \n for line endings instead of \r\n

Autres

/usr/bin/isutf8

mv App.ini.j2 App.ini.j2.bak
# iconv -f iso-8859-1 -t utf-8 App.ini.j2.bak > App.ini.j2
iconv -f iso-8859-15 -t utf-8 App.ini.j2.bak > App.ini.j2
 
# convmv -f iso-8859-1 -t utf8 DIR
# convmv -f iso-8859-15 -t utf8 DIR

Exemple

install.sh:4:22: invalid UTF-8 encoding
iconv -f iso-8859-15 -t utf-8 install.sh > install2.sh
iconv -f utf-8 -t ascii//TRANSLIT README.md > README2.md
Pb hGetContents: invalid argument (invalid byte sequence)
$ shellcheck plop.sh
plop.sh: plop.sh: hGetContents: invalid argument (invalid byte sequence)

$ file plop.sh
plop.sh:    Bourne-Again shell script, ISO-8859 text executable

$ iconv -t utf-8 plop.sh > mkiso-debian3.sh
iconv: illegal input sequence at position 2582

$ iconv -f iso-8859-1 -t utf-8 plop.sh > plop2.sh
$ file plop*
plop1.tcl:			Unicode text, UTF-8 text, with CRLF line terminators
plop2.tcl:			Unicode text, UTF-8 text


$ dos2unix plop1.tcl
$ dos2unix plop2.tcl
$ file plop*
plop1.tcl:                      ISO-8859 text
plop2.tcl: 			ISO-8859 text
diff <(cat -A plop.yml) <(cat plop.yml | sed -e 's/$/$/g' )

Autres

Idée #1

Adoptez une approche radicalement différente : modifiez le fichier en UTF-8, suivez-le dans Git en UTF-8, mais demandez à votre outil de build de le convertir en ISO-8859-1 afin que la machine Windows puisse l'utiliser.

Unicode contient tous les caractères ISO-8859-1 en tant que points de code : https://en.wikipedia.org/wiki/ISO/IEC_8859-1

Je pense que cela signifie que tous les caractères ISO-8859-1 ont un équivalent exact en Unicode, vous devriez donc pouvoir représenter parfaitement les fichiers ISO-8859-1.

Cela suppose que vous n'utilisez pas un outil Windows pour le modifier, mais si c'est le cas, vous pouvez effectuer une conversion bidirectionnelle. Et cela suppose également que vous avez un outil de build et qu'il peut gérer cela

Idée #2

Configurez des filtres smudge et clean https://git-scm.com/docs/gitattributes#_filter (pour ce fichier) pour convertir UTF-8 en ISO-8859-1 lors du checkout et vice versa lors de la mise en scène/validation. Maintenant, votre copie de travail est en ISO-8859-1, mais Git la suit en UTF-8. C'est plus automatique, mais peut-être un peu plus sujet aux erreurs car (je pense) il doit être correctement configuré dans chaque référentiel. De plus, le fait que cela résolve réellement votre problème dépendrait de la façon dont git diff fonctionne avec les filtres. Si tout est nettoyé (en UTF-8 dans votre cas) avant la comparaison, il semble que cela résoudrait ce problème.

2025/03/24 15:06

Notes sécurité PAM

Modules

  • pam_timestamp.so
  • pam_permit.so
  • pam_xauth.so
  • pam_permit.so
  • pam_exec.so

Notes

/home/$USER/.pam_environment

Autres

-session   optional   pam_systemd.so

Le “-” indiquant que ce n'est pas essentiel à la session.

2025/03/24 15:06

Notes sécurité OS GNU/Linux hardening

Vulnérabilités connues

apt-get install debsecan
debsecan

Mise à jour automatique

apt-get install unattended-upgrades

Scan intégrité fichiers

Find

Recherche de fichier SUID (4000) et SGID (2000)

find / -type f \( -perm -4000 -o -perm -2000 \)         \
        -not \(                                         \
        -wholename "/proc/*"                            \
        -o -wholename "/var/lib/docker/aufs/*"          \
        -o -wholename /usr/bin/chage                    \
        -o -wholename /usr/bin/newgrp                   \
        -o -wholename /usr/bin/passwd                   \
        -o -wholename /usr/bin/gpasswd                  \
        -o -wholename /usr/bin/expiry                   \
        -o -wholename /bin/su                           \
        -o -wholename /bin/mount                        \
        -o -wholename /bin/ping6                        \
        -o -wholename /bin/ping                         \
        -o -wholename /bin/umount                       \
        -o -wholename /sbin/unix_chkpwd                 \
        -o -wholename /usr/bin/pumount                  \
        -o -wholename /usr/bin/pmount                   \
        -o -wholename /usr/bin/sudo                     \
        -o -wholename /usr/bin/crontab                  \
        -o -wholename /usr/bin/mlocate                  \
        -o -wholename /sbin/mount.cifs                  \
        -o -wholename /bin/fusermount                   \
        -o -wholename /bin/ntfs-3g                      \
        -o -wholename /usr/lib/dbus-1.0/dbus-daemon-launch-helper \
        -o -wholename /usr/bin/at                       \
        -o -wholename /usr/lib/eject/dmcrypt-get-device \
        -o -wholename /usr/lib/utempter/utempter        \
        \)
 
        #-o -wholename /usr/bin/wall                    \
        #-o -wholename /usr/bin/chsh                    \
        #-o -wholename /usr/bin/ssh-agent               \
        #-o -wholename /usr/lib/openssh/ssh-keysign     \
        #-o -wholename /usr/bin/bsd-write               \
        #-o -wholename /usr/bin/udevil                  \
        #-o -wholename /usr/bin/chfn                    \
        #-o -wholename /usr/bin/dotlockfile             \
        #-o -wholename /usr/sbin/exim4                  \
        #-o -wholename /usr/bin/beep                    \

Supression du bit SUID

chmod u-s /usr/bin/chsh
chmod u-s /usr/bin/chfn
chmod u-s /usr/lib/openssh/ssh-keysign
chmod u-s /usr/sbin/exim4

Supression du bit SGID

chmod g-s /usr/bin/dotlockfile
chmod g-s /usr/bin/ssh-agent
chmod g-s /usr/bin/wall

Worldreadable

find / \( -type d -o -type f \)  -not \( -wholename "/proc/*" -o -wholename "/dev/*" -o -wholename "/var/lib/docker/aufs/*" \) -perm /o=w -not -perm /o=t -ls

Comptes

perl -a -F':' -ne '$HOMEUSER=$F[5] ; $CHAINE="$HOMEUSER/.ssh/authorized_keys\n" ; $CHAINE=~s|//|/| ; print $CHAINE unless /false$/ or /nologin$/' /etc/passwd

sysctl

Voir https://www.it-connect.fr/details-durcissement-sysctl-systeme-linux/

Interdire strace

echo 3 > /proc/sys/kernel/yama/ptrace_scope

Mot de passe

Lenteur à la connexion

man 3 crypt

/etc/shadow

plop1:$6$rounds=656000$P7gp1PPaN9bdjMt/$M2xJFWCpmlTS8CkYCHOnjI1TqfhIabgkJhp4HNvHHsI3NkXYJ2vZ.OVSNpOtee3sXJQcCdcZhezlQfrHZm3fE1:18369:0:99999:7::: 

plop1:$6$LCJMGXiumcpyY7nP$8t/u6oewRH.GHk94QKmN/1pZyMFCIwG4Y/JzUF/qKSVU9/U.BhG1Vm6fpYIuUaZuIJq5b6omuGJVpD9XxFisM.:18369:0:99999:7:::

https://askubuntu.com/questions/894404/how-to-increase-the-number-of-hashing-rounds-for-etc-shadow

/etc/pam.d/common-password

#password       [success=1 default=ignore]      pam_unix.so obscure sha512
password        [success=1 default=ignore]      pam_unix.so obscure sha512 rounds=656000

Voir SHA_CRYPT_MIN_ROUNDS

man pam_unix
 
sudo chpasswd -s 10000 000 -c SHA512 <<< username:password; history -c

/etc/pam.d/common-password

password        [success=1 default=ignore]      pam_unix.so obscure sha512 rounds=656000
auth required pam_tally2.so onerr=fail deny=3 unlock_time=900 root_unlock_time=900 file=/var/log/tallylog

pam_tally2 --file /var/log/tallylog --reset --user root

pam_faildelay.so
faillock --user aaronkilik --reset 
faillock --user aaronkilik
fail --reset	#clears all authentication failure records
chown root:root /boot/grub2/grub.cfg
chmod og-rwx /boot/grub2/grub.cfg

Set the following restrict parameters in /etc/ntp.conf or use /etc/systemd/timesyncd.conf (for Debian) /etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

Set the following restrict parameters in /etc/ntp.conf /etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

/etc/ntp.conf

Also, make sure /etc/ntp.conf has an NTP server specified
server <ntp-server>

Set the net.ipv4.ip_forward parameter to 0 in /etc/sysctl.conf Modify active kernel parameters to match:

/sbin/sysctl -w net.ipv4.ip_forward=0
/sbin/sysctl -w net.ipv4.route.flush=1
chown root:root /etc/cron.d
chmod og-rwx /etc/cron.d
rm /etc/at.deny
touch /etc/at.allow
chown root:root /etc/at.allow
chmod og-rwx /etc/at.allow

Edit the /etc/bashrc and /etc/profile.d/cis.sh files (and the appropriate files for any other shell supported on your system) and add the or use PAM following the UMASK parameter as shown

umask 027

Pas de version dans les fichiers suivants

  • /etc/motd
  • /etc/issue
  • /etc/issue.net

Service SystemD

/lib/systemd/system/wsl-pro.service

[Unit]
Description=Bridge to Ubuntu Pro agent on Windows
ConditionVirtualization=wsl
 
[Service]
Type=notify
ExecStart=/usr/libexec/wsl-pro-service -vv
Restart=always
RestartSec=2s
 
# Some daemon restrictions
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=true
PrivateDevices=yes
PrivateMounts=yes
PrivateTmp=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallArchitectures=native
 
# Only permit system calls used by common system services, excluding any special purpose calls
SystemCallFilter=@system-service
 
[Install]
WantedBy=multi-user.target

Autre

apt-get install auditd

Partition dédiée pour

  • /var/log
  • /var/log/audit/
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki