Outils pour utilisateurs

Outils du site


issue144:tutoriel3

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
issue144:tutoriel3 [2019/05/05 17:41] d52frissue144:tutoriel3 [2019/05/08 14:38] (Version actuelle) andre_domenech
Ligne 9: Ligne 9:
  
 Any system administrator or hacker – we don't judge which way you lean – should have a solid understanding of netcat. Skilled system administrators can do almost all of their work using the built-in tools without having to install additional software, and, indeed, netcat is baked into most distributions.** Any system administrator or hacker – we don't judge which way you lean – should have a solid understanding of netcat. Skilled system administrators can do almost all of their work using the built-in tools without having to install additional software, and, indeed, netcat is baked into most distributions.**
 +
 +Site Web: http://netcat.sourceforge.net/
 +Version: 0.7.1 (2004)
 +
 +Netcat est un utilitaire qui utilise TCP/IP pour lire et écrire des données via des connexions réseau. Il est utilisé principalement pour tester les connexions TCP et UDP, mais il fait beaucoup plus. Certaines personnes l'appellent le couteau suisse des outils de réseau. Netcat est un outil d'administration qui fait tout à propos des connexions de réseau, la supervision, les tests et l'envoi de données.
 +
 +Si, pour une raison quelconque, vous ne l'avez pas, installez-le avec :
 +
 +sudo apt install netcat
 +
 +Tout administrateur système ou pirate - nous ne jugeons pas vers quel bord vous penchez - devrait avoir une bonne compréhension de netcat. Les administrateurs système expérimentés peuvent faire presque tout leur travail en utilisant les outils intégrés sans avoir à installer des logiciels supplémentaires, et, en fait, netcat fait partie de la plupart des distributions.
  
 **Looking at the man page for netcat is bleh. Netcat is better understood with examples. Don't go rushing off installing bro pages, netcat is not listed in it yet. The basic syntax for netcat is: **Looking at the man page for netcat is bleh. Netcat is better understood with examples. Don't go rushing off installing bro pages, netcat is not listed in it yet. The basic syntax for netcat is:
Ligne 17: Ligne 28:
  
 As stated before, netcat is a utility that does things via TCP/IP; should you require UDP, you have to specify the -u switch. If you are using ports 1-1024, you will require root privileges, anything else is fine as a normal user. You can add netcat to your scripts and it will work just fine. You can also use netcat to scan a range of ports (this is called port scanning), to test if your firewall setup was successful.** As stated before, netcat is a utility that does things via TCP/IP; should you require UDP, you have to specify the -u switch. If you are using ports 1-1024, you will require root privileges, anything else is fine as a normal user. You can add netcat to your scripts and it will work just fine. You can also use netcat to scan a range of ports (this is called port scanning), to test if your firewall setup was successful.**
 +
 +Un coup d'œil à la page man de netcat est... bof. Netcat se comprend beaucoup mieux avec des exemples. Ne vous jetez pas dans l'installation de pages « bro », Netcat n'est pas encore référencé dedans. La syntaxe de base de Netcat est :
 +
 +netcat [options] host port
 +
 +Vous pouvez l'utiliser en tapant netcat en entier, ou juste le raccourcir en nc.
 +
 +Comme dit plus haut, netcat est un utilitaire qui agit via TCP/IP ; si vous avez besoin de UDP, vous devez spécifier le commutateur -u. Si vous utilisez les ports 1-1024, vous devrez avoir les privilèges de root ; tout le reste se passe bien pour le simple utilisateur. Vous pouvez ajouter netcat à vos scripts et il fonctionnera bien. Vous pouvez aussi utiliser netcat pour scanner une plage de ports (c'est appelé le scanning des ports), pour tester si le paramétrage de votre pare-feu marche bien.
  
 **IMPORTANT - When scanning addresses on your internet connection, make sure that your ISP allows this, so that you do not get banned from the network.  **IMPORTANT - When scanning addresses on your internet connection, make sure that your ISP allows this, so that you do not get banned from the network. 
Ligne 27: Ligne 46:
 z - don't send data to the ports z - don't send data to the ports
 w - is just so that the listening times out and does not wait forever.** w - is just so that the listening times out and does not wait forever.**
 +
 +IMPORTANT - Lors d'un scan d'adresses sur votre connexion internet, assurez-vous que votre FAI l'autorise, afin que vous ne soyez pas banni du réseau.
 +
 +Il est aussi très pratique pour vérifier les ports de votre routeur, en tenant compte de ceci :
 +
 +Ici (présenté ci-dessous) j'ai scanné mon routeur, entre les ports 50 et 60 et j'ai découvert que le port 53 était ouvert. La raison que je le savais était que DNS utilise le port 53 (pour en savoir plus, lisez ceci, uniquement en anglais : https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers). Si ça ne l'était pas, et si je n'avais aucune connexion à Internet, cela aurait été la raison. J'ai utilisé les commutateurs -vnz (regroupés ; j'aurais pu aussi utiliser -u -n -z) qui signifient :
 +v - sortie verbeuse ;
 +n - pas de requête DNS ;
 +z - ne pas envoyer de données vers les ports ;
 +w - il est là juste pour qu'il y ait une limite de temps et éviter une attente éternelle.
 +
  
 **As you can see, crafting custom scans is very easy in netcat, which in turn, makes crafting your own tools very easy. **As you can see, crafting custom scans is very easy in netcat, which in turn, makes crafting your own tools very easy.
