Outils pour utilisateurs

Outils du site


blog

Notes Windows Manager

wmctrl

Lancer une application dans un workspace spécifique

apt-get install wmctrl
Off-Screen Window Restore

Source : https://github.com/mezga0153/offscreen-window-restore

A simple shell script that moves off-screen windows back.

This script was made to fix a bug in unity where if you have multiple monitors, when they wake up after being off some windows move off-screen.

sudo apt-get install wmctrl x11-xserver-utils

offscreen-window-restore.sh

#!/bin/bash
#
# This script moves back windows that have been moved off screen
#
# Author: Tine Mezgec tine.mezgec@gmail.com
#
 
width=`xrandr | grep current | awk {'print $8'}`
 
wmctrl -l -G | awk -v w=$width '{
	if ($8 != "unity-dash" && $8 != "Hud") {
		if ($3 >= w || $3 < 0) {
			system("wmctrl -i -r " $1 " -e 0," sqrt($3*$3) % w ",-1,-1,-1");
		}
	}
}'			
 
height=`xrandr | grep current | awk {'print $10'} | cut -d ',' -f1`
wmctrl -l -G | awk -v h=$height '{		
	if ($8 != "unity-dash" && $8 != "Hud") {
		if ($4 >= h || $4 < 0) {
			system("wmctrl -i -r " $1 " -e 0,-1," sqrt($4*$4) % h ",-1,-1");
		}
	}
}'
 
# restart unity to avoid problems with restored windows (unclickable areas)
unity
2025/03/24 15:06

Notes windows - Active Directory AD - Kerberos - WinRM

Voir :

Les ports suivants sont utilisés :

  • 5985/tcp (En clair)
  • 5986/tcp (TLS)

Vérif ports en écoute

netstat -tn | findstr "5985 5986"
netsh http show iplisten
 
Get-Service WinRM

Pb Connection refused This problem occurs because one or more of the following conditions are true:

  • The application is experiencing problems or is not running ?
  • The user does not have Remote PowerShell Enabled status.
  • Windows Remote Management (WinRM) is configured incorrectly on the server.

Test avec curl

source : https://gist.github.com/g3rhard/b8a829b4932be9c3e8854656945f32d9

check_winrm.sh

#!/bin/bash
if [ $# -eq 0 ]; then
    echo "please provide hostname or ip address"
    exit 1
fi
 
url=$1
output=$(curl -s -f -k -m 10 --header "Content-Type: application/soap+xml;charset=UTF-8" --header "WSMANIDENTIFY: unauthenticated" http://${url}:5985/wsman --data "<s:Envelope xmlns:s=http://www.w3.org/2003/05/soap-envelope xmlns:wsmid=http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd><s:Header/><s:Body><wsmid:Identify/></s:Body></s:Envelope>" || true);
if [[ $output == *"IdentifyResponse"* ]]
then
        echo "Online";
else
        echo "Offline";
fi

Test des domaines / contrôleurs de domaines

winrm_check_domains.sh

#! /bin/bash
 
set -uo pipefail
 
echo "DOMAIN;IS_AD;FLUX_TCP88"
 
#for DOMAIN in $(grep -v -e '^#' domains.txt)
while read -r DOMAIN
do
        if [[ $(dig +short SRV _kerberos._tcp.dc._msdcs."${DOMAIN}" | wc -l) -eq 0 ]]
        then
                IS_DOM_AD=N
                TCP=na
        else
                IS_DOM_AD=Y
                declare -i DOM_TCP_ERR=0
                for SRV in $(getent hosts "$DOMAIN" | awk '{ print $1 }')
                do
                        echo $SRV >> plop.txt
                        timeout 2 curl -s --connect-timeout 1 telnet://"${SRV}":88 </dev/null
                        if [[ "$?" -ne 124 ]]
                        then
                                DOM_TCP_ERR=$(( DOM_TCP_ERR + 1))
                        fi
                done
                if [[ "$DOM_TCP_ERR" -eq 0 ]]
                then
                        TCP=OK
                else
                        TCP=NOK
                fi
        fi
        echo "$DOMAIN;$IS_DOM_AD;${TCP}"
# done
done < domains.txt

Connexion WinRM depuis GNU/Linux

sudo apt-get install winrm
winrm-go -hostname 192.168.237.29 -username Administrator -password "P@ssw0rd" cmd
 
sudo apt-get install txwinrm
winrm --remote 192.168.237.29 --username "Administrator" --password "P@ssw0rd" -f "select * from Win32_NetworkAdapter"
winrm --remote 192.168.237.29 --username "Administrator" --password "P@ssw0rd"

Ansible

sudo apt-get install python-pip
sudo pip install pywinrm
ansible -u Administrator -i 192.168.237.29, -m win_ping --connection=winrm -e ansible_winrm_server_cert_validation=ignore -k all
ansible -u Administrator -i 192.168.237.29, -m setup --connection=winrm -e ansible_winrm_server_cert_validation=ignore -k all

La collection ansible.windows est nécessaire.

play-test-ping-win.yml

#! /usr/bin/env ansible-playbook
---

- name: ping win
  hosts: all
  #gather_facts: no

  vars:
    #ansible_ssh_user: 'Administrator'
    ansible_winrm_user: 'Administrator'
    #ansible_ssh_pass: 'P@ssw0rd'
    #ansible_winrm_transport: basic
    #ansible_ssh_port: 5985
    ansible_winrm_port: 5985
    ansible_connection: winrm
    ansible_winrm_server_cert_validation: ignore

  tasks:
    - name: ping
      win_ping:
./play-test-ping-win.yml -i 192.168.237.29, -k

WinRM avec Kerberos

  • dans les credentials utilisés : on met le realm kerberos en majuscules (Exemple : USER1@DOMAIN.LOCAL)
  • dans l'inventaire, on modifie la cible en lui attribuant les caractéristiques suivantes : ** comme nom d'hôte, utilisation du FQDN : l'hôte srv1 devient srv1.acme.local
# dig any +short _kerberos._tcp.dc._msdcs.acme.local
dig srv +short _kerberos._tcp.dc._msdcs.acme.local
nslookup
set type=all
_kerberos._tcp.acme.local
_kerberos._tcp.dc._msdcs.acme.local

Ou plus simplement

nslookup acme.local

Dans les variables de l'hôte

ansible_connection: winrm
ansible_winrm_host: srv1.acme.local
ansible_winrm_server_cert_validation: ignore
#ansible_winrm_port: 5986
#ansible_winrm_transport: kerberos 

Pour valider la connexion Kerberos, depuis un nœud d'exécution :

kinit USER1@ACME.LOCAL

Un mot de passe est demandé

Puis pour afficher le ticket associé.

klist

Messages d'erreurs Ansible

Name or service not known Le nom n'est pas correct ou n'est pas un FQDN
Max retries exceeded with url.*timed out Flux pas ouverts
Server not found in Kerberos database.*timed out Le serveur n'est pas connu de l'AD (workgroup?)
Cannot contact any KDC for realm (sauf si Max retries exceeded) Le domaine n'est pas une forêt AD
Specified credentials were rejected by the server Mauvais MDP ou compte verrouillé / expiré

Pb

Pb Erreur nom compte ou MDP
$ winrm-go -hostname 192.168.237.29 -username Administrator -password "P@ssw0rd" cmd
http error: 401 -

Erreur nom compte ou MDP

Pb credentials have been revoked while getting initial credentials
Kerberos auth failure for principal SRV_APP_PLOP@ACME.LOCAL with pexpect: Client's credentials have been revoked while getting initial credentials

Le compte est verrouillé

Voir : Windows - Active Directory - Vérifier si un compte AD est verrouillé

Err - Cannot contact any KDC for realm

Erreur Ansible win_ping WinRM

{
  "unreachable": true,
  "msg": "kerberos: authGSSClientStep() failed: (('Unspecified GSS failure.  Minor code may provide more information', 851968), (\"Cannot contact any KDC for realm 'ACME.LOCAL'\", -1765328228)), ssl: the specified credentials were rejected by the server",
  "changed": false
}
$ dig A +short acme.local
192.168.18.172
172.16.1.248
172.16.1.246
172.16.1.249
172.16.1.247

Un seul serveur répond au ping (pb de routage)

$ dig A +short acme.local | xargs -P5 -I '{}' bash -c 'ping -c 1 -W 2 {} >/dev/null 2>&1 && echo {}'
192.168.18.172

Les KDC sont injoignables, sauf un. \ Heureusement nous avons un KDC joignable par une autre route ou sur un autre VLAN.

Solution de contournement
$ echo "192.168.18.172 acme.local acme.local." | sudo tee -a /etc/hosts

$ dig SRV _ldap._tcp.dc._msdcs.acme.local +short | awk '{print $4}' | xargs -L1 -I'{}' bash -c 'echo 192.168.18.172 {}' | sudo tee -a /etc/hosts
192.168.18.172 dc1.acme.local.
192.168.18.172 dc2.acme.local.
192.168.18.172 dc3.acme.local.
192.168.18.172 dc4.acme.local.

Autres

Ansible requires PowerShell v3.0 or newer
2025/03/24 15:06

Notes Wifi WPA wpa_supplicant

Exemple simple

Voir https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=FR
 
network={
        ssid="Livebox-2930"
        psk="FFFFFFFFFFFFFFFFFFFFFFFFFF"
}
wpa_passphrase "Livebox-2930" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

PKI avec RADIUS

/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlp12s0
iface wlp12s0 inet dhcp
	wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
 
ctrl_interface_group=0
 
eapol_version=1
 
ap_scan=1
 
#fast_reauth=1
 
network={
	ssid="acme-wifi"
	scan_ssid=1
	key_mgmt=WPA-EAP
	pairwise=CCMP TKIP
	eap=TLS
	identity="acme-wifi@acme.com"
	ca_cert="/etc/cert/ca.pem"
	client_cert="/etc/cert/acme-wifi.pem"
	private_key="/etc/cert/acme-wifi.key"
	private_key_passwd="secret"
}

Debug

wpa_supplicant -Dnl80211 -iwlo1 -c /etc/wpa_supplicant/wpa_supplicant.conf 
 
wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -iwlp12s0 -d -f debug.log
2025/03/24 15:06

Notes Weboob

Travelboob

Exemple RER

traveloob departures CHATELET-LES-HALLES@transilien LA-DEFENSE-GRANDE-ARCHE@transilien

Exemple train SNCF

traveloob departures paris nancy 2015-04-02 09:00

Wetboobs

alias meteo="wetboobs forecasts 75001@meteofrance ; echo ; wetboobs forecasts 615702@yahoo"
meteo

Videoob

videoob search groland

Pb

Actuellement ne marche plus pour la Caisse d’Épargne

Pb

weboob-config update
$ boobank -d list

2015-12-08 09:27:17,600:DEBUG:modules:1.0:modules.py:161:load_module Loaded module "caissedepargne" from /home/jibe/.local/share/weboob/modules/1.0/caissedepargne
2015-12-08 09:27:17,601:DEBUG:backend:1.0:modules.py:98:create_instance Created backend "caissedepargne" for module "caissedepargne"
                                Account                     Balance    Coming 
---------------------------------------------------------+----------+----------
2015-12-08 09:27:17,612:DEBUG:bcall:1.0:bcall.py:81:backend_process <Backend 'caissedepargne'>: Calling function <bound method Boobank._do_complete of <weboob.applications.boobank.boobank.Boobank object at 0x7feaa247b850>>
2015-12-08 09:27:17,946:DEBUG:backend.caissedepargne.browser:1.0:browser.py:405:lowsslcheck Found 9a5af08c31a22a0dbc2724cec14ce9b1f8e297571c046c2210a16fa3a9f8fc2e as certificate hash
2015-12-08 09:27:17,946:DEBUG:bcall:1.0:bcall.py:87:backend_process <Backend 'caissedepargne'>: Called function <bound method Boobank._do_complete of <weboob.applications.boobank.boobank.Boobank object at 0x7feaa247b850>> raised an error: BrowserSSLError()
Error(caissedepargne): website is unavailable.
---------------------------------------------------------+----------+----------
                                                   Total       0.00       0.00

Solution :

import ssl
from hashlib import sha256
domain='www.caisse-epargne.fr'
sha256(ssl.get_server_certificate((domain,  443))).hexdigest()
'9a5af08c31a22a0dbc2724cec14ce9b1f8e297571c046c2210a16fa3a9f8fc2e'

/home/jean/.local/share/weboob/modules/1.0/caissedepargne/browser.py

Class CaisseEpargne(Browser):
    DOMAIN = 'www.caisse-epargne.fr'
    PROTOCOL = 'https'
    CERTHASH = ['dfff27d6db1fcdf1cea3ab8e3c1ca4f97c971262e95be49f3385b40c97fe640c', '9894ab2088630f341de821a09f1286c525f854f62ac186bd442368b4692c5969', '0e0fa585a8901c206c4ebbc7ee33e00e17809d7086f224e1b226c46165a4b5ac', '74FBF3380D32F4C01137CE37FDC19CBC3B560058EED653B5B27EA3260E42C2F6', '9a5af08c31a22a0dbc2724cec14ce9b1f8e297571c046c2210a16fa3a9f8fc2e']
Test
openssl s_client -connect www.caisse-epargne.fr:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ce.pem
openssl x509 -noout -in ce.pem -fingerprint -sha256
SHA256 Fingerprint=74:FB:F3:38:0D:32:F4:C0:11:37:CE:37:FD:C1:9C:BC:3B:56:00:58:EE:D6:53:B5:B2:7E:A3:26:0E:42:C2:F6
2025/03/24 15:06

Notes webmail Roundcube

docker run -ti --rm -p 127.0.0.1:8081:80 \
    -e ROUNDCUBEMAIL_DEFAULT_HOST=tls://imap.acme.fr \
    -e ROUNDCUBEMAIL_SMTP_SERVER=smtp.acme.fr \
    -e ROUNDCUBEMAIL_SMTP_PORT=25 \
    roundcube/roundcubemail
docker ps
docker update --restart unless-stopped 22eac34b881c

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

server {                            
    if ($host = mail.acme.fr) {                 
        return 301 https://$host$request_uri;              
    } # managed by Certbot                                                   
 
 
        listen 80;
        listen [::]:80;
        server_name mail.acme.fr;
        return 301 https://mail.acme.fr$request_uri;                     
 
 
} 
 
server {
        #listen 127.0.0.1:444 ssl;
        listen 443 ssl;
        listen [::]:443 ssl;
 
        server_name mail.acme.fr;
        ssl_certificate /etc/letsencrypt/live/mail.acme.fr/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mail.acme.fr/privkey.pem; # managed by Certbot
        ssl_session_timeout 5m;
        ssl_prefer_server_ciphers on;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_protocols TLSv1.2;
        ssl_ciphers ALL:!aNULL:!eNULL:!LOW:!EXP:!RC4:!3DES:+HIGH:+MEDIUM;
        #ssl_dhparam /etc/ssl/private/dh2048.pem;
        ssl_dhparam /etc/nginx/ssl/dhparam4.pem;
        add_header Strict-Transport-Security max-age=2678400;
 
        #auth_basic "Restricted";
        #auth_basic_user_file /etc/nginx/wiki.htpasswd;
        client_max_body_size 20m;
        proxy_read_timeout 3600;
 
 
        location / {
                 proxy_redirect off;
                 proxy_set_header Host $http_host;
                 proxy_set_header X-Forwarded-Server $host;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_pass http://127.0.0.1:8081;
        }
 
}

/etc/postfix/main.cf

# Ajouter le réseau de Docker dans mynetworks
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.16.0.0/12

Puis

postfix reload

Cela permet de pouvoir envoyer des mails à soi-même dans le cas où nous interdisons les mails de “mondomain.com” depuis internet.

Voir smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/etc/postfix/client_checks

Pb

Erreur upstream timed out (110: Connection timed out)
2023/03/23 16:24:33 [error] 20264#20264: *66053 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.78.117, server: mail.acme.fr, request: "GET /?_task=mail&_action=search&_interval=&_q=plop&_headers=text&_layout=widescreen&_filter=ALL&_scope=all&_remote=1&_unlock=loading1679585013210&_=1679584230928 HTTP/1.1", upstream: "http://127.0.0.1:8081/?_task=mail&_action=search&_interval=&_q=david&_headers=text&_layout=widescreen&_filter=ALL&_scope=all&_remote=1&_unlock=loading1679585013210&_=1679584230928", host: "mail.acme.fr", referrer: "https://mail.acme.fr/?_task=mail&_mbox=INBOX"
Solution
Pb taille des pièces jointes
Solution
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