Outils pour utilisateurs

Outils du site


blog

Contrôle d'intégrité des fichiers avec AIDE

Install

apt-get install aide

Utilisation

Initialisation

aideinit

Contrôle

aide.wrapper --check
 
aide.wrapper --check --limit /etc

Mise à jour de la base

aide.wrapper -u

Configuration

/etc/aide/aide.conf.d/31_aide_plop

#/var/log$ VarDir

# Exlusion list
!/var/lib/docker/
!/var/log/journal/
!/var/log/commands.log
!/run/
!/mnt/
!/etc/.git/
!/etc/.etckeeper
!/var/tmp/
!/var/log/
!/root/.viminfo
!/root/.bash_history
!/root/.lesshst
!/var/lib/sss/mc/passwd
!/usr/NX/var/tmp/
!/var/lib/sss/db/

Check conf

aide.wrapper --config-check

Pb

Segmentation fault (core dumped)
# aideinit
Overwrite existing /var/lib/aide/aide.db.new [Yn]? Y
Running aide --init...
Segmentation fault (core dumped)
AIDE --init return code 139
# dmesg | tail
[169712.662630] aide[428807]: segfault at 0 ip 00007f9fd5e7b14b sp 00007ffc48052578 error 4 in libc-2.31.so[7f9fd5d80000+178000]
[169712.662645] Code: 89 01 48 83 c8 ff c3 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 8b 05 25 ad 0c 00 48 83 ff 10 74 47 48 83 ff 1a 74 49 48 8b 40 60 <48> 8b 10 48 85 d2 75 12 eb 1b 0f 1f 00
48 8b 50 10 48 83 c0 10 48
Solution : Exclure les dossiers problématiques

Trouver la où se plante avec lsof ou strace

aideinit &
 
while PID_AIDE=$(pgrep aide || exit 2) ; do lsof -p $(pgrep -n aide) | tee -a aide_lsof.log ; done
 
watch -d lsof -p $(pgrep -n aide)

Créer une liste d'exclusions /etc/aide/aide.conf.d/31_aide_plop

!/var/lib/docker/
!/var/log/journal/

puis relancer

aideinit
Erreur Database does not have attr field.
aide --check -c /etc/aide/aide.conf
Database does not have attr field.
Comparation may be incorrect
Generating attr-field from dbspec
It might be a good Idea to regenerate databases. Sorry.
db_char2line():Error while reading database

La base n'est pas complete. Vérifier la taille de /var/lib/aide/aide.db.new.

Solution

Si paquet aide-common installé

aideinit

Sinon

aide --init -c /etc/aide/aide.conf
cp -p /var/lib/aide/aide.db.new /var/lib/aide/aide.db

Notes

Debug

aide -D
aide -V255 --config=/etc/aide/aide.conf -C

Conf

/etc/aide/aide.conf.d/31_aide_plop

#/var/log$ VarDir
!/var/lib/docker/
!/var/log/journal/
!/var/log/commands.log
!/run/
!/etc/.git/
!/etc/.etckeeper
!/var/tmp/
!/var/log/
!/root/.viminfo
!/root/.bash_history
!/root/.lesshst

Source : https://raw.githubusercontent.com/duritong/puppet-aide/master/files/aide.conf

/etc/aide.conf

# AIDE conf

database=file:/var/lib/aide/aide.db
database_out=file:/var/lib/aide/aide.db.new

# Change this to "no" or remove it to not gzip output
# (only useful on systems with few CPU cycles to spare)
gzip_dbout=yes

# Here are all the things we can check - these are the default rules 
#
#p:      permissions
#i:      inode
#n:      number of links
#u:      user
#g:      group
#s:      size
#b:      block count
#m:      mtime
#a:      atime
#c:      ctime
#S:      check for growing size
#md5:    md5 checksum
#sha1:   sha1 checksum
#rmd160: rmd160 checksum
#tiger:  tiger checksum
#R:      p+i+n+u+g+s+m+c+md5
#L:      p+i+n+u+g
#E:      Empty group
#>:      Growing logfile p+u+g+i+n+S
#haval:         haval checksum
#gost:          gost checksum
#crc32:         crc32 checksum

# Defines formerly set here have been moved to /etc/default/aide.

# Custom rules
Binlib = p+i+n+u+g+s+b+m+c+md5+sha1
ConfFiles = p+i+n+u+g+s+b+m+c+md5+sha1
Logs = p+i+n+u+g+S
Devices = p+i+n+u+g+s+b+c+md5+sha1
Databases = p+n+u+g
StaticDir = p+i+n+u+g
ManPages = p+i+n+u+g+s+b+m+c+md5+sha1

# Next decide what directories/files you want in the database

# Kernel, system map, etc.
=/boot$ Binlib
# Binaries
/bin Binlib
/sbin Binlib
/usr/bin Binlib
/usr/sbin Binlib
/usr/local/bin Binlib
/usr/local/sbin Binlib
#/usr/games Binlib
# Libraries
/lib Binlib
/usr/lib Binlib
/usr/local/lib Binlib
# Log files
#=/var/log$ StaticDir
#!/var/log/ksymoops
#/var/log/aide/aide.log(.[0-9])?(.gz)? Databases
#/var/log/aide/error.log(.[0-9])?(.gz)? Databases
#/var/log/setuid.changes(.[0-9])?(.gz)? Databases
#!/var/log/aide
#/var/log Logs
# Devices
!/dev/pts
# If you get spurious warnings about being unable to mmap() /dev/cpu/mtrr,
# you may uncomment this to get rid of them. They're harmless but sometimes
# annoying.
#!/dev/cpu/mtrr
#!/dev/xconsole
/dev Devices
# Other miscellaneous files
/var/run$ StaticDir
!/var/run
# Test only the directory when dealing with /proc
/proc$ StaticDir
!/proc

# You can look through these examples to get further ideas

# MD5 sum files - especially useful with debsums -g
#/var/lib/dpkg/info/([^\.]+).md5sums u+g+s+m+md5+sha1

# Check crontabs
#/var/spool/anacron/cron.daily Databases
#/var/spool/anacron/cron.monthly Databases
#/var/spool/anacron/cron.weekly Databases
#/var/spool/cron Databases
#/var/spool/cron/crontabs Databases

# manpages can be trojaned, especially depending on *roff implementation
#/usr/man ManPages
/usr/share/man ManPages
/usr/local/man ManPages

# docs
#/usr/doc ManPages
/usr/share/doc ManPages

# check users' home directories
#/home Binlib

# check sources for modifications
#/usr/src L
#/usr/local/src L

# Check headers for same
/usr/include L
#/usr/local/include L

#!/var/log/portage/elog
#!/var/log/puppet/puppet.log
!/var/log     # ignore the log dir it changes too often
!/dev/disk/by-uuid  # ignore, because its only crypt-swap, that changes every boot ...
2025/03/24 15:06

Variable TMOUT en lecture seule readonly variable

Pour contourner un bash timeout définie par une variable TMOUT en lecture seul par exemple avec la ligne suivante dans le .bashrc :

declare -rix TMOUT=900
# echo $TMOUT
900

/etc/profile.d/tmout.sh

#declare -rix TMOUT="900"
 
TMOUT=900
readonly TMOUT
export TMOUT
# unset TMOUT
bash: unset: TMOUT: cannot unset: readonly variable

Solution pour contourner un bash timeout TMOUT

env TMOUT= bash --init-file /dev/null
2025/03/24 15:06

Construire un paquet Debian .deb

Pour construire un paquet à partir des sources

Voir checkinstall http://openmaniak.com/fr/checkinstall.php

Voir Debian - Construction d un paquet a partir des sources - wdfs

Construire un paquet Debian .deb

Créer un répertoire temporaire. Entrer dans ce répertoire.
Télécharger la source .tar.gz d'origine et la nommer ex.: package_x.x.x.orig.tar.gz
Décompresser la source d'origine dans un dossier nommé package-x.x.x. C'est dans ce dossier qu'il faut effectuer les modifications (ex. créer /debian avec dh_make)
À la racine du répertoire package-x.x.x, entrer "dpkg-buildpackage -rfakeroot" pour lancer la génération du .deb
Dans le répertoire temporaire (..), en plus du .deb on devrait maintenant avoir un diff.gz, en plus d'un .dsc 

Et pour générer un .src.deb:

Créer le .src.deb avec: ar -r package_x.x.x-x_arch.src.deb package_x.x.x-x.diff.gz package_x.x.x-x.dsc package_x.x.x.orig.tar.gz

Création d'un paquet Debian - Exemple avec NodeJS

