Outils pour utilisateurs

Outils du site


blog

Monter un ficher VMDK

Voir aussi :

Voir :

  • supermin (utilisé en backend par virt-filesystems)

Install

apt-get install libguestfs-tools
#apt-get install linux-image-generic

Lister les partitions

# virt-filesystems -a plop_disk0.vmdk
/dev/sda1
/dev/vghome/lvhome
/dev/vgsyst/lvopt
/dev/vgsyst/lvroot
/dev/vgsyst/lvtmp
/dev/vgsyst/lvusr
/dev/vgsyst/lvvar

Montage de la partition

mkdir -p /mnt/vm/root
guestmount -a plop_disk0.vmdk -m /dev/vgsyst/lvroot --ro /mnt/vm/root

Autre

Debug de virt-filesystems

export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1

Err - error mount_options mount exited with status 32 mount /sysroot: can't read superblock

# guestmount -a PLOP_disk0.vmdk -m /dev/vghome/lvhome /mnt/vm/home/
libguestfs: error: mount_options: mount exited with status 32: mount: /sysroot: can't read superblock on /dev/mapper/vghome-lvhome.
       dmesg(1) may have more information after failed mount system call.
guestmount: ‘/dev/vghome/lvhome’ could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount:     /dev/sda1 (ext3)
guestmount:     /dev/vghome/lvhome (ext3)
Solution

Monter la partition en lecture seule

guestmount -a PLOP_disk0.vmdk -m /dev/vghome/lvhome --ro /mnt/vm/home/
2025/04/09 15:59 · Jean-Baptiste

Lancer des applications Android sous GNU Linux

Voir :

WayDroid

WayDroid fonctionne sous Wayland

waydroid first-launch
Err WayDroid session is stopped
Solution
waydroid container start
2025/04/07 14:15 · Jean-Baptiste

Note crack ASM Assembly reverse

Ghidra

Voir :

sudo snap install ghidra

Exe2asm avec objdump

objdump -d app.exe
2025/04/04 17:44 · Jean-Baptiste

Pb plugin Nagios centreon NSClient 403

Getting response 403 Your not allowed from NSClient++ running on Windows over the REST API but curl ok

Problème

https://community.icinga.com/t/getting-response-403-your-not-allowed-from-nsclient-running-on-windows-over-the-rest-api/4005

$ /usr/lib/centreon/plugins/centreon_nsclient_restapi.pl --plugin=apps::nsclient::restapi::plugin --mode=query --hostname='192.168.1.161' --port='8443' --proto='https' --legacy-password='centreon' --insecure --command=check_cpu --arg="warning=time = '5m' and load > 80" --arg="critical=time = '5m' and load > 90" --arg=show-all
UNKNOWN: 403 Forbidden

Alors que le curl fonctionne

curl -k -u centreon:centreon https://192.168.1.161:8443/api/v1/scripts/ext?all=true

Analyse - Création d'un MITM HTTPS avec socat

Décapsuler HTTPS en créant un MITM HTTP (HTTPS to HTTP)
socat TCP-LISTEN:8080,fork OPENSSL:10.12.50.161:8443,verify=0
Création des certificats pour encapsulation HTTPS (HTTP to HTTPS)

Voir :

FQDN=localhost
 
#openssl genrsa -out plop.key 2048
#openssl req -new -key plop.key -x509  -subj '/CN=localhost'  -out plop.cert
#cat plop.key plop.cert > plop.pem
 
# Ou 
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout plop.key -out plop.crt

Résultats

Test OK
curl -k -u centreon:centreon https://127.0.0.1:1443/api/v1/scripts/ext?all=true
[root@centreon-central ~]# PORT=1443 FQDN=localhost
[root@centreon-central ~]# socat -v -ls OPENSSL-LISTEN:${PORT},reuseaddr,cert=${FQDN}.pem,verify=0,crlf,fork TCP4:localhost:8080
> 2025/04/04 12:27:38.353691  length=146 from=0 to=145
GET /api/v1/scripts/ext?all=true HTTP/1.1
Host: 127.0.0.1:1443
Authorization: Basic Y2VudHJlb246Y2VudHJlb24=
User-Agent: curl/7.61.1
Accept: */*

< 2025/04/04 12:27:38.378346  length=1681 from=0 to=1680
HTTP/1.1 200\r\r
Content-Length: 1544\r\r
Set-cookie: token=yapnxrpMCARCr4zdGc81tBDKsMlaZTXC; path=/\r\r
Set-cookie: uid=centreon; path=/\r\r
\r\r
Test NOK
/usr/lib/centreon/plugins/centreon_nsclient_restapi.pl --plugin=apps::nsclient::restapi::plugin --mode=query --hostname='127.0.0.1' --port='1443' --proto='https' --legacy-password='centreon' --insecure --command=check_cpu --arg="warning=time = '5m' and load > 80" --arg="critical=time = '5m' and load > 90" --arg=show-all
UNKNOWN: 403 Forbidden
[root@centreon-central ~]# socat -v -ls OPENSSL-LISTEN:${PORT},reuseaddr,cert=${FQDN}.pem,verify=0,crlf,fork TCP4:localhost:8080
> 2025/04/04 12:34:59.797373  length=315 from=0 to=314
GET /query/check_cpu?warning%3Dtime%20%3D%20%275m%27%20and%20load%20%3E%2080&critical%3Dtime%20%3D%20%275m%27%20and%20load%20%3E%2090&show-all HTTP/1.1
TE: deflate,gzip;q=0.3
Keep-Alive: 300
Connection: Keep-Alive, TE
Host: 127.0.0.1:1443
User-Agent: centreon::plugins::backend::http::useragent
Password: centreon

< 2025/04/04 12:34:59.804956  length=59 from=0 to=58
HTTP/1.1 403\r\r
Content-Length: 20\r\r
\r\r
403 Your not allowed

Solution

Ajouter les arguments ci-dessous pour l'authentification “basic”

  • --basic
  • --credentials
  • --username=centreon
  • --password=centreon
/usr/lib/centreon/plugins/centreon_plugins --plugin=apps::nsclient::restapi::plugin --mode=query --hostname='192.168.1.161' --port='8443' --proto='https' --basic --credentials --username=centreon --password=centreon --insecure --command=check_cpu --arg="warning=time = '5m' and load > 80" --arg="critical=time = '5m' and load > 90" --arg=show-all

Autres socat

Pour test

socat -v -ls OPENSSL-LISTEN:${PORT},reuseaddr,cert=${FQDN}.pem,verify=0,crlf,fork SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: text/plain; echo; echo \"hello from $(hostname) at \$(date)\""
2025/04/04 14:18 · Jean-Baptiste

Prometheus windows_export i386 compilation go lang

Brouillon

Nous avons besoin de récupérer le maximum de métriques sur un OS XP 32bits.

Une solution est d'utiliser windows_export (ancienement wmi_exporter) de Prometheus, cependant nous n'avons pas de version 32 bits compilée fournie par le projet.

Source : https://github.com/prometheus-community/windows_exporter

Ca ne marche pas en compilant

Go 1.10 is the last release to support Windows Vista or below

Voir :

La dernière version compatible Win32 :

Usage

C:\Program Files\windows_exporter\

Command line Usage

--config.file=CONFIG.FILE
--collectors.enabled="cpu,cs,memory,logical_disk,physical_disk,net,os,service,system"
--collector.tcp.enabled="metrics,connections_state"
--collector.performancecounter.objects=""
--collector.netframework.enabled="clrexceptions,clrinterop,clrjit,clrloading,clrlocksandthreads,clrmemory,clrremoting,clrsecurity"
--collector.process.include=".+"
--collector.scheduled_task.include=".+
--collector.service.include=".+"
--collector.net.enabled="metrics,nic_addresses"
--collector.net.nic-include=".+"
--collector.time.enabled="system_time,ntp"
Usage old version wmi_exporter-0.9.0
msiexec /i wmi_exporter-0.9.0-386.msi ENABLED_COLLECTORS=cpu,cs,logical_disk,logon,memory,net,os,process,service,system,tcp,vmware

On test : http://localhost:9182

Other

https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md

time=2025-04-03T11:27:26.836Z level=WARN source=cs.go:75 msg="The cs collector is deprecated and will be removed in a future release. Logical processors has been moved to cpu_info collector. Physical memory has been moved to memory collector. Hostname has been moved to os collector."
time=2025-04-03T11:27:26.836Z level=WARN source=os.go:108 msg="The os collect holds a number of deprecated metrics and will be removed mid 2025. See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information." collector=os

Old

Compile sur Windows

set http_proxy=http://192.168.1.221:3128
set https_proxy=http://192.168.1.221:3128

go install github.com/prometheus/promu@latest
set GOARCH=386
go install github.com/prometheus-community/windows_exporter@latest
cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter
promu build -v
Compiled on GNU+Linux WSL
sudo apt-get install gcc-multilib
sudo apt-get install gcc-mingw-w64

go install github.com/prometheus/promu@latest

export http_proxy=http://192.168.1.221:3128
export https_proxy=http://192.168.1.221:3128

GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-gcc
export GOOS GOARCH CGO_ENABLED CXX CC
go install github.com/prometheus-community/windows_exporter@latest
cd ~/go/pkg/mod/github.com/prometheus-community/windows_exporter
promu build -v
go: downloading github.com/containerd/typeurl/v2 v2.2.3
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb
go: downloading github.com/gogo/protobuf v1.3.2
github.com/prometheus-community/windows_exporter/cmd/windows_exporter: go build github.com/prometheus-community/windows_exporter/cmd/windows_exporter: copying /tmp/go-build2685928784/b001/exe/a.out.exe: open windows_exporter.exe: permission denied
!! command failed: build -o windows_exporter.exe -ldflags -X github.com/prometheus/common/version.Version= -X github.com/prometheus/common/version.Revision=non-git -X github.com/prometheus/common/version.Branch=non-git -X github.com/prometheus/common/version.BuildUser=management@vlbvmdevadm01 -X github.com/prometheus/common/version.BuildDate=20250403-08:47:02  -extldflags '-static' -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter: exit status 1

Solution : remplacer build -o windows_exporter.exe par build -o /tmp/windows_exporter.exe

go build -o /tmp/windows_exporter.exe -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter
Err windows_exporter.exe is not a valid Win32 application

Voir https://learn.microsoft.com/en-us/windows/win32/debug/pe-format

$ file windows_exporter*
windows_exporter.exe:                    PE32 executable (console) Intel 80386, for MS Windows, 13 sections
windows_exporter_CompiledOnOuindoze.exe: PE32 executable (console) Intel 80386, for MS Windows, 13 section
2025/04/03 14:09 · Jean-Baptiste
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki