Outils pour utilisateurs

Outils du site


blog

Script automatisation entrées clavier automated input macro

Voir : http://www.thegeekstuff.com/2010/10/expect-examples/

#! /usr/bin/expect
 
set timeout 10
 
spawn cadaver -p 192.168.56.1:3128 https://www.acme.fr/
 
expect "Do you wish to accept the certificate? (y/n)"
send "y\n"
 
interact

Ou dans un script bash

Exemple

#!/bin/bash
# Get password from PAM
read password
# A few files we use to save and validate the results
SHADFILE=/root/newshadow
LOGFILE=/root/convpass.log
# Let's see if the user has been converted already
# The username is provided as an environment variable.
CHECK=$(grep ^$PAM_USER $SHADFILE)
if [ "x$CHECK" == "x" ]; then
    # The user has not been migrated already
    #
    # First, we need to validate that the provided password 
    # is the correct one.  
    # Since this script is run for ALL password-attempts, and
    # before the user is actually logged in, any brute force attack, 
    # or wrong password entered by the user will also be sent to the   
    # script.  So we can't just blindly accept whatever password
    # is provided here.  We try do a "su" to the provided user
    # with the provided password, using "expect", if the su succeds
    # the password is correct.  But since su will succeed without a
    # password for root, we need to sudo the su command as an
    # unprivileged user - in this case the user "nobody"
    #
    # since we use expect inside a bash-script, 
    # we have to escape tcl-$.
    expect << EOF
    spawn sudo -u nobody su "$PAM_USER" -c "exit" 
    expect "Password:"
    send "$password\r"
    set wait_result  [wait]
    # check if it is an OS error or a return code from our command
    #   index 2 should be -1 for OS erro, 0 for command return code
    if {[lindex \$wait_result 2] == 0} {
        exit [lindex \$wait_result 3]
    } 
    else {
        exit 1 
    }
EOF
    # So if the expect-script returns 0, the su succeeded
    # and we can continue 
    if [ $? == 0 ]; then
        echo "Password for user $PAM_USER is correct" >> $LOGFILE
        # Generate a new sha512 hash of the provided password:
        S512=$(echo "$password" | openssl passwd -6 -stdin)
        # Here, I simply generate a new shadow-file to replace the
        # old one later.
        # But if you need to push this to LDAP, you can of course
        # easily generate an ldif or whatever.
        echo "$PAM_USER:$S512:18000:0:99999:7:::" >> $SHADFILE
        exit 0
    fi
    echo "Password for user $PAM_USER is incorrect" >> $LOGFILE
fi
# We return a non 0 exit status just in case, 
# but see the note for pam_exec below
exit 1

Source : https://olathoresen.medium.com/linux-users-password-migration-b6bc4fab267d

2025/03/24 15:06

Screenshot - capture d'écran

Outils graphiques :

  • screengrab
  • xfce4-screenshooter
  • lximage-qt -s
  • scrot

Ça dépend si vous utiliser X11 ou Wayland !

2025/03/24 15:06

Notes cluster shell parallèle

  • clustershell (clush)
  • clusterssh (cssh)
  • mussh

clush

apt-get install clustershell
# ou 
pip install --user ClusterShell

/etc/clustershell/groups

all: host1 host2

-a pour “all”\ -B pour affichage groupé de STDOUT et STDERR si retour identique

clush -a -B
clush -w lame[1-4] -B
clush -w lame[1-6] --diff dmidecode -s bios-version
--- lame[1-4] (4)
+++ lame[5-6] (2)
@@ -1 +1 @@
-I36
+I15
Clush copy

Exemple SosRepport

Exemple

Génération du sosreport sur les cibles

clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst 
sosreport -q --case-id 000000 --since 20230813000000 --batch

Récupération des sosreports

mkdir sosreports
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst --rcopy '/var/tmp/sosreport-*.tar.xz' --dest sosreports/
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst --rcopy '/var/tmp/sosreport-*.tar.xz.sha256' --dest sosreports/

Renommage

cd sosreports/
# rename -nv '*' ` *
rename '*' ` *
rename '-' ` *

Nettoyage

clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l root --hostfile targets.lst
rm -f /var/tmp/sosrepor*
List
clush -B --hostfile=hosts.lst
clush -B -O ssh_options='-oStrictHostKeyChecking=no -oPort=2222' -l admin --hostfile hosts.lst
Groupes
mkdir ~/.config/clustershell/
cp /etc/clustershell/groups.conf ~/.config/clustershell/

~/.config/clustershell/groups.d/plop.yaml

plop:
    www: 'www[1-4]'
    db: 'db-alpha,db-beta'
clush -B -g plop:www
clush -B -g plop:*

mussh

mussh -H list.txt -b -c 'uptime'
mussh -H list.txt -b -C script.sh
mussh -m 7 -H ~/dev/list.txt -b -c 'apt-get -s dist-upgrade | grep "^[[:digit:]]\+ upgraded"'

ClusterSSH cssh

sudo apt-get install clusterssh
cssh c2-bl1 c2-bl2 c2-bl3 c2-bl4 c2-bl5 c2-bl6

sshpass

read -s SSHPASS ; export SSHPASS
 
for ip in $(cat ip_all.lst) ; do sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 $ip /bin/true && echo $ip >> ip_ok.lst || echo $ip >> ip_nok.lst ;done
 
for ip in $(cat ip_ok.lst) ; do sshpass -e ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 $ip grep 192.168.1.253 /etc/resolv.conf && echo $ip >> dns_ok.lst || echo $ip >> dns_nok.lst ;done
2025/03/24 15:06

Faire des schémas d’architecture réseau sous GNU/Linux

Diagramme en code :

Voir Inkscape, Dia…

2025/03/24 15:06

Installer les pilotes scanner Canon LiDE30 sur MacOSX

Apparemment LiDE30 est comme N1240U

I Installation des pilotes SANE / TWAIN

Aller sur http://www.ellert.se/twain-sane/

Télécharger les 5 paquages “Binary” (les SDK sont destinés au développeurs)

Pour MacOSX Yosemite

Sha256sum (pour information)

4da70865b827f4972db8cc92bc9389139b26f2e949e8d0719548051c2e845c19  gettext.pkg
079dfcbf1e3026ec447a5bb390a6f08272eb5c0af8641692d6feb2a8a7cc5a67  libusb.pkg
d9a079d3ce86b42647eaa9573ba24a3970d9ed3561b8f90d58401f5c21667fdd  sane-backends.pkg
0c970e9ca1be19f20365e155aa9f59edd60a33d295b5cd2c39b4cff6f33cb4d3  SANE-Preference-Pane.pkg
5623ef7fac5c033f5f9eb934b1f11a47db27d7285d77119eb048d8bf9cfa0485  TWAIN-SANE-Interface.pkg

2 Installation TWAIN Bridge

Aller sur http://janegil.net/2014/01/twain-scanners-in-os-x-maverick/

Télécharger TwainBridge Maverick Fix.pkg http://files.janegil.net/TwainBridge%20Maverick%20Fix.pkg

Sha256sum (pour information)

330c12d336315f9f416d31710264000a88392e210cb29a5332f5d0df37a28a35  TwainBridge Maverick Fix.pkg

3 Utilisation

On peut utiliser Transfert d’images (Image Capture app) inclus dans MacOSX.

Certaines résolutions sont mal acceptés créant des images entrelacées


Obsolète et pas Libre. Marche plus sur MacOSX Yosemite

Marche sans rien faire sur Debian/Ubuntu mais sous MacOSX voici la manip.

  1. Installer le canoScan Toolbox
  2. Installer ScanGear CS dans Applications/CanoScan Toolbox 4.1/Plug-Ins

Fichier lide20lide30n670un676un1240uosx7011aen.dmg
Vérifier la présence de du fichier suivant à l’emplacement indiqué :
Applications/CanoScan Toolbox 4.1/Plug-Ins/ScanGear CS 7.0X

  1. Lancer CanoScan Toolbox X présent dans Applications.
  2. Cliquez sur Scan-1
  3. Dans Link scanned image to cliquez sur Set…
  4. Indiquez le fichier et l’emplacement suivant :

Applications/CanoScan Toolbox 4.1/Plug-Ins/ScanGear CS 7.0X

  1. Cliquer sur Scan et ca marche
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