Outils pour utilisateurs

Outils du site


issue144:tutoriel3

Ceci est une ancienne révision du document !


Web: http://netcat.sourceforge.net/ Version: 0.7.1 (2004) Netcat is a utility that uses TCP/IP to read and write data across network connections. It is mainly used for testing TCP and UDP connections, but it is so much more. Some people refer to it as the Swiss army knife of network tools. Netcat is all about network connections, monitoring, testing, and sending data with this admin tool. If - for some reason, you don't have it, install it with: sudo apt install netcat 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 au travers des connexions d'un réseau. Il est utilisé principalement pour tester les connexions TCP et UDP, mais il fait beaucoup plus. Certaines personnes se réfère à lui comme le couteau suisse des outils de réseau. Netcat fait tout à propos des connections de réseau, la supervision, les tests et l'envoi de données avec cet outil d'administration.

Si, pour une raison quelconque, vous ne l'avez pas, installez-le avec :

sudo apt install netcat

Tout administrateur de systèmes ou pirate - nous jugeons pas vers quel bord vous penchez - devrait avoir une bonne compréhension de netcat. Les administrateurs systèmes expérimentés peuvent faire presque tout leur travail en utilisant les outils intégrés sans avoir à installer des logiciels supplémentaires, et, bien sûr, netcat est présent dans 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: netcat [options] host port You can use netcat typed out in full, or simply shortened to nc. 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 exemeples. 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 racourcir 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 -, vous devrez avoir les provilèges de root ; tout le reste se passe bien en étant un simple utilisateur. Vous pouvez ajouter netcat à vos scripts et il fonctionnera bien. Vous pouvez aussi utiliser netcat pour scanner une étendue de ports (c'est appellé 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. It is also very handy to check your router ports, consider the following: Here (shown below) I scanned my router, ports 50-60, and discovered that port 53 is open. The reason I knew it would be is because DNS uses port 53. (further reading here: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers) If it was not - and I had no internet connectivity, this would be why. I used switches -vnz (clumped, I could also have used -v -n -z) as: v - verbose output n - no DNS lookup z - don't send data to the ports 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, de sorte que vous ne soyez pas banni du réseau.

Il est aussi très pratique pour vérifier les ports de votre routeur, en prenant ceci en compte :

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 connaissais était que DNS utilise le port 53 (pour en savoir plus, lisez ceci : https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers). Si ça ne l'étais pas - et que je n'avais aucune connexion à Internet, ça 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 donner 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. By adding a u after -vnz = -vnzu, will do the scan via UDP, very handy for servers. Let's not kid about the power of netcat. Hackers can use netcat to make a backup of all your data and have your server send it to them! Hacker is seen in such a negative light, let's call it 'Rogue administrator doing an unauthorized backup'? Hello GDPR? For the sake of completion, let us explore this. On your laptop run the following command: nc -lp 8888 | sudo dd of=/home/backups/image.img.gz then, on your server, run: 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 illusionnez pas sur la puissance de netcat. Les pirates peuvent l'utiliser pour faire une sauvegarde complète de toutes vos données et s'envoyer tout votre serveur ! 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 protable, 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. nc -lp 8888 | gunzip -c | sudo dd of=/dev/sdc and 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/

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: netcat domain.com port If you have an empty domain, and want to park something there, you can, with netcat. If you spun up your server at digital ocean, or wherever, netcat can display a static webpage for you. Let's make an index page: 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. 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.

issue144/tutoriel3.1557211325.txt.gz · Dernière modification : 2019/05/07 08:42 de d52fr