Outils pour utilisateurs

Outils du site


issue155:tutoriel1

Différences

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

Lien vers cette vue comparative

Prochaine révision
Révision précédente
issue155:tutoriel1 [2020/03/28 17:47] – créée auntieeissue155:tutoriel1 [2020/04/05 10:58] (Version actuelle) auntiee
Ligne 1: Ligne 1:
-A quick update on the recipe-scrapers library that I wrote about last month. Right nowthere are 47 different recipe sites that are now supported5 of which I wrote for the project. I have a few more sites that I am working on for the project, so that number will continue to growMany of the scrapers are dedicated to non-United States sites in many different languages. will probably explain the process of creating your own scraper in future article.+**One of our readersJoe Wongwanted to know how to set up things like TOR and nmap and the like on UbuntuAs his questions were too broad to cover in questions and answers, decided to do mini tutorial on it.
  
-As most of you know, I act as an unofficial support outlet for Page, the GUI designer for Python using TkinterOn average, spend probably 5 hours a week answering questions from users, both brand new to Page and users who have been using Page for yearsI also help out Don Rozenberg with testing new development builds, trying to break it in as many ways as I canOnce I can’t break it anymore, Don usually creates a releaseIt’s a very time consuming job, but one I really enjoy.+Let us start with the short onesand work ourselves up to the longer winded ones? Nmap is easy. ‘Sudo apt install nmap’ will do the trick. Should you prefer the GUI, you need to install ZenmapThe nmap website has great tutorials on how to use nmap / zenmap. Documentation here: https://nmap.org/book/man.html - find nmap to be faster and more accurate than angry IP scanner for LinuxThere is even a book dedicated to this useful toolYou can read some of it here: https://nmap.org/book/toc.html **
  
-Of all the questions I get about using Pagethe one I get the most is how to create a program with multiple forms. The answer to this is really pretty easybut is not as straight-forward as a user would thinkhence the questions. The next question is how do I get the forms or windows to communicate with each other. My good friend Halvard from Norway asked how to have one form read information from another in “real time”. Againwhile the answer is easy, it’s not something that most users would try before they ask the question. So, in this edition, I intend to present a very simple demo to help understand the process. AND there’s an added benefit in that this solution is not limited to a Page GUI program. It can be used for any Python program including CLI programs. Your imagination is the only limit.+Un de mes lecteursJoe Wongvoulait savoir comment paramétrer des choses comme TORnmap et consorts sur Ubuntu. Comme ces questions sont trop vastes pour être insérées dans Questions et Réponsesj'ai décidé de faire un mini tutoriel dessus.
  
-SoI thought I’d throw together a quick demo using Page to show how to deal with both ideasI’m going to use Page since the process is much easier to show in a GUI, and since the first question is about dealing with multiple form Page programs.+Commençons par les plus courtset préparez-vous pour les plus longs et tortueux ! Nmap est facile« sudo apt install nmap » fera l'affaire. Si vous préférez l'affichage graphique (GUI)vous devrez installer Zenmap. Le site Web de nmap a d'excellents tutoriels sur l'utilisation de nmap/zenmap. Voici la documentation : https://nmap.org/book/man.html. Je trouve que nmap est plus rapide et plus précis que le coleureux scanner d'IP de Linux. Il y a même un livre consacré à cet outil utile. Vous pouvez en lire un peu ici : https://nmap.org/book/toc.html
  
-The project will consist of two Page formsone called “Parent” and the other called “Child”The Parent program will launch the Child program and will receive data from the child.+**Similarly, wireshark is available from your repositories, so ‘sudo apt install wireshark’ will fetch it for youalternatively search in the software centreIf you need a quick primer,  
 +https://www.youtube.com/watch?v=TkCSr30UojM - is a handy link. As network traffic analysers go, this is awesome. If you just want the basic commands, go here: https://www.tecmint.com/wireshark-network-traffic-analyzer-for-linux/ **
  
-Form Design+De la même façon, wireshark est disponible dans vos dépôts ; aussi, « sudo apt install wireshark » ira vous le chercher ; autre solution, trouvez-le dans le Centre de logiciels. Si vous avez besoin d'une rapide présentation, https://www.youtube.com/watch?v=TkCSr30UojM est un lien pratique. Comme analyseurs de trafic du réseau, c'est impressionnant. Si vous voulez juste les commandes de base, allez ici : https://www.tecmint.com/wireshark-network-traffic-analyzer-for-linux/
  
-We’ll create the Parent form firstI won’t bore you with the form creation details, I’ll just provide a screenshot of the form and give you a small amount of important information about some special attributes of some of the widgets.+**TOR comes in two parts, the TOR network, and the TOR browserThe browser installation is as simple as downloading the .deb-file from the TOR browser website and installing it. The other option is to download the .tar-file and extract it to your home folder. The compressed file includes a launcher you can copy to your desktop, if you like. It is good idea to keep the folder separate from your current Firefox installation. The browser manual is here: https://tb-manual.torproject.org **
  
-Below is what the Parent form looks likeI didn’t spend much time on making it pretty and mainly kept the attributes for everything on the form to their defaults where possible.+TOR est livré en deux parties, le réseau TOR et le navigateur TORL'installation du navigateur est aussi simple que de télécharger le fichier .deb depuis le site Web du navigateur TOR et de l'installer. L'autre option est de télécharger le fichier .tar et de l'extraire dans votre dossier personnel. le fichier compressé inclut un lanceur que vous pouvez copier sur votre bureau, si ça vous chante. C'est une bonne idée de garder le dossier séparé de votre installation courante de Firefox. Le manuel du navigateur est ici : https://tb-manual.torproject.org
  
-As you can see, it’s very simple formTwo buttons and four labels. The two buttons are named or aliased (from left to right) as btnLaunch and btnExit. There two static labels (status and received) and two dynamic labels, one that is a simple coloured square which shows the connection status to the child form and one (that shows as a fancy ribbed box) which has the textvariable set as DataReceived so it can be updated easily by code. This willas the variable suggests, contain the data that comes from the child formBefore saved the formI moved it to the middle-left of the screen. The child form will be positioned to the middle-right side of the screen.+**TOR network needs bit moreIt is safest to install TOR from the official repository. To add it, simply edit your sources file. I will use nano herebut the editor does not matter
  
-btnLaunch has the command attribute set to “on_btnLaunch” and the btnExit has the command attribute set to “on_btnExit”These are the names of the callback functions for each of the buttonsThe only other in the top_level form is the title of “I am Parent”.+sudo nano /etc/apt/sources.list.d/tor.list
  
-Nextwell design our child program. This one is a bit more complicated, but not horribly so.+Add the following linesreplacing “bionic” with your versions code-name:
  
-As you can see, there is a small simple keypad similar to a “10 key” with 3 helper buttons, all in a frameThere is also a label that will display the value of the key presses that has the textvariable set to DisplayLabelThe helper buttons are ClearBksp (Backspace) and Enter. At this point the enter key does nothing. There is also an Exit button.+deb https://deb.torproject.org/torproject.org bionic main, and
  
-The three helper buttons have the command attributes set to on_btnClear, on_btnBackspace and on_btnEnter, which, again, are the callback functions, and the exit button has its command attribute set to on_btnExit.+deb-src https://deb.torproject.org/torproject.org bionic main**
  
-The 11 keypad buttons don’t use the command attribute setsince it’s easier to set the callback functionwhich requires parameter containing which button was clicked, by using the bind command – which we will see in a few minutes. We’ll set the bindings in the _support module.+Le réseau TOR en demande un peu plus. Le plus sûr est d'installer TOR depuis le dépôt officiel. Pour l'ajouteréditez simplement votre fichier de sources. J'utiliserai nano icimais l'éditeur n'pas d'importance :
  
-The Communications Magic+sudo nano /etc/apt/sources.list.d/tor.list
  
-To communicate between programswe use a shared python file, in this case called “shared.py”. Really apropos filename, huh? This module is imported into both (or as many programs as needed) programs as a standard import…+Ajoutez les lignes suivantesen remplaçant « bionic » par le nom de code de votre version :
  
-Import shared+deb https://deb.torproject.org/torproject.org bionic main
  
-The file itself is actually an empty file. There is nothing in it. However, since both of our programs have imported it, they can each read from and write to it.+et
  
-However, you need to be careful to make sure that before you try to read the value of a variable from it, the value must have already been written to the shared moduleWe’ll discuss this some more when we examine the code.+deb-src https://deb.torproject.org/torproject.org bionic main
  
-The Code+**You will also need to add the key:
  
-The code for the two _support.py modules will be presented belowIt’s presented almost in its entiretyThe code for the GUI files won’t be presented, nor will the .tcl files, however the GUI.py files will be available from the pastebin repository so you can actually run the programs.+curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | sudo gpg --import 
  
-As always, we’ll start with the imports section for the parent_support.py file. Notice we import child.py, child_support.py, and shared.py+gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
  
-import sys +NOTE: There are double dashes before import and export, word processors do weird things with double dashes.**
-import child +
-import child_support +
-import shared+
  
-The next function (below) is provided by Page for us, which is the set_Tk_var function. This gives us the access to the Label that displays the values that are generated by the child program.+Vous devez aussi ajouter la clé :
  
-Next up is the init functionThis is the very last thing that gets run within the program before the GUI is shown to the user, so we run any initialization and setup tasks from this function. The top part of the function is already written for us by Page. I always provide the comment box, just to give me a “landmark” to easily find the function. We’ll discuss my added code below...+curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | sudo gpg --import 
  
-The first two lines of my added code, set two variables in the shared module. That way, when the child program starts up, the variables are already there and can be written to when needed. We also use those variables in the next function so they need to be initialized right away. If we don’t, Python will throw an error.+gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add
  
-The next thing we do is assign an alias for the status label, which is the red square that shows when the child program is running and connected to the shared module. Finally, I set up timer function that Tkinter provides called “root.after”. This is an event that fires every X milliseconds to take care of just about any kind of repetitive task you want to do. You can also create multiple ‘root.after’ timers that run simultaneously. The basic syntax is:+NOTE : Il y un double tiret devant import et export ; les traitements de texte font des choses bizarres avec les tirets doubles.
  
-     handle = root.after(ms, callback)+**After the obligatory:
  
-In the case above, the handle is called “comm1” which lets me know that this particular timer is used to communicate with the child process. Notice that I set the time to 0, which means that the callback function will be called immediately, and the final parameter is the name of the callback function.+sudo apt-get update
  
-Bottom right is the callback function code…+just type the following
  
-First, we set two global variables, comm1 which is the handle for the timer, and LblStat which is the alias for our little red square. Next, we access the shared module to see if the child process is running by checking shared.child_active to see if it’s True. This is set as soon as the child program starts up. If it is, we set the square colored label to “Green” to show that the child process is running and then we check to see if shared.ReadyToRead is set to True – which is basically a flag that says that one of the numeric keys has been clicked. If it is, we get that data, put it into the display label with the .set() method, and clear the ReadyToRead flag, so we can wait for the next click event on the child process. If the shared.child_active flag is False, we reset the coloured square to RedThis way, when the child program is exited, we will know it visually.+sudo apt-get install tor deb.torproject.org-keyring torbrowser-launcher
  
 +Rootkit Hunter : http://rkhunter.sourceforge.net/ is not difficult to install and run either. Type:
  
-Finally, we “re-arm” the timer routine, this time to check 100 ms from that point.+sudo apt install rkhunter
  
-Now, we look at the on_btnExit callback function (shown above). It’s very simple. We simply call the destroy_window() function that will cleanly end the program. The destroy_window function is provided by Page as is the on_btnExit callback skeletonsince we added the callback name in the command attribute for the exit button. All we have to do is add the line “destroy_window()”.+There is a bit of an ncurses based setup to go throughbut it is really straightforward**
  
-Next, we’ll look at the btnLaunch callback function (above). This is how we make the child program start. Again, we used the command attribute for the button in Page, so the skeleton is started for us…+Après la formule obligatoire :
  
-The only line we need to enter here is the last one. Since we have already imported the child.py GUI file at the top of the code, we just need to call the create_Toplevel1() function. This is the entry point for the program when it is called from another program.+sudo apt-get update
  
-Finally, I’ve provided the destroy_window() (below) which is provided by Page, just so you can see it.+tapez juste ce qui suit :
  
-Now we’ll look at the child programIt is a bit more complicated, but not overly so. Again, I’m going to provide the code here for only the child_support.py module.+sudo apt-get install tor deb.torproject.org-keyring torbrowser-launcher
  
-Again, we’ll start with the import sectionNotice herethat we need to import only the shared modulesince we don’t need to call any functions from the parent.+Rootkit Hunter (le chasseur de rootkit) : http://rkhunter.sourceforge.net/ n'est difficileni à installerni à lancerSaisissez :
  
-import sys+sudo apt install rkhunter
  
-import shared+Il y a quelques réglages basés sur ncurses à faire, mais c'est vraiment direct. 
 +  
 +***Once installed, rootkit hunter needs you to edit the configuration file a bit:
  
-Top right is the definition for the label that shows the running value from the keypad button entries.+sudo nano /etc/rkhunter.conf
  
-The first thing we do is set up a global variable to hold the accumulated value of the keypad entries. We then call the function setup_bindings() that attaches the callback function to all of the buttons of the keypad. Finally, we set the shared.child_active flag to True.+and make sure MIRRORS MODE=0 and WEB_CMD="" 
  