Ligne 41: Ligne 71:
  
 dd if=/dev/sdc | gzip -c | nc 192.168.8.103 8888** dd if=/dev/sdc | gzip -c | nc 192.168.8.103 8888**
 +
 +Comme vous pouvez le voir, l'élaboration de scans personnalisés est très facile dans netcat, ce qui, en retour, facilite grandement l'élaboration de vos propres outils.
 +
 +L'utilisation d'un u après -vnz (= -vnzu) permet le scan via UDP, très pratique pour les serveurs.
 +
 +Ne vous leurrez pas sur la puissance de netcat. Les pirates peuvent l'utiliser pour faire une sauvegarde complète de toutes vos données et demander à votre serveur de leur envoyer le tout ! Le pirate est vu sous un éclairage tellement négatif que nous pourrions l'appeler « L'administrateur filou qui fait une sauvegarde non autorisée » ! Où sont les RGPD ?
 +
 +Dans un souci de tout dire, explorons ceci. Sur votre portable, lancez la commande suivante :
 +
 +nc -lp 8888 | sudo dd of=/home/backups/image.img.gz
 +
 +Puis, sur votre serveur, lancez :
 +
 +dd if=/dev/sdc | gzip -c | nc 192.168.8.103 8888
  
 **Now, in this example, my server was at 192.168.0.102, and my laptop at 192.168.0.103. (assuming port 8888 is open and because hosted VM's don't have root access and port 80 can't be used, hint-hint, nudge-nudge, wink-wink.) In my backups folder, I now have a 100% copy of my server drive, or your server drive, depending on my inclination. I would not use this to make a backup normally, but in a pinch, this will do. Now we can also do the opposite, a restore. **Now, in this example, my server was at 192.168.0.102, and my laptop at 192.168.0.103. (assuming port 8888 is open and because hosted VM's don't have root access and port 80 can't be used, hint-hint, nudge-nudge, wink-wink.) In my backups folder, I now have a 100% copy of my server drive, or your server drive, depending on my inclination. I would not use this to make a backup normally, but in a pinch, this will do. Now we can also do the opposite, a restore.
