issue155:tutoriel1
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue155:tutoriel1 [2020/03/28 17:47] – créée auntiee | issue155: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 now, there are 47 different recipe sites that are now supported, 5 of which I wrote for the project. I have a few more sites that I am working | + | **One of our readers, Joe Wong, wanted to know how to set up things like TOR and nmap and the like on Ubuntu. As his questions were too broad to cover in questions and answers, |
- | As most of you know, I act as an unofficial support outlet for Page, the GUI designer for Python using Tkinter. On average, | + | Let us start with the short ones, and work ourselves up to the longer winded ones? Nmap is easy. ‘Sudo apt install nmap’ will do the trick. Should you prefer |
- | Of all the questions I get about using Page, the one I get the most is how to create a program with multiple forms. The answer to this is really pretty easy, but is not as straight-forward as a user would think, hence 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”. Again, while 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 lecteurs, Joe Wong, voulait savoir comment paramétrer des choses comme TOR, nmap et consorts sur Ubuntu. Comme ces questions |
- | So, I thought I’d throw together a quick demo using Page to show how to deal with both ideas. I’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 courts, et préparez-vous pour les plus longs et tortueux ! Nmap est facile. « sudo apt install nmap » fera l' |
- | The project | + | **Similarly, |
+ | https:// | ||
- | 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, |
- | We’ll create | + | **TOR comes in two parts, the TOR network, and the TOR browser. The browser installation is as simple as downloading |
- | Below is what the Parent form looks like. I 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 TOR. L' |
- | As you can see, it’s | + | **TOR network needs a bit more. It is safest |
- | 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 buttons. The only other in the top_level form is the title of “I am Parent”. | + | sudo nano / |
- | Next, we’ll design our child program. This one is a bit more complicated, | + | Add the following lines, replacing “bionic” with your version’s code-name: |
- | As you can see, there is a small simple keypad similar to a “10 key” with 3 helper buttons, all in a frame. There is also a label that will display the value of the key presses that has the textvariable set to DisplayLabel. The helper buttons are Clear, Bksp (Backspace) | + | deb https://deb.torproject.org/ |
- | The three helper buttons have the command attributes set to on_btnClear, | + | deb-src https://deb.torproject.org/ |
- | The 11 keypad buttons don’t use the command attribute set, since it’s easier to set the callback function, which requires | + | Le réseau TOR en demande un peu plus. Le plus sûr est d' |
- | The Communications Magic | + | sudo nano / |
- | To communicate between programs, we 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 suivantes, en remplaçant « bionic » par le nom de code de votre version : |
- | Import shared | + | deb https:// |
- | 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 module. We’ll discuss this some more when we examine the code. | + | deb-src https://deb.torproject.org/ |
- | The Code | + | **You will also need to add the key: |
- | The code for the two _support.py modules will be presented below. It’s presented almost in its entirety. The 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/ |
- | As always, we’ll start with the imports section for the parent_support.py file. Notice we import child.py, child_support.py, | + | gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add |
- | import | + | NOTE: There are double dashes before |
- | 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 function. This 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/ |
- | 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 a 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 a un double tiret devant import et export ; les traitements de texte font des choses bizarres avec les tirets doubles. |
- | | + | **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, | + | 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 Red. This 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:// | ||
- | 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 | + | There is a bit of an ncurses based setup to go through, but 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 program. It is a bit more complicated, | + | sudo apt-get install tor deb.torproject.org-keyring torbrowser-launcher |
- | Again, we’ll start with the import section. Notice here, that we need to import only the shared module, since we don’t need to call any functions from the parent. | + | Rootkit Hunter (le chasseur de rootkit) : http:// |
- | 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 / |
- | 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 page, top left) for when a keypad button is clicked. Notice this must be done from scratch, since Page has no idea of the need for the function. | + | Now we get to talk about one of my favourite security tools, Lynis. So many checks, so little time. You can find it here: https:// |
- | In the callback, we 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 / |
- | 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:// | + | C'est tout. |
- | parent_support.py - https://pastebin.com/3iBHgCN0 | + | Maintenant, nous allons parler d'un de mes outils de sécurisation favoris, Lynis. Tant de vérifications en si peu de temps. Vous pouvez le trouver ici : https://cisofy.com/lynis/ |
- | child.py - https:// | + | **You can download the compressed file and do it all manually, but it is easier from the terminal. Let us grab the key first: |
- | child_support.py | + | sudo wget -O - https://packages.cisofy.com/keys/ |
- | I hope this article has given you some food for thought that can be used in your own programming. | + | Now: |
- | Until next time, keep coding. | + | sudo apt install apt-transport-https |
+ | |||
+ | Followed by: | ||
+ | |||
+ | echo ' | ||
+ | |||
+ | 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' | ||
+ | |||
+ | sudo wget -O - https:// | ||
+ | |||
+ | Maintenant : | ||
+ | |||
+ | sudo apt install apt-transport-https | ||
+ | |||
+ | suivi de : | ||
+ | |||
+ | echo ' | ||
+ | |||
+ | SI VOUS L' | ||
+ | |||
+ | **Now add the sources: | ||
+ | |||
+ | echo "deb https:// | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | 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' | ||
+ | |||
+ | Lynis est un outil qui nécessite d' | ||
+ | |||
+ | sudo lynis audit system | ||
+ | |||
+ | **References: | ||
+ | |||
+ | https:// | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | Il y a d' | ||
+ | |||
+ | Si vous avez des questions sur l' |
issue155/tutoriel1.1585414067.txt.gz · Dernière modification : 2020/03/28 17:47 de auntiee