Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Notes cross-compilation
Voir : https://blog.svgames.pl/article/cross-compiling-c-programs-for-ms-windows-using-mingw
apt-get install crossbuild-essential-i386
Ou
cat /etc/apt/sources.list | grep debian | sed -e 's/stretch/jessie/g' | grep -v deb-src > /etc/apt/sources.list.d/jessie.list dpkg --add-architecture i386 apt-get update apt-get install mingw32 mingw32-binutils #apt-get install mingw-w64
plop.cpp
#include <iostream> int main(int argc, char** argv) { std::cout << "Hello" << std::endl; return 0; }
i586-mingw32msvc-g++ -o plop.exe plop.cpp
On windows error libstdc++-6.dll missing
Pour le plus avoir l'erreur \ Nous ne voulons plus de DLL, donc mettons tout en static
i586-mingw32msvc-g++ -o plop.exe plop.cpp
aptitude search '~n curl ~r i386' apt-get source curl:i386 apt-get source libcurl3:i386 libcurl3-gnutls:i386 cd curl #apt-get install crossbuild-essential-i386 export ARCH=i386 CROSS_COMPILE=arm-linux
make -f lazy_makefile CC=i686-w64-mingw32-gcc ./configure --host=i686-w64-mingw32 --enable-shared --disable-install-doc ./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 ./configure --host=x86_64-w64-mingw32 --disable-magic --disable-cuckoo --with-crypto CFLAGS=-I/root/openssl/include LDFLAGS=-L/root/openssl/lib --enable-static The right way to do this is to add the `-static` flag to an `LDFLAGS` variable. For all targets: `AM_LDFLAGS=-static` export CC=i586-mingw32msvc-cc ./configure --host=i686-w64-mingw32 --enable-static export CFLAGS='-static' make V=1 curl_LDFLAGS=-all-static git clone -b curl-tiny-7.72 https://github.com/curl/curl.git
libtool: error: Could not determine the host path corresponding to libtool: error: '/home/jibe/code/i386/curl-7.52.1/lib/.libs' libtool: error: Continuing, but uninstalled executables may not work. libtool: error: Could not determine the host path corresponding to libtool: error: '/home/jibe/code/i386/curl-7.52.1/lib/.libs:/usr/local/lib:/usr/local/bin' libtool: error: Continuing, but uninstalled executables may not work. make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/src' make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/src' Making all in include make[1]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include' Making all in curl make[2]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include/curl' make all-am make[3]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include/curl' make[3]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include/curl' make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include/curl' make[2]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include' make[2]: Nothing to be done for 'all-am'. make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include' make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include' make[1]: Entering directory '/home/jibe/code/i386/curl-7.52.1' make[1]: Nothing to be done for 'all-am'. make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1'
$ find . -iname curl.exe ./curl-7.52.1/src/.libs/curl.exe ./curl-7.52.1/src/curl.exe
Le bon est celui qui est dans src/.libs/
export AM_LDFLAGS='-static' git clone https://github.com/curl/curl.git cd curl git tag git checkout curl-7_9_8 export ROOTDIR="${PWD}" cd curl #$ export CROSS_COMPILE="arm-none-linux-gnueabi" #export CROSS_COMPILE="stable-i686-pc-windows-gnu" export CROSS_COMPILE="i686-w64-mingw32" #export CPPFLAGS="-I${ROOTDIR}/openssl/include -I${ROOTDIR}/zlib/include" export CPPFLAGS="-I${ROOTDIR}/openssl/include/openssl -I${ROOTDIR}/openssl/include/crypto -I${ROOTDIR}/openssl/include/internal" export LDFLAGS="-L${ROOTDIR}/openssl/libs -L${ROOTDIR}/zlib/libs" export AR=${CROSS_COMPILE}-ar export AS=${CROSS_COMPILE}-as export LD=${CROSS_COMPILE}-ld export RANLIB=${CROSS_COMPILE}-ranlib export CC=${CROSS_COMPILE}-gcc export NM=${CROSS_COMPILE}-nm export LIBS="-lssl -lcrypto" ./buildconf ./configure --prefix=${ROOTDIR}/build --target=${CROSS_COMPILE} --host=${CROSS_COMPILE} --build=i586-pc-linux-gnu --with-ssl --with-zlib
sudo apt-get build-dep curl
Pb
Err
m32test.c
#include <stdio.h> int main() { printf("This works\n"); return 0; }
$ gcc -m32 -o m32test m32test.c
In file included from /usr/include/stdio.h:27:0,
from m32test.c:2:
/usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory
# include <sys/cdefs.h>
^
compilation terminated.
# gcc -m32 -o m32test m32test.c
In file included from m32test.c:1:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
#include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Solution
apt-get install gcc-multilib
Err undefined reference to
Notes crontab
Voir aussi :
- vixie-cron
/etc/cron.d/plop
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # CRON_TZ=Europe/Paris 30 2 * * * root find /opt/plop/ -type f -name '*.old' -type f -mtime +20 -delete
Ici nous avons root en 6em position. Ce champs n'est présent uniquement pour les fichiers crontab dans /etc/cron.d
(1) valeur comprise entre 0 et 59
(2) valeur comprise entre 0 et 23
(3) valeur comprise entre 1 et 31
(4) valeur comprise entre 1 et 12
(5) valeur comprise entre 0 et 7 (Dimanche étant le 0 ou le 7) ou alors les abréviations correspondant aux jours de la semaine en Anglais: sun,mon,tue,wed,thur,fri,sat
(6) uniquement pour les fichiers crontab du système dans /etc/cron.d
(7) commande à effectuer
Sur RedHat 7 / CentOS 7 \ il suffit d'ajouter le fichier dans /etc/cron.d/ rien à faire (pas de redémarrage)
at
Voir :
at -t 202008171818 <<EOF wall plop EOF
Notes CouchDB
Voir aussi :
- MongoDB / DocumentDB / FerretDB
- ArangoDB
- RethinkDB
Voir :
- Kivik & kivik CLI tool
Code :
docker run -d --name my-couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password couchdb:3.2.1
WebUI Fauxton Futon
Ping
curl http://admin:password@127.0.0.1:5984
Pour Supervision
curl http://localhost:5984/_up
Show databases
curl http://admin:password@localhost:5984/_all_dbs
Create database
curl -X PUT http://127.0.0.1:5984/testdb
Show all docs
curl http://admin:password@localhost:5984/testdb/_all_docs curl http://admin:password@localhost:5984/testdb/_all_docs?include_docs=true
Upload binary file
curl -X PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/ artwork.jpg?rev=2-2739352689 --data-binary @artwork.jpg -H "Content-Type: image/jpg"
Opérandes de comparaison
https://guide.couchdb.org/draft/tour.html
https://dev.to/yenyih/query-in-apache-couchdb-mango-query-lfd
{ "selector": { "status": { "$eq": "draft" } }, "fields": ["_id", "_rev", "title", "content", "date", "author"], "sort": [], "limit": 10, "skip": 0, "execution_stats": true }
Bases
Insert - Post
curl -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test -d '{"type": "user", "username": "jean", "application": "app1"}' curl -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test -d '{"type": "host", "hostname": "srv1", "application": "app1"}'
Select - Get
curl -d '{"keys":["73ab9c8c5dad9442ae91e6e1920088a5"]}' -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_all_docs?include_docs=true | jq . curl -d ' { "selector": { "username": "jean" }, "fields": [ "application" ] } ' -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_find | jq .docs curl -d ' { "selector": { "hostname": "srv1", "application": { "$in": ["app1","app2"] } }, "fields": [ "application" ] } ' -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_find | jq .docs curl -X PUT http://admin:password@127.0.0.1:5984/db/_design/my_ddoc -d '{"views":{"my_filter":{"map": "function(doc) { if(doc.date && doc.title) { emit(doc.date, doc.title); }}"}}}'
function(doc){ emit(doc.table.id, null); } { "views": { "all": { "map": "function(doc) { emit(doc.title, doc) }", } } }
Programmation - db drivers
pycouchdb
Obsolète ?
pip install -U celery-with-couchdb pip install -U celery[couchdb]
https://couchdb-python.readthedocs.io/en/latest/getting-started.html https://readthedocs.org/projects/couchdb-python/downloads/pdf/latest/
https://pythonhosted.org/Flask-CouchDB/
pip install Flask-CouchDB
import couchdb couch = couchdb.Server('localhost:5984/') db = couch['newtweets'] count = 0 for docid in db.view('_all_docs'): i = docid['id']
Voir
- cloudant
- cloudant-python-sdk
pip install --upgrade "ibmcloudant>=0.0.42"
Outils tiers
CouchBackup
Source : https://blog.cloudant.com/2020/10/09/Automated-Daily-Backups.html
The couchbackup utility is a command-line tool that allows a Cloudant database to be turned a text file.
Turn our “animals” database into a text file
couchbackup --db animals > animals.txt
It comes with a matching utility which does the reverse: restores a text file back to a Cloudant database.
Restore our animals backup to a new database
cat animals.txt | couchrestore --db animals2
All we need to do is trigger couchbackup periodically to perform a backup.
CORS - Cross-origin resource sharing
Err Cannot load M3U8: Crossdomain access denied
Cannot load M3U8: Crossdomain access denied
Solution sous Firefox
Faite [F12] / Network puis [F5] pour trouver “CORS Missing Allow Origin” dans la colone “Transferred” \ Noter le ou les domaines concernés \ Installer l'extention “Cross Domain - CORS” \ Dans “Apply URL (regex)” saisir la (ou les) domaine \ Cliquer sur “Save” \ Le bouton “Cross Doamin” doit être Enable et vert. Cliquer sur “Save”
C'est mieux à présent j'ai un “403 Forbidden” mais c'est une autre histoire
Notes audit
Liens :
Note :
- Penser à vérifier le NTP / l'heure des serveurs
- Penser à vérifier le SMTP des fax, scanners, imprimantes
Quelques commande pour Audit système
Disques
lsblk
Réseaux
nft list ruleset iptables -vnxL ip6tables -vnxL ip -s macsec show ss -peaonmi resolvectl status resolvectl statistics
Fichier de conf
Debian DEB Voir audit_debian_differences_de_version_entre_un_fichier_d_origine_et_le_fichier_actuelle
dpkg -l LANG=C find /etc -type f -exec dpkg -S {} 2>&1 \; |grep -e '^dpkg-query:' |tee jb_dpkg-S.txt LANG=C debsums -as 2>&1 |tee jb_debsums.txt
Pour RedHat/CentOS RPM
rpm -Va
Exemple
rpm -V -a |egrep -v -e '^missing|/var/run|/var/log|\.jar$' |sed -e 's% c % %' |awk '{print $2}' |grep -v -e '/$' |cpio -ov --format=ustar |pigz > /tmp/plop/fic-${HOSTNAME}.tar.gz
Matos
Drivers
for MODULE in $(lsmod |sed 1d |awk '{print $1}') ; do modinfo $MODULE |grep -e '^filename:' |awk '{print $2}'| xargs dpkg -S || echo -e "\t ERR IN $MODULE"; done 2>&1 |tee jb_modules.txt
Voir DKMS /var/lib/dkms/megaraid-sas
# LANG=C dpkg -S /var/lib/dkms/megaraid-sas dpkg-query: no path found matching pattern /var/lib/dkms/megaraid-sas # dpkg -S /usr/share/dkms/modules_to_force_install/megaraid-sas.force megaraid-sas-dkms: /usr/share/dkms/modules_to_force_install/megaraid-sas.force
/usr/share/dkms/modules_to_force_install/megaraid-sas.force
megaraid-sas
sudoers
for user in $(awk -F':' '{print $1}' /etc/passwd) ; do sudo -U $user -l |sed -n -e '/^User /,/$$/p' |sed -e 1d |egrep -q -i '(root|all).*ALL' && echo "$user" ; done
Est-ce que cela fonctionne avec les groupes ? Les netgroups ? etc….
Ne liste pas les utilisateurs ayant des droits sur sh, bash, perl, python etc…
Config
Flux réseaux :
tcpdump tcp -p -qtn -nn -i eth0 and not host 192.168.1.11
Config Apache
apache2ctl -S
cat /usr/local/apache/conf/httpd.conf |sed -n -e '/\<VirtualHost/,/\<\/VirtualHost/p' |egrep -i -e "DocumentRoot|ServerName|ServerAlias|^$" |grep -v -e '^#' |tr -d '\n' | sed -e 's/DocumentRoot/\n/g' | sed -e 's/ServerName/|/g' | sed -e 's/ServerAlias/|ServerAlias/g' |sed -e 's/DocumentRoot/\nDocumentRoot/g' | grep -v -e "^$" | sed -e 's/[[:space:]]//g'
Comptes système
# uid0 cat /etc/passwd |awk -F':' '{print $3":"$1}' |grep -e '^0:' # list active account for compte in $(cat /etc/shadow |awk -F':' '{print $2":"$1}' |egrep -v -e "^\*|^\!" |awk -F ':' '{print $2}') do grep -e "^$compte:" /etc/passwd done > /tmp/ftp1.txt #cat ftp1.txt |awk -F':' '{print "| "$1" || || JJ/MM/AAAA || "$6" || "}' |perl -pe 's/\n/\n|-\n/' > ftp.txt
Réseaux. Serveur
netstat -tapen |grep LISTEN |grep -v '127\.0\.0\.1' |awk '{print "| " $4 " || " $9}'
Comptes système. Clefs SSH
for hom in $(cut -d':' -f 6 /etc/passwd) ; do ls $hom/$(grep AuthorizedKeysFile /etc/ssh/sshd_config |awk '{print $2}' |sed -e 's#^%h/##' ) 2>/dev/null ;done
perl -a -F':' -ne '$HOMEUSER=$F[5] ; $CHAINE="$HOMEUSER/.ssh/authorized_keys\n" ; $CHAINE=~s|//|/| ; print $CHAINE unless /false$/ or /nologin$/' /etc/passwd
Zones DNS
for zone in $(cat /etc/bind/named.conf |grep ^zone |egrep -v 'zone "." IN {|zone "localhost" IN {|zone "127.in-addr.arpa" IN {' |awk '{print $2}'| tr -d '"' |sort); do dig -t AXFR @127.0.0.1 $zone > /tmp/dns_${HOSTNAME}_${zone}.txt ; done
MySQL
mysql -u root -p < <(echo "select host, user from mysql.user;") > /tmp/mysql_user.txt mysql -u root -p < <(echo "show databases;") > /tmp/mysql_databases.txt
Logs
à un jour et une heure précise
journalctl --since "2019-10-16 06:00" --until "2019-10-16 10:00" touch -t 1910160600 fic1 touch -t 1910161000 fic2 find / -newer fic1 -not -newer fic2 atop -r 20191016 sar -A -f /var/log/sa/sa18 last
