1106 shaares
173 results
tagged
linux
#!/bin/bash
WAN=wlp3s0
LAN=vmbr0
brctl addbr vmbr0
ip link set vmbr0 up
ip address add 192.168.53.1/24 dev vmbr0
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
iptables -A FORWARD -i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
dnsmasq \
--strict-order \
--except-interface=lo \
--interface=vmbr0 \
--listen-address=192.168.53.1 \
--bind-interfaces \
--dhcp-range=192.168.53.10,192.168.53.20 \
--conf-file="" \
--pid-file=/var/run/qemu-dnsmasq.pid \
--dhcp-leasefile=/var/run/qemu-dnsmasq.leases \
--dhcp-no-override \
WAN=wlp3s0
LAN=vmbr0
brctl addbr vmbr0
ip link set vmbr0 up
ip address add 192.168.53.1/24 dev vmbr0
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
iptables -A FORWARD -i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
dnsmasq \
--strict-order \
--except-interface=lo \
--interface=vmbr0 \
--listen-address=192.168.53.1 \
--bind-interfaces \
--dhcp-range=192.168.53.10,192.168.53.20 \
--conf-file="" \
--pid-file=/var/run/qemu-dnsmasq.pid \
--dhcp-leasefile=/var/run/qemu-dnsmasq.leases \
--dhcp-no-override \
Juste pour le script linux qui marche très bien pour mon certificat PFSense
via https://www.reddit.com/r/debian/comments/6ostr7/samba_domain_controller_debian_stretch/
Testé, approuvé!
+ https://smeretech.com/en/samba4-remote-server-administration-tools/
EDIT:
Update /etc/samba/smb.conf
[global]
...
...
# Add this line under [global]
# IP Address is the same as your domain contoller
dns forwarder = 10.0.0.1 # and not 10.0.0.2
Testé, approuvé!
+ https://smeretech.com/en/samba4-remote-server-administration-tools/
EDIT:
Update /etc/samba/smb.conf
[global]
...
...
# Add this line under [global]
# IP Address is the same as your domain contoller
dns forwarder = 10.0.0.1 # and not 10.0.0.2
J'ajoute "en omettant le répertoire /media/truc"
find / -path /media/truc -prune -o -xdev -type f -print0 | xargs -0 grep -H "foo"
find / -path /media/truc -prune -o -xdev -type f -print0 | xargs -0 grep -H "foo"
<<Perl
To convert a Windows text file to a Unix text file using Perl, enter:
perl -p -e 's/\r$//' < winfile.txt > unixfile.txt
To convert from a Unix text file to a Windows text file, enter:
perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt
You must use single quotation marks in either command line. This prevents your shell from trying to evaluate anything inside.>>
#ThisSaveMyLifeToday
To convert a Windows text file to a Unix text file using Perl, enter:
perl -p -e 's/\r$//' < winfile.txt > unixfile.txt
To convert from a Unix text file to a Windows text file, enter:
perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt
You must use single quotation marks in either command line. This prevents your shell from trying to evaluate anything inside.>>
#ThisSaveMyLifeToday
A tester
J'en connaissais pas tant!
Création d'un RAT sous linux
install qemu-kvm
sudo modprobe nbd
qemu-nbd -c /dev/nbd0 [vdi-file]
sudo modprobe nbd
qemu-nbd -c /dev/nbd0 [vdi-file]
TIL
#ls -l /proc/*/fd/ | grep -C 2 deleted
Parce que pour du send only, postfix est overkill
SSMTP, c'est juste deux fichiers de conf:
# /etc/ssmtp/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=adresse_mail
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=mail.gandi.net:587
# Where will the mail seem to come from?
#rewriteDomain=y
# The full hostname
hostname=locahost.localdomain
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=adresse_mail
AuthPass=password
# Email 'From header's can override the default domain?
FromLineOverride=yes
#/etc/ssmtp/revaliases
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:adresse_mail:mail.gandi.net:587
SSMTP, c'est juste deux fichiers de conf:
# /etc/ssmtp/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=adresse_mail
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=mail.gandi.net:587
# Where will the mail seem to come from?
#rewriteDomain=y
# The full hostname
hostname=locahost.localdomain
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=adresse_mail
AuthPass=password
# Email 'From header's can override the default domain?
FromLineOverride=yes
#/etc/ssmtp/revaliases
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:adresse_mail:mail.gandi.net:587
Untar and launch without root access
reptyr permet de rattacher un process a GNU screen.
$ reptyr `pidof process_name`
$ reptyr `pidof process_name`
Ça simplifie énormément mon script qui utilisait transmission daemon.
A tester
A tester
En cours de test sur le serveur
1.45 TB en 1 jours, 9h, 18m et 24.75s :-)
compression lz4
EDIT: Pensez à installer le module llfuse (python-llfuse) pour monter les backup comme des mountpoint fuse.
sudo borg mount /path/to/backup::backup_name /tmp/mountpoint
ou
sudo borg mount /path/to/backup /tmp/mountpoint
<3 Borg Backup
1.45 TB en 1 jours, 9h, 18m et 24.75s :-)
compression lz4
EDIT: Pensez à installer le module llfuse (python-llfuse) pour monter les backup comme des mountpoint fuse.
sudo borg mount /path/to/backup::backup_name /tmp/mountpoint
ou
sudo borg mount /path/to/backup /tmp/mountpoint
<3 Borg Backup
<<Mise à jour Kernel sans reboot
Kexec vous permet de bypasser la phase d’amorçage du système, il charge directement le nouveau Kernel en mémoire et l’exécute.
Pour installer kexec lancez la commande suivante :
sudo apt-get install kexec-tools
Maintenant pour lancer la mise à jour Kernel sans reboot, exécutons la commande suivante
sudo systemctl kexec
Votre session SSH va couper, re-lancez la et vérfiez la version du Kernel via la commande
uname -r
Pour effectuer un reboot « normal » il faudra désormais utiliser la commande
coldreboot
>>
A tester...
Kexec vous permet de bypasser la phase d’amorçage du système, il charge directement le nouveau Kernel en mémoire et l’exécute.
Pour installer kexec lancez la commande suivante :
sudo apt-get install kexec-tools
Maintenant pour lancer la mise à jour Kernel sans reboot, exécutons la commande suivante
sudo systemctl kexec
Votre session SSH va couper, re-lancez la et vérfiez la version du Kernel via la commande
uname -r
Pour effectuer un reboot « normal » il faudra désormais utiliser la commande
coldreboot
>>
A tester...
Un interface GTK pour monitorer ses services systemd.
Parce que je le retrouve pas dans mes liens... et que j'ai encore cherché comme un fou.
echo "0 0 0" >/sys/class/scsi_host/host<n>/scan
echo "0 0 0" >/sys/class/scsi_host/host<n>/scan
The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
Code:
fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bfaa
Device Boot Start End Blocks Id System
Stick.img1 * 128 8015999 4007936 b W95 FAT32
So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:
mount -o loop,offset=65536 Stick.img /mnt/tmp
If you do a
Code:
fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bfaa
Device Boot Start End Blocks Id System
Stick.img1 * 128 8015999 4007936 b W95 FAT32
So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:
mount -o loop,offset=65536 Stick.img /mnt/tmp
Des VM virtualbox / vagrant de MS fournis par MS. Peux servir un jour...
As root obv
for i in {0..5}
do
echo "0 0 0" >/sys/class/scsi_host/host$i/scan
done
for i in {0..5}
do
echo "0 0 0" >/sys/class/scsi_host/host$i/scan
done
Un steetfighter-like opensource sous Linux
Tout simplement...
gpg -ca photo.jpg
gpg -d photo.jpg.asc > photo.jpg
gpg -ca photo.jpg
gpg -d photo.jpg.asc > photo.jpg
Si on cherche les police ttf installé, elles sont dans /usr/share/fonts/TTF
Pas mal, ça a juste mis mon serveur à genou pendant 40 minutes...
Log à étudier.
Log à étudier.
Je l'avais bookmarké en avril mais le lien était mort depuis.
"Fim manage the integrity of a complete file tree.
Fim is compiled using Java 8 and require Java 8 to run. You can download Java 8 from here.
You need at least Java 8 Standard Edition JRE. You can also use the OpenJDK 8." :-(
Fim is compiled using Java 8 and require Java 8 to run. You can download Java 8 from here.
You need at least Java 8 Standard Edition JRE. You can also use the OpenJDK 8." :-(
"The LaZagne project is an open source application used to retrieve lots of passwords stored on a local computer. Each software stores its passwords using different techniques (plaintext, APIs, custom algorithms, databases, etc.). This tool has been developed for the purpose of finding these passwords for the most commonly-used software. At this moment, it supports 22 Programs on Microsoft Windows and 12 on a Linux/Unix-Like OS."
Pour une raison qui me dépasse encore, après avoir fait boooter ma machine sur W7 via un autre HDD, ma partition EFI s'est rétrouvé non fonctionnelle (plus de menu, plus vmlinuz-linux ni initramfs-linux.img.
Solution : tous reconstruire...
Booter sur un live EN EFI!!!! pour monter ses partitions puis chrooter dessus.
#bootctl --path=/boot install
#vi /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=/dev/sdaX rw
#vi /boot/loader/loader.conf
default arch
# pacman -S linux
# ln -s /proc/self/fd /dev/ ----> Because "/dev must be mounted" when it already is
# mkinitcpio -p linux
Reboot and enjoy
FUCK YOU EFI!!!!!
Solution : tous reconstruire...
Booter sur un live EN EFI!!!! pour monter ses partitions puis chrooter dessus.
#bootctl --path=/boot install
#vi /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=/dev/sdaX rw
#vi /boot/loader/loader.conf
default arch
# pacman -S linux
# ln -s /proc/self/fd /dev/ ----> Because "/dev must be mounted" when it already is
# mkinitcpio -p linux
Reboot and enjoy
FUCK YOU EFI!!!!!
Résume très bien les bases.
Exemple actuel pour moi.
J'ai 2 machines : katara et archcraft
katara a acces à internet via WiFi et au réseau local via filaire. Je demande à katara de partager sa connection internet et créer ainsi un subnet 10.42.0.0/24.
archcraft à une ip static sur 192.168.0.0/24 et souhaite la garder pour communiquer avec les autres pc de ce subnet ainsi que l'imprimante. Mais ce dernier veux acceder à internet via katara.
Solution:
# ip addr add 10.42.0.2/24 broadcast 10.42.0.255 dev eth0
# ip route del default
# ip route add default via 10.42.0.1
Nous avons attribué une adresse ip statique à archcraft sur le subnet 10.42.0.0/24, supprimé sont ancienne "route" pour lui en imposer une autre.
Il me reste plus qu'à trouver comment rendre cela persistant sous debian. Editer le fichier /etc/network/interfaces ne semble pas fonctionner.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.0.251
netmask 255.255.255.0
gateway 192.168.0.1
#########{Static Route}###########
up ip route add default via 10.42.0.1 dev eth0
EDIT: Ça fonctionne avec systemd
sudo vim /etc/systemd/system/network\@.service
[Unit]
Description=Wired Static IP Connectivity
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-enp3s0.device
After=sys-subsystem-net-devices-enp3s0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ip link set dev enp3s0 up
ExecStart=/usr/bin/ip addr add 10.42.0.2/24 broadcast 10.42.0.255 dev enp3s0
ExecStart=/usr/bin/ip addr add 192.168.0.2/24 broadcast 192.168.0.255 dev enp3s0
ExecStart=/usr/bin/ip route add default via 10.42.0.1
ExecStop=/usr/bin/ip addr flush dev enp3s0
ExecStop=/usr/bin/ip link set dev enp3s0 down
[Install]
WantedBy=multi-user.target
:wq
sudo systemctl enable network@enp3s0
sudo systemctl start network@enp3s0
Si le start foire, penser à "disable" et stopper les autre netctl & co puis redemarrer.
Exemple actuel pour moi.
J'ai 2 machines : katara et archcraft
katara a acces à internet via WiFi et au réseau local via filaire. Je demande à katara de partager sa connection internet et créer ainsi un subnet 10.42.0.0/24.
archcraft à une ip static sur 192.168.0.0/24 et souhaite la garder pour communiquer avec les autres pc de ce subnet ainsi que l'imprimante. Mais ce dernier veux acceder à internet via katara.
Solution:
# ip addr add 10.42.0.2/24 broadcast 10.42.0.255 dev eth0
# ip route del default
# ip route add default via 10.42.0.1
Nous avons attribué une adresse ip statique à archcraft sur le subnet 10.42.0.0/24, supprimé sont ancienne "route" pour lui en imposer une autre.
Il me reste plus qu'à trouver comment rendre cela persistant sous debian. Editer le fichier /etc/network/interfaces ne semble pas fonctionner.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet static
address 192.168.0.251
netmask 255.255.255.0
gateway 192.168.0.1
#########{Static Route}###########
up ip route add default via 10.42.0.1 dev eth0
EDIT: Ça fonctionne avec systemd
sudo vim /etc/systemd/system/network\@.service
[Unit]
Description=Wired Static IP Connectivity
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-enp3s0.device
After=sys-subsystem-net-devices-enp3s0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ip link set dev enp3s0 up
ExecStart=/usr/bin/ip addr add 10.42.0.2/24 broadcast 10.42.0.255 dev enp3s0
ExecStart=/usr/bin/ip addr add 192.168.0.2/24 broadcast 192.168.0.255 dev enp3s0
ExecStart=/usr/bin/ip route add default via 10.42.0.1
ExecStop=/usr/bin/ip addr flush dev enp3s0
ExecStop=/usr/bin/ip link set dev enp3s0 down
[Install]
WantedBy=multi-user.target
:wq
sudo systemctl enable network@enp3s0
sudo systemctl start network@enp3s0
Si le start foire, penser à "disable" et stopper les autre netctl & co puis redemarrer.
discover new kiss tool
Bon, vu que je scripte pas mal en python en ce moment, j'ai décidé de me mettre à vim.
J'ai installé wasavi sur firefox pour éditer ce texte avec vi :-)
Je vais noter ici ce que je découvre au fur et à mesure d'utile.
Installer vim-gtk pour partager le clipboard du système. Coller avec Ctrl+Maj+V
Ctrl-X Ctrl-F pour l'autocompletion de path
hjkl : déplacement gauche bas haut droite
$ : déplacement fin de ligne
o : ajoute une nouvelle ligne sous le curseur
ZZ =» :wq
u : undo action
Ctrl-r : redo action
d : cut
y : copy
p : paste after cursor
P : paste before cursor
:%s /foo/bar/g : remplace foo par bar sur toute les lignes du fichiers
/string : cherche le mot "string" puis n pour next et N pour previous
* : cherche une autre occurence pour le mot ce trouvant sous le curseur
/etc/vimrc
syntax on "coloration syntaxique
set whichwrap=b,s,<,>,[,] "navigation début et fin de ligne
set background=dark "ou light en fonction de la couleur derrière le terminal
set mouse=a "utilisation de la souris
J'ai installé wasavi sur firefox pour éditer ce texte avec vi :-)
Je vais noter ici ce que je découvre au fur et à mesure d'utile.
Installer vim-gtk pour partager le clipboard du système. Coller avec Ctrl+Maj+V
Ctrl-X Ctrl-F pour l'autocompletion de path
hjkl : déplacement gauche bas haut droite
$ : déplacement fin de ligne
o : ajoute une nouvelle ligne sous le curseur
ZZ =» :wq
u : undo action
Ctrl-r : redo action
d : cut
y : copy
p : paste after cursor
P : paste before cursor
:%s /foo/bar/g : remplace foo par bar sur toute les lignes du fichiers
/string : cherche le mot "string" puis n pour next et N pour previous
* : cherche une autre occurence pour le mot ce trouvant sous le curseur
/etc/vimrc
syntax on "coloration syntaxique
set whichwrap=b,s,<,>,[,] "navigation début et fin de ligne
set background=dark "ou light en fonction de la couleur derrière le terminal
set mouse=a "utilisation de la souris
TIL
Interressant, je me souviens pas avoir entendu parler de ce fichier.
Alternative open source à Siri
https://github.com/jhauswald/sirius/tree/master/sirius-suite
https://github.com/jhauswald/sirius/tree/master/sirius-suite
Génial ce petit script, j'ai commencé à en suivre les recommandation mais je terminerais plus tard.