41: Python 3 Compatibility
7minThis transcript is also available as a PDF download within the files tab.
Python 3 Compatibility
Now if you finish the exercise, you should have a function like this that returns the arguments that the user enters and the main argument or the only argument that it takes, it’s an argument for the target. Now I went one step further and I called the function in here and my main program exactly the way that I called it in the market changed your example when we did it in the previous section. So I just have a variable called options that will capture the value for options when get arguments is called. And then I’m passing options dot target to my scan function, which is the function that that does the scan and that takes an IP as an argument or as an input. So I ended up with a program that I can run like so I can just do python program name, which is network scanner and then I can do dash t or dash dash target.
And after that I can give the Ip that I want to scan. And in this example I’m going to give a range 10 zero two one over 24 to scan my whole sub net. And as you can see, I’ll get the results in here. Now this all works and it’s all good. The only thing is the opt parts module in here is deprecated. What we mean by deprecated is it still works. It even works with python three but if the python developers wanted to add new features, they’re not going to add it to this module. They’re going to add it to a different module that came after this. Now, the reason why I showed this module is because I’m actually very used on using it and I’ve been using it even before they created the new module and since this still works, I’m just used to always use this.
No, I’m not the only program where that does that. There are loads of programs and scripts online that’s still used the opt pars, hence why python made sure that it still works even in python three and hence why I told it to you because you might be looking at some code written by some other programmer and they might be used in opt fars. Now if you want to use the successor of [inaudible] powers, it’s called Eric Pars and I’m going to include it’s manual and the resources of this lecture but using it is actually very, very simple and very, very similar to use an opt parts and you’ll see why now. So in order to use our cars instead of important opt parts, we’re going to import arc powers. And then when you’re creating the parser here and instead of doing opt parts, obviously we’re going to say arc parts, which is the name of our module.
And instead of saying option Parser, the name of the class, in this case it’s called argument parser. Again, you can see the similarities. It’s identical. The only thing we’re doing is just changing the module name and the class name. Next, when you want to add an option and instead of saying dot add option, we’re going to say dot argument. Again, everything in here stays the same. We don’t need to change any of that. And then in here when we’re calling them parts arcs to parse the arguments, again, this is the same. We don’t need to change any of that. The only differences in this case, it only returns the options. It doesn’t return the arguments. So we can remove this in here and just return the options at the end. Now this code will work, so if we just go down and run it again, as you can see it’s still working and it works exactly the same.
The methods are still called exactly the same. The only differences, they’re called different names. And again, the only difference between this module and the opt pars is that opt parts is deprecated. So whenever python developers want to add new features, they’re going to be adding it to Arc Pars, not opt pars, but opt parts works with both python two and even python three so that’s very important to note. The other notes that I wanted to show in this lecture is using the whole script with python three so arc parts and of parts both work with python three so that wouldn’t be an issue. The issue would be with [inaudible]. Now it’s not really an issue, it’s just that you need to install KP on the system or in Cali to be specific because it doesn’t come preinstalled. So it comes pre installed with python 2.7 but it doesn’t come preinstalled with python three so this is a very good opportunity to me to show you how to install modules if they’re not installed.
So you can follow the method that I’m going to show you to install any module you want. It doesn’t have to be escaping. Now in order to install python modules, we use a command called pip. So you do pip install and then you put the module name that you want to install. So in our case it’s called escapee python three so pep is a command that you use to install python modules regardless of what module you want to install. So if you want to use a module in your program and this module doesn’t come pre installed with the operating system that you’re using, then you can use pip to install the module that you want. We’re using installed to tell pip that I want to install something because we can also use pip to do other stuff like removing modules. And finally the Po, the module that we want to install is called skp python three now this command will work to install modules for Python 2.7 if you want to install modules for python three then you have to say pip three so it’s the same way.
When we use python, we actually use python 2.7 and if we want to use python three we type python three same goes when you want to install modules. You do pip three if you want to install modules on python three you do pip if you want to install modules on python. So I’m going to hit enter and this will tell me that scape is already installed on my system because I actually already installed it before recording this lecture. But if it’s not installed on your system, then it’ll install it for you. Now once you have pip installed on python three you can actually use our code exactly the same way it is. So the program that we wrote, we’ll work on both python two and python three by default, you actually don’t need to modify anything. So if I just type python three year to run my program with python three you’ll see that the program will work exactly the same way that it used to work with Python 2.7 so that’s it for this lecture. I just wanted to give you two quick notes, and as we did this, we learned a few useful things.
You must Login to access notes.
All videos in this course
Lessons
- log in to buy this course and get access 1: Introduction 7min
- log in to buy this course and get access 2: What is Programming, What is Hacking & Why Learn Them (Preview) 6min
- log in to buy this course and get access 3: Lab Overview & Needed Software 8min
- log in to buy this course and get access 4: Installing Kali 2019 as a virtual Machine 10min
- log in to buy this course and get access 5: Basic Overview of Kali Linux 5min
- log in to buy this course and get access 6: The Terminal & Linux Commands 11min
- log in to buy this course and get access 7: Python 2 VS Python 3 & Writing Our First Program 9min
- log in to buy this course and get access 8: Installing & Using a Python IDE 9min
- log in to buy this course and get access 9: What is MAC Address & How To Change it 8min
- log in to buy this course and get access 10: Using Python Modules & Executing System Commands (Preview) 9min
- log in to buy this course and get access 11: Implementing a Very Basic MAC Changer (Preview) 5min
- log in to buy this course and get access 12: Variables & Strings 10min
- log in to buy this course and get access 13: Using Variables in MAC Changer 4min
- log in to buy this course and get access 14: Getting Input From The User 10min
- log in to buy this course and get access 15: Handling User Input (Preview) 10min
- log in to buy this course and get access 16: Handling Command-line Arguments 10min
- log in to buy this course and get access 17: Initialising Variables Based on Command-line Arguments 8min
- log in to buy this course and get access 18: Functions 10min
- log in to buy this course and get access 19: Returning Values From Functions 7min
- log in to buy this course and get access 20: Decision Making - Theory 7min
- log in to buy this course and get access 21: Using Conditional Statements in MAC Changer 9min
- log in to buy this course and get access 22: What is an Algorithm 3min
- log in to buy this course and get access 23: Reading Output Returned By System Commands 6min
- log in to buy this course and get access 24: Regular Expressions (Regex) 8min
- log in to buy this course and get access 25: Extracting a Substring Using Regex 6min
- log in to buy this course and get access 26: Refactoring & Housekeeping 11min
- log in to buy this course and get access 27: Implementing The Algorithm to Check The Mac Did Change (Preview) 6min
- log in to buy this course and get access 28: Programming a Network Scanner - Introduction & Teaser 10min
- log in to buy this course and get access 29: Installing Windows as a Virtual Machine 4min
- log in to buy this course and get access 30: What is ARP & What its Used For? 10min
- log in to buy this course and get access 31: Designing an Algorithm To Discover Clients Connected To The Same Network 4min
- log in to buy this course and get access 32: Using Scapy To Create an ARP Request 7min
- log in to buy this course and get access 33: Combining Frames To Broadcast Packets 9min
- log in to buy this course and get access 34: Sending & Receiving Packets 7min
- log in to buy this course and get access 35: Lists 8min
- log in to buy this course and get access 36: Iterating Over Lists & Analysing Packet 10min
- log in to buy this course and get access 37: Using Escape Characters To Enhance Program Output 6min
- log in to buy this course and get access 38: Dictionaries 9min
- log in to buy this course and get access 39: Improving the Program Using a List of Dictionaries 9min
- log in to buy this course and get access 40: Iterating Over Nested Data Structures 7min
- log in to buy this course and get access 41: Python 3 Compatibility 7min
- log in to buy this course and get access 42: What is ARP Spoofing? 6min
- log in to buy this course and get access 43: Redirecting the Flow of Packets in a Network Using arpspoof 5min
- log in to buy this course and get access 44: Creating an ARP Response 7min
- log in to buy this course and get access 45: Sending ARP Responses 5min
- log in to buy this course and get access 46: Extracting MAC Address From Responses 7min
- log in to buy this course and get access 47: Loops 9min
- log in to buy this course and get access 48: More on Loops & Counters 8min
- log in to buy this course and get access 49: Dynamic Printing 7min
- log in to buy this course and get access 50: Handling Exceptions 5min
- log in to buy this course and get access 51: Implementing a Restore Function 12min
- log in to buy this course and get access 52: Restoring ARP Tables When an Exception Occures 6min
- log in to buy this course and get access 53: Writing a Packet Sniffer - Introduction & Teaser 5min
- log in to buy this course and get access 54: Sniffing Packets Using Scapy 7min
- log in to buy this course and get access 55: Extracting data From a Specific Layer 7min
- log in to buy this course and get access 56: Analysing Sniffed Packets & Extracting Fields From Layers 12min
- log in to buy this course and get access 57: Analysing Fields & Extracting Passwords 11min
- log in to buy this course and get access 58: Extracting URLs 8min
- log in to buy this course and get access 59: Capturing Passwords From Any Computer Connected to the Same Network 8min
- log in to buy this course and get access 60: Intercepting Packets - Creating a Proxy 13min
- log in to buy this course and get access 61: Converting Packets to Scapy Packets 9min
- log in to buy this course and get access 62: What is DNS Spoofing 7min
- log in to buy this course and get access 63: Filtering DNS Responses 6min
- log in to buy this course and get access 64: Analysing & Creating a Custom DNS Response 8min
- log in to buy this course and get access 65: Modifying Packets On The Fly 8min
- log in to buy this course and get access 66: Redirecting DNS Responses (Preview) 6min
- log in to buy this course and get access 67: Writing a File Interceptor - Introduction & Teaser (Preview) 4min
- log in to buy this course and get access 68: Filtering Traffic Based on the Port Used 9min
- log in to buy this course and get access 69: Analysing HTTP Requests 5min
- log in to buy this course and get access 70: Intercepting HTTP Requests 10min
- log in to buy this course and get access 71: Modifying HTTP Responses on The Fly 11min
- log in to buy this course and get access 72: Intercepting & Replacing Downloads on The Network (Preview) 9min
- log in to buy this course and get access 73: Writing a Code Injector - Introduction & Teaser (Preview) 1min
- log in to buy this course and get access 74: Analysing HTTP Responses 7min
- log in to buy this course and get access 75: Replacing a Substring Using Regex 7min
- log in to buy this course and get access 76: Decoding HTTP Responses 10min
- log in to buy this course and get access 77: Modifying HTTP Responses & Injecting Javascript Code in HTML Pages 9min
- log in to buy this course and get access 78: Refactoring & Housekeeping 8min
- log in to buy this course and get access 79: Debugging Issues 6min
- log in to buy this course and get access 80: Using Groups & None-capturing Regex 6min
- log in to buy this course and get access 81: Recalculating Content Length 11min
- log in to buy this course and get access 82: BeEF Overview & Basic Hook Method 7min
- log in to buy this course and get access 83: Hooking Computers Using code_injector 5min
- log in to buy this course and get access 84: Basic BeEF Commands 4min
- log in to buy this course and get access 85: Delivering Malware Using BeEF 6min
- log in to buy this course and get access 86: How to Bypass HTTPS (Preview) 10min
- log in to buy this course and get access 87: Bypassing HTTPS & Sniffing Login Credentials 8min
- log in to buy this course and get access 88: Replacing Downloads on HTTPS Pages 11min
- log in to buy this course and get access 89: Injecting Code in HTTPS Pages 8min
- log in to buy this course and get access 90: Running Python Programs on Windows 10min
- log in to buy this course and get access 91: Capturing & Analysing ARP Responses 7min
- log in to buy this course and get access 92: Detecting ARP Spoofing Attacks 8min
- log in to buy this course and get access 93: Writing Malware - Introduction & Teaser 2min
- log in to buy this course and get access 94: Execute System Command Payload 10min
- log in to buy this course and get access 95: Sending Reports By Email 11min
- log in to buy this course and get access 96: Filtering Command Output Using Regex 10min
- log in to buy this course and get access 97: Stealing WiFi Passwords Saved on a Computer 9min
- log in to buy this course and get access 98: Downloading Files From Program 8min
- log in to buy this course and get access 99: Writing Files on Disk 11min
- log in to buy this course and get access 100: Password Recovery Basics 8min
- log in to buy this course and get access 101: Using all the Above to Steal Saved Passwords Remotely 8min
- log in to buy this course and get access 102: Interacting With The File System 11min
- log in to buy this course and get access 103: Writing Malware: Keylogger -Introduction & Teaser (Preview) 4min
- log in to buy this course and get access 104: Writing a Basic Local Keylogger 10min
- log in to buy this course and get access 105: Global Variables 8min
- log in to buy this course and get access 106: Logging Special Keys 7min
- log in to buy this course and get access 107: Threading & Recursion 11min
- log in to buy this course and get access 108: OOP - Object Oriented Programming Basics 15min
- log in to buy this course and get access 109: Constructor Methods & Instance Variables 8min
- log in to buy this course and get access 110: Logging Key-strikes and Reporting Them By Email 12min
- log in to buy this course and get access 111: Writing Malware: Backdoors - Introduction & Teaser 6min
- log in to buy this course and get access 112: Client - Server Communication & Connection Types 8min
- log in to buy this course and get access 113: Connecting Two Remote Computers Using Sockets 10min
- log in to buy this course and get access 114: Sending & Receiving Data Over TCP 5min
- log in to buy this course and get access 115: Executing System Commands Remotely 10min
- log in to buy this course and get access 116: Implementing a Server 9min
- log in to buy this course and get access 117: Implementing Skeleton For Server - Client Communication 7min
- log in to buy this course and get access 118: Refactoring - Creating a Listener Class 8min
- log in to buy this course and get access 119: Refactoring - Creating a Backdoor Class 6min
- log in to buy this course and get access 120: Serialisation - Theory 11min
- log in to buy this course and get access 121: Serialisation - Implementing Reliable Methods to Send & Receive Data Over TCP 8min
- log in to buy this course and get access 122: Serialisation - Reliably Sending & Receiving Data 6min
- log in to buy this course and get access 123: Sending Commands as List & Implementing Exit Command 8min
- log in to buy this course and get access 124: Interacting With the File System - Implementing "cd" Command 9min
- log in to buy this course and get access 125: Reading Files 7min
- log in to buy this course and get access 126: Writing Files 7min
- log in to buy this course and get access 127: Downloading Files From Hacked Computer 8min
- log in to buy this course and get access 128: Implementing Upload Functionality in Listener 8min
- log in to buy this course and get access 129: Implementing Upload Functionality in Backdoor 6min
- log in to buy this course and get access 130: Handling Unknown Exceptions 9min
- log in to buy this course and get access 131: Using the Backdoor to Hack Windows, Linux & OS X 12min
- log in to buy this course and get access 132: Writing Malware: Packaging - Introduction & Teaser (Preview) 3min
- log in to buy this course and get access 133: Converting Python Programs To Windows Binary Executables 7min
- log in to buy this course and get access 134: Running Executables Silentely 7min
- log in to buy this course and get access 135: Installing Windows Pyinstaller on Linux 8min
- log in to buy this course and get access 136: Packaging Programs For Windows From Linux 8min
- log in to buy this course and get access 137: Persistence Idea 8min
- log in to buy this course and get access 138: Running Programs on Startupesson 15min
- log in to buy this course and get access 139: Creating a Basic Trojan Using Download & Execute Payload 10min
- log in to buy this course and get access 140: Creating a Trojan By Embedding Files In Program Code 8min
- log in to buy this course and get access 141: Bypassing Anti-Virus Programs - Theory 5min
- log in to buy this course and get access 142: Bypassing Anti-Virus Programs - Practical 9min
- log in to buy this course and get access 143: Adding an Icon to Generated Executables 5min
- log in to buy this course and get access 144: Spoofing File Extension 9min
- log in to buy this course and get access 145: Converting Python Programs To OS X Executables 9min
- log in to buy this course and get access 146: Converting Python Programs to Linux Executables 7min
- log in to buy this course and get access 147: Website / Web Application Hacking - Introduction & Teaser 7min
- log in to buy this course and get access 148: What is a Website 4min
- log in to buy this course and get access 149: How to Hack a Website 5min
- log in to buy this course and get access 150: Sending GET Requests To Web Servers 10min
- log in to buy this course and get access 151: Discovering Subdomains 11min
- log in to buy this course and get access 152: Discovering Hidden Paths in Websites 11min
- log in to buy this course and get access 153: Reading Response Content 6min
- log in to buy this course and get access 154: Extracting Useful Data From Response 7min
- log in to buy this course and get access 155: Filtering Results 7min
- log in to buy this course and get access 156: Extracting Unique Links & Storing Them In a List 7min
- log in to buy this course and get access 157: Recursively Discovering All Paths On a Target Website 10min
- log in to buy this course and get access 158: Sending Post Requests to Websites 12min
- log in to buy this course and get access 159: Guessing Login Information on Login Pages 9min
- log in to buy this course and get access 160: Writing a Vulnerability Scanner - Introduction & Teaser 3min
- log in to buy this course and get access 161: HTTP Requests - POST VS GET 7min
- log in to buy this course and get access 162: Parsing HTML Code 8min
- log in to buy this course and get access 163: Extracting HTML Attributes 10min
- log in to buy this course and get access 164: Posting Forms 10min
- log in to buy this course and get access 165: Building Basic Structure For Vulnerability Scanner 11min
- log in to buy this course and get access 166: Using Default Parameters 5min
- log in to buy this course and get access 167: Sending Requests in a Session 9min
- log in to buy this course and get access 168: Extracting & Submitting Forms Automatically 10min
- log in to buy this course and get access 169: Implementing a Method To Run The Scanner 6min
- log in to buy this course and get access 170: Discovering XSS Vulnerabilities 9min
- log in to buy this course and get access 171: Exploiting XSS Vulnerabilities 5min
- log in to buy this course and get access 172: Implementing Code To Discover XSS in Forms 8min
- log in to buy this course and get access 173: Implementing Code To Discover XSS in Parameters 8min
- log in to buy this course and get access 174: Automatically Discovering Vulnerabilities Using the Vulnerability Scanner 9min