Voir : https://github.com/ruxkor/checkinstall/blob/master/checkinstallrc-dist

wget https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz
tar xvf node-v8.9.3.tar.gz
cd node-v8.9.3
 
./configure
make -j $(nproc)
 
cat >description-pak <<EOF
evented I/O for V8 javascript
 
Node.js is a platform built on Chrome's JavaScript runtime for easily
building fast, scalable network applications. Node.js uses an
event-driven, non-blocking I/O model that makes it lightweight and
efficient, perfect for data-intensive real-time applications that run
across distributed devices.
EOF
 
echo | fakeroot checkinstall --install=no \
	--strip \
	--nodoc \
	--exclude '/home,/usr/local/include' \
	--gzman \
	--reset-uids \
	--maintainer 'Plop \<plop@acme.fr\>' \
	--pkglicense 'GPL' \
	--pkgname nodejs \
	--pkgrelease 1 \
	--pkgversion 8.9.3 \
	--pkggroup web \
	--pkgsource 'https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz' \
	--requires 'libc-ares2 (>= 1.8.0), libc6 (>= 2.14), libgcc1 (>= 1:4.1.1), libssl1.0.0 (>= 1.0.1), libstdc++6 (>= 4.1.1), libv8-3.14.5, zlib1g (>= 1:1.1.4)'
#	--review-control

Méthode 2

Voir :

  • dpkg-dev: /usr/bin/dpkg-buildpackage
  • lintian
  • dh-make
  • debhelper
apt-get install dh-make debhelper lintian
apt-get install dpkg-dev # dpkg-buildpackage
dh_make --single --native --yes --email root@localhost
 
cd  /debian/
dos2unix preinst postinst prerm postrm copyright control
 
# Modification de la cible dh_install dans le fichier debian/rules
cat >> debian/rules << FIN_AJOUT_debian_rules
override_dh_install:
        dh_install --sourcedir=$X_BASEDIR/src
FIN_AJOUT_debian_rules
 
dpkg-buildpackage -us -uc 2>&1 > /dev/null
 
# Vérification par lintian
lintian --suppress-tags dir-or-file-in-opt,embedded-library,executable-not-elf-or-script ../${PKG_NAME}_${PKG_VERSION}_amd64.deb			

Notes

Les scripts de postinstall et autres sont dans /var/lib/dpkg/info

# ls -1 /var/lib/dpkg/info/atop.*
/var/lib/dpkg/info/atop.conffiles
/var/lib/dpkg/info/atop.list
/var/lib/dpkg/info/atop.md5sums
/var/lib/dpkg/info/atop.postinst
/var/lib/dpkg/info/atop.postrm
/var/lib/dpkg/info/atop.preinst
/var/lib/dpkg/info/atop.prerm

Autres

/usr/share/apport/package-hooks/wsl-pro-service.py

`'apport package hook for wsl-pro-service
 
(c) Canonical Ltd.
`'
 
import apport.hookutils
 
def add_info(report):
    pass
2025/03/24 15:06

Console Linux polluee par les messages d erreur du kernel

Solution

echo 0 > /proc/sys/kernel/printk

source https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt Documentation/admin-guide/kernel-parameters.txt

	loglevel=	All Kernel Messages with a loglevel smaller than the
			console loglevel will be printed to the console. It can
			also be changed with klogd or other programs. The
			loglevels are defined as follows:

			0 (KERN_EMERG)		system is unusable
			1 (KERN_ALERT)		action must be taken immediately
			2 (KERN_CRIT)		critical conditions
			3 (KERN_ERR)		error conditions
			4 (KERN_WARNING)	warning conditions
			5 (KERN_NOTICE)		normal but significant condition
			6 (KERN_INFO)		informational
			7 (KERN_DEBUG)		debug-level messages

Autres

Au boot
systemd.log_level=0
2025/03/24 15:06

Connexion SSH via proxy HTTP

Le proxy doit très probablement accepter de joindre les ports distants 80 (HTTP) et 443 (HTTPS). Il peut être nécessaire de faire écouter le serveur SSH sur l'un de ces ports. \ Voir tunnel_ssh_over_https

Install de corkscrew (tire-bouchon en anglais)

sudo apt-get install corkscrew

Configuration du client SSH

.ssh/config

Host plop
    Hostname plop.acme.fr
    Port 443
    ProxyCommand /usr/bin/corkscrew 192.168.56.1 3128 %h %p
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