Ligne 49: Ligne 93:
  
 cat /home/backups/image.img.gz | nc 192.168.8.102 8888** cat /home/backups/image.img.gz | nc 192.168.8.102 8888**
 +
 +Il se trouve que, dans cet exemple, mon serveur est à 192.168.0.102 et mon portable à 192.168.0.103 (en supposant que le port 8888 soit ouvert et parce que les VM (machines virtuelles) accueillies n'ont pas d'accès en root et que le port 80 ne peut pas être utilisé, coup de coude et clin d'œil). Dans mon dossier de sauvegarde, j'ai une copie à 100 % du disque de mon serveur, ou du disque de votre serveur, suivant mon penchant. Normalement, je n'utiliserais pas ceci pour une sauvegarde, mais au besoin, ça fera l'affaire. Maintenant, nous pouvons aussi faire l'inverse, une restauration .
 +
 +nc -lp 8888 | gunzip -c | sudo dd of=/dev/sdc
 +
 +et 
 +
 +cat /home/backups/image.img.gz | nc 192.168.8.102 8888
  
 **The -lp switch is very handy; it listens on a specific port. In the old days before Teamviewer and the likes, we used the screen command to mirror a screen and chat to one another. Another way of chatting, server to server, or workstation to workstation, would be via netcat. Just go typing everything before the pipe '|' in the example, on one side, and the address and port on the other, you can have a rudimentary IRC chat. Very handy for talking to an IT person in a large server room, when you are at the monitor. Just like we streamed a whole hard drive from one computer to another, we can stream any file as well. (and play it on VLC ~ hello own Netflix!) Here is a nice tutorial I found: https://linoxide.com/tools/simple-chat-netcat-linux/** **The -lp switch is very handy; it listens on a specific port. In the old days before Teamviewer and the likes, we used the screen command to mirror a screen and chat to one another. Another way of chatting, server to server, or workstation to workstation, would be via netcat. Just go typing everything before the pipe '|' in the example, on one side, and the address and port on the other, you can have a rudimentary IRC chat. Very handy for talking to an IT person in a large server room, when you are at the monitor. Just like we streamed a whole hard drive from one computer to another, we can stream any file as well. (and play it on VLC ~ hello own Netflix!) Here is a nice tutorial I found: https://linoxide.com/tools/simple-chat-netcat-linux/**
 +
 +Le commutateur -lp est très pratique : il écoute sur un port précis. Autrefois, avant Teamviewer et consorts, nous utilisions la commande screen pour avoir une image miroir de l'écran et chatter avec quelqu'un d'autre. Une autre façon de chatter, de serveur à serveur, ou de station de travail à station de travail, se fait via netcat. Vous n'avez qu'à taper tout ce qui est avant le pipe « | » dans l'exemple, d'un côté, et l'adresse et le port de l'autre côté ; vous avez ainsi un chat IRC rudimentaire. Très pratique pour parler avec un informaticien dans une grande salle des serveurs, quand vous êtes devant votre moniteur. Exactement comme quand nous déversons un disque complet d'un ordinateur sur un autre, nous pouvons aussi envoyer des fichiers de flux (et les jouer avec VLC ~ Salut, Netflix personnel !). Voici un tutoriel sympa que j'ai trouvé : https://linoxide.com/tools/simple-chat-netcat-linux/
  
 **So far we have used netcat with IP addresses, you can also use domain names, which make it handy for testing your websites. The syntax is: **So far we have used netcat with IP addresses, you can also use domain names, which make it handy for testing your websites. The syntax is:
Ligne 63: Ligne 117:
  
 while true; do sudo nc -lp 80 < index.html; done** while true; do sudo nc -lp 80 < index.html; done**
 +
 +Jusqu'ici, nous avons utilisé netcat avec des adresses IP ; nous pouvons aussi utiliser des noms de domaines, ce qui est pratique pour tester des sites Web. La syntaxe est :
 +
 +netcat domain.com port
 +
 +Si vous avez un domaine vide, et si vous voulez y ranger quelque chose temporairement, vous le pouvez, avec netcat. Si vous avez fait tourner votre serveur sur digital ocean, ou n'importe où ailleurs, netcat peut vous afficher une page Web statique.
 +
 +Créons une page d'index :
 +
 +nano index.html
 +
 +while true; do sudo nc -lp 80 < index.html; done
  
 **This keeps serving the page by looping, as if you did not, it would otherwise stop after serving the index page once. **This keeps serving the page by looping, as if you did not, it would otherwise stop after serving the index page once.
  
 There is lots more netcat can do, and many ways a sharp mind can form this versatile tool. Examples include TCP banner grabber, relays, backdoor shell, etc. Hopefully, you now have an idea of the range of netcat's usefulness. ** There is lots more netcat can do, and many ways a sharp mind can form this versatile tool. Examples include TCP banner grabber, relays, backdoor shell, etc. Hopefully, you now have an idea of the range of netcat's usefulness. **
 +
 +Ceci rafraîchit la page en boucle, car, si vous ne le faites pas, tout s'arrêtera après un seul affichage de la page d'index.
 +
 +Il y a beaucoup d'autres choses à propos de netcat et des nombreuses façons qu'un esprit affiné peut utiliser cet outil polyvalent, notamment un récupérateur de bannière TCP, des relais, un shell pour porte dérobée, etc. J'espère que vous avez maintenant une idée de l'étendue de l'utilité de netcat.
  
issue144/tutoriel3.1557070876.txt.gz · Dernière modification : 2019/05/05 17:41 de d52fr