-Since we are going to pass parameters to the callback for the keypad buttons, it’s much easier to deal with things here (below) than to try to do it within Page through the command attribute.+That’s it.
  
-Now we define the callback routine code (next pagetop left) for when a keypad button is clickedNotice this must be done from scratchsince Page has no idea of the need for the function.+Now we get to talk about one of my favourite security toolsLynisSo many checksso little time. You can find it here: https://cisofy.com/lynis/**
  
-In the callbackwe simply take the value (which is the number of the button) and append it, as a string, to the valu variable. We also check to see if the period key (value 10) was pressed, and if it was, then we add the period into the display value. Finally, we put the data into the DisplayLabel through the .set() method, and set shared.ReadyToRead to True, so the parent knows to pull the data.+Une fois installévous devez modifier un peu le fichier de configuration de Rootkit Hunter : 
  
-We don’t do anything with the Enter button, so we just leave the skeleton for later use (far right).+sudo nano /etc/rkhunter.conf
  
-As usual,, I’ve put the code for the programs on Pastebin. You can find the links below:+et assurez-vous que MIRRORS MODE=0 et WEB_CMD="" 
  
-parent.py - https://pastebin.com/AZXXvuAU+C'est tout.
  
-parent_support.py - https://pastebin.com/3iBHgCN0+Maintenant, nous allons parler d'un de mes outils de sécurisation favoris, LynisTant de vérifications en si peu de temps. Vous pouvez le trouver ici : https://cisofy.com/lynis/
  
-child.py - https://pastebin.com/bwZLnkHc+**You can download the compressed file and do it all manually, but it is easier from the terminalLet us grab the key first
  
-child_support.py - https://pastebin.com/Vg0K1w5G+sudo wget -O - https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add’
  
-I hope this article has given you some food for thought that can be used in your own programming.+Now:
  
-Until next timekeep coding.+sudo apt install apt-transport-https 
 + 
 +Followed by: 
 + 
 +echo 'Acquire::Languages "none";' | sudo tee /etc/apt/apt.conf.d/99disable-translations’ 
 + 
 +IF YOU ARE USING IT IN ENGLISH.** 
 + 
 +Vous pouvez télécharger le fichier compressé et tout faire à la main, mais c'est plus facile à partir du terminal. Récupérons la clé d'abord : 
 + 
 +sudo wget -O - https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add 
 + 
 +Maintenant : 
 + 
 +sudo apt install apt-transport-https 
 + 
 +suivi de : 
 + 
 +echo 'Acquire::Languages "none";' | sudo tee /etc/apt/apt.conf.d/99disable-translations’ 
 + 
 +SI VOUS L'UTILISEZ EN ANGLAIS. 
 + 
 +**Now add the sources: 
 + 
 +echo "deb https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list 
 +  
 +You know the drill after this:  
 + 
 +sudo apt update && sudo apt install lynis 
 +  
 +Lynis is currently at 2.7.5, but you can install as far back as 2.6.6 for Ubuntu 14.04. 
 +  
 +Lynis is a tool that needs to be run as root or else it will just skip some of the most important tests:  
 + 
 +sudo lynis audit system** 
 + 
 +Maintenant, ajoutez les sources : 
 + 
 +echo "deb https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list 
 +  
 +Vous connaissez la suite :  
 + 
 +sudo apt update && sudo apt install lynis 
 + 
 +Lynis est actuellement en version 2.7.5, mais vous pouvez installer à partir de l'ancienne 2.6.6 pour Ubuntu 14.04. 
 + 
 +Lynis est un outil qui nécessite d'être lancé comme root ; sinon, certains des tests les plus importants seront sautés : 
 + 
 +sudo lynis audit system 
 + 
 +**References: 
 + 
 +https://packages.cisofy.com/community/#debian-ubuntu 
 + 
 +There are other ways to install Lynis, but this is the easiest. 
 + 
 +If there are any queries on the installation of these tools, or maybe their use, please email us on misc@fullcirclemagazine.org** 
 + 
 +Références : 
 + 
 +https://packages.cisofy.com/community/#debian-ubuntu 
 + 
 +Il y a d'autres façons d'installer Lynis, mais c'est la plus rapide. 
 + 
 +Si vous avez des questions sur l'installation de ces outils, ou peut-être sur leur utilisationmerci de nous envoyer un mail à misc@fullcirclemagazine.org
issue155/tutoriel1.1585414067.txt.gz · Dernière modification : 2020/03/28 17:47 de auntiee