Outils pour utilisateurs

Outils du site


blog

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

Caractère spéciaux Unicode / UTF8

Voir :

Voir aussi :

  • convmv
  • textconv

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 : ✗

https://fr.wikipedia.org/wiki/Coche_%28typographie%29

https://en.wikipedia.org/wiki/Unicode_input

https://fr.wikipedia.org/wiki/Aide:Caract%C3%A8res_sp%C3%A9ciaux_probl%C3%A9matiques

http://michal.kosmulski.org/computing/articles/linux-unicode.html

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=

CRLF

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é 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

Notes sécurité OS GNU/Linux hardening - partitions - noexec

Voir aussi :

FS noexec - Sécurité Montage Système de fichier

nodev,nosuid,noexec,ro

echo "/var/tmp /tmp    none bind 0 0" >> /etc/fstab

/etc/apt/apt.conf.d/01PrePost

DPkg {
        Pre-Invoke  { "mount /var -o remount,exec"; "mount /tmp -o remount,exec"; "mount /var/tmp -o remount,exec" };
        Post-Invoke { "mount /var -o remount,noexec"; "mount /tmp -o remount,noexec"; "mount /var/tmp -o remount,noexec"  };
};

Pour des raisons de sécurité, il est recommandé de monter /tmp en noexec cependant Debian à besoin des droits exec lors de mise-à-jour. Voici une solution :

/etc/apt/apt.conf.d/70debconf

DPkg::Pre-Install-Pkgs {"mount -o remount,exec /tmp; /usr/sbin/dpkg-preconfigure --apt || true";};
DPkg::Post-Invoke {"mount -o remount /tmp";};

Pour plus de sécurité, on pourra monter certaines partitions avec des options particulières :

Partition Options de montage
/ noatime,ro
/boot noatime,nodev,nosuid,noexec,ro
/tmp noatime,nodev,nosuid,noexec
/usr noatime,nodev,ro
/var noatime,nodev,nosuid,noexec
/home noatime,nodev,nosuid noexec,usrquota,grpquota

Noatime : Pour toutes les partitions. Voir debian_noatime Nodev : Pour toutes les partitions sauf /dev Nosuid : Pour toutes les partitions sauf / et /usr Noexec : Pour /tmp et /run/shm (pour /run/shm c'est normalement le cas par défaut). Si possible aussi pour /var ro : / et /usr

# Dev
find / \( -type b -o -type c \) -not -wholename "/dev/*"
# Suid
find / -type f -perm /a+s
# Partition /run/shm ou /dev/shm. Doit-être en nosuid,nodev,noexec
mount | grep shm

A tester

/lib64/ld-linux-x86-64.so.2 /bin/echo "Plop"
2025/03/24 15:06

Notes seafile avec Nginx sous Debian

Voir aussi :

  • rclone
  • directive sendfile_max_chunk pour Nginx

Votre navigateur doit envoyer le “Referer” HTTP. Si besoin utiliser pour Firefox RefControl

Liens :

adduser --group --system --disabled-password seafile
apt-get install python-setuptools python-imaging

/etc/nginx/sites-available/seafile.acme.fr

server {
        listen 80;
        server_name seafile.acme.fr;
        rewrite ^ https://$server_name$request_uri? permanent;
}
 
server {
        listen 443 ssl;
        server_name seafile.acme.fr;
        ssl_certificate /etc/ssl/private/acme.crt+chain;
        ssl_certificate_key /etc/ssl/private/acme.fr.key;
 
        access_log /var/log/nginx/access_seafile_log;
        error_log /var/log/nginx/error_seafile_log;
 
        proxy_set_header X-Forwarded-For $remote_addr;
 
        location / {
                proxy_bind http://127.0.0.1:8080 ;
#                fastcgi_pass    127.0.0.1:8000;
#                fastcgi_param   HTTPS               on;
#                fastcgi_param   HTTP_SCHEME         https;
#                fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
#                fastcgi_param   PATH_INFO           $fastcgi_script_name;
#                fastcgi_param   SERVER_PROTOCOL     $server_protocol;
#                fastcgi_param   QUERY_STRING        $query_string;
#                fastcgi_param   REQUEST_METHOD      $request_method;
#                fastcgi_param   CONTENT_TYPE        $content_type;
#                fastcgi_param   CONTENT_LENGTH      $content_length;
#                fastcgi_param   SERVER_ADDR         $server_addr;
#                fastcgi_param   SERVER_PORT         $server_port;
#                fastcgi_param   SERVER_NAME         $server_name;
#                fastcgi_param   REMOTE_ADDR         $remote_addr;
        }
 
        location /seafhttp {
                rewrite ^/seafhttp(.*)$ $1 break;
                proxy_pass http://127.0.0.1:8082;
                #include         /etc/nginx/proxy_params;
                client_max_body_size 0;
                proxy_request_buffering off;
                proxy_connect_timeout  36000s;
                proxy_read_timeout  36000s;
                proxy_send_timeout  36000s;
        }
 
        location /media {
                root /var/www/seafile/seafile-server-latest/seahub ;
        }
}

Derrière un reverse proxy Nginx

On NGINX Reverse-proxy Server

/etc/nginx/sites-available/files2.acme.fr

server {
        listen 80;
        server_name files2.acme.fr www.files2.acme.fr;
        rewrite ^ https://$server_name$request_uri? permanent;
}
 
server {
        listen 443 ssl;
        server_name files2.acme.fr www.files2.acme.fr;
 
        ssl_certificate /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key /etc/nginx/ssl/nginx.key;
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
 
        server_tokens off;
        proxy_set_header X-Forwarded-For $remote_addr;
 
        access_log /var/log/nginx/access_seafile_log;
        error_log /var/log/nginx/error_seafile_log;
 
        client_max_body_size 0;
        #client_body_buffer_size 128k;
 
        location /seafhttp {
                rewrite ^/seafhttp(.*)$ $1 break;
                proxy_pass http://192.168.15.149:8082;
                client_max_body_size 0;
                #proxy_request_buffering off;
                proxy_connect_timeout  36000s;
                proxy_read_timeout  36000s;
                proxy_send_timeout  36000s;
 
        }
 
 
        location / {
                proxy_pass http://192.168.15.149:8000;
#                fastcgi_pass    192.168.15.149:8000;
#                fastcgi_param   HTTPS               on;
#                fastcgi_param   HTTP_SCHEME         https;
#                fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
#                fastcgi_param   PATH_INFO           $fastcgi_script_name;
#                fastcgi_param   SERVER_PROTOCOL    $server_protocol;
#                fastcgi_param   QUERY_STRING        $query_string;
#                fastcgi_param   REQUEST_METHOD      $request_method;
#                fastcgi_param   CONTENT_TYPE        $content_type;
#                fastcgi_param   CONTENT_LENGTH      $content_length;
#                fastcgi_param   SERVER_ADDR        $server_addr;
#                fastcgi_param   SERVER_PORT        $server_port;
#                fastcgi_param   SERVER_NAME        $server_name;
#                fastcgi_param   REMOTE_ADDR         $remote_addr;
        }
 
        location /media {
                #root /var/www/html/seafile-server-latest/seahub/ ;
                proxy_pass http://192.168.15.149:8081;
                include /etc/nginx/proxy_params;
        }
 
}

On FILE Server

/etc/nginx/sites-enabled/file2.acme.fr

server {
        listen 8081;
 
        access_log /var/log/nginx/access_seafile_log;
        error_log /var/log/nginx/error_seafile_log;
 
        server_tokens off;
 
        location /media {
                root /var/www/html/seafile-server-latest/seahub/ ;
        }
}

conf/seafile.conf

[fileserver]
port=8082
host=0.0.0.0

conf/ccnet.conf

SERVICE_URL = https://files2.acme.fr

conf/seahub_settings.py

FILE_SERVER_ROOT = 'https://files2.acme.fr/seafhttp'
su - www-data -s /bin/bash
./seafile.sh start
export SEAFILE_FASTCGI_HOST='0.0.0.0'
./seahub.sh start-fastcgi

ln -s seafile-server-5.1.1 seafile-server-latest
cd seafile-server-latest
./setup-seafile.sh

~/conf/ccnet.conf

[General]
SERVICE_URL = https://seafile.acme.fr

~/conf/seafile.conf

[fileserver]
port=8083

~/conf/seahub_settings.py

FILE_SERVER_ROOT = 'https://seafile.acme.fr/seafhttp'
 
EMAIL_USE_TLS = False
EMAIL_HOST = 'localhost'
#EMAIL_HOST_USER = 'root@acme.fr'    # username and domain
#EMAIL_HOST_PASSWORD = 'password'    # password
EMAIL_PORT = 25
#DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
DEFAULT_FROM_EMAIL = 'contact@acme.fr'
#SERVER_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = 'contact@acme.fr'
./seafile.sh start
./seahub.sh start-fastcgi 8003

Clients

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