
Hi guys! I am glad you decided to join the course. In this course we will be learning about Python Network Programming and TCP/IP Socket Programming.
The whole course is divided into 7 basic sections. Lets see what each section is going to cover -
1) Section 1 - Installing Python and Pycharm.
Now the network programming can also be done in simple Notepad or some other code editor but I really like coding in Pycharm because it offers a lot of awesome features. You can literally code anything in Pycharm.
Want to make a website? Can be done in Pycharm
Want to write a python code? or May be learn Machine Learning? All this is so easily implemented in Pycharm. Pycharm requires Python to run and that is why we are also going to be installing Python 3. The whole process is going to take about 5 minutes max.
2) Section 2 - Python Basics
In this section we cover some basic concepts of conditions, loops, functions and how to take input from the user. If you are not familiar with the Python language or want to revise the language once again then this section is for you. If you are comfortable with basic Python then feel free to skip this section.
3) Section 3 - Basics of Networking
In this section we will be learning about IP addresses, Ports and Sockets. We will also learn about two types of connections, that is, Direct and Reverse connections. Both of them are involved when we connect to a computer remotely. Lastly we will also learn how to create a server online using a service called Digital Ocean.
4) Section 4 - Network Programming using Python
In this section we will start working on our capstone project by building a security tool called reverse shell. Using this tool you can connect and control anyone's computer in the world using just your laptop. How cool is that? We will be learning about networking by actually coding something in Python.
5) Section 5 - Advance Socket Programming
In this last section we will add multi-client support to our reverse shell networking tool and use advance concepts like multithreading in socket programming.
Now that you know what the course is going to cover. I'll see you in the next video where we will be installing Python and Pycharm. If you already know the basics of python you can directly to the Basics of Networking section where we will start with understanding IP addresses. So ill see you over there!
Now the Graphical user Interface(Python GUI) code can also be written in simple Notepad or some other code editor but I really like coding in Pycharm because it offers a lot of awesome features. You can literally code anything in Pycharm.
Want to make a website? Can be done in Pycharm Want to write a python code? or May be learn Machine Learning? All this is so easily implemented in Pycharm.
Pycharm requires Python to run and that is why we are also going to be installing Python 3. The whole process is going to take about 5 minutes max.
In this video we are going to learn how to print anything in Python and learn about Variables and how to store data in them.
In this video we are going learn about the Python conditional statement if-else.
In this video we are going to learn how to take input from the user in Python
Learn what are functions and how to use them in Python code
Learn to store a lot of values in Python Lists and Arrays
Learn how to Loop through statements a lot of times. This is the for-loop in Python.
Second looping statement - While Loop in Python
Learn to import modules and submodules into your python project
Hey guys! Welcome to the Basics of Networking section. In this video we are going to be learning about IP addresses. You can think of IP addresses as the address of your computer or a device. If you are device has a way of connecting to the internet then it definetly has an IP address.
Right now you must be living in an apartment or a house that has an address. Because your house has an address people can send you mail or come to your house. Without the address they would be lost. Similarly, when a computer has to communicate or send a message to another another computer it needs an address and that address is known as the IP address.
Now lets see what google has to say about it - (Impomtu stuff)
Alright guys! In this video we are going to be talking about Ports. You can think of ports as exact house or apartment numbers. So IP addresses represent the city and street name and the port number represents the exact house number you are living in.
So when a computer tries to connect or communicate with another computer it not only needs the IP address but the Port as well.
So whenever we are making an application that connects one computer to another we have to make sure that we are not using the common ports.
Learning about sockets and common commands used in Python networking to create and manage sockets
Alright guys! Welcome back. In this video we are going to be learning about direct and reverse connections.
First we are going to discuss about direct connections and it's real life use case. Then we will get into some of the problems with direct connection and how reverse connection solves them.
So without wasting any time lets get into the direct connection.
Lets say you are sitting somewhere in China and you have a friend, in lets say, Texas. Now your friend has run into some kind of a problem with his computer and he wants you to fix it. So what you can do is, you can remotely connect to his computer using command shell or terminal and fix his computer for him. This type of connection is achieved by something known as a direct connection.
In a direct connection we first create a socket on our computer, which basically means opening up a line of communication between computers. Then we bind our port and host to the socket and send a request to our friend on his IP address. If he accepts our request then we will be able to remotly access his computer using our command prompt on terminal and fix his problems.
So for direct connection we require IP address of our computer as well as our friend's computer.
Now lets discuss some of the problems associated with a direct connection
1) The first major problem with a direct connection is that it's difficult to get the IP address of your friends computer if he is not tech savy. Or lets say you are hacker who wants to access the someone's computer without his knowledge. In this scenario getting the IP address of someone's computer is next to impossible.
2) Now let's assume you have gotten access to the IP address of another computer or your friends computer. That still makes it difficult to maintain the connection because the IP address is dynamic. That is, it's always changing. So you won't be able to maintain the connection for a long time.
3) And Even if we could get regular updates to his dynamic IP address, computers have a bunch of in-built firewalls which prevent these type of connections to happen, thus making it impossible for us to get into his computer.
Now that we understand the concept of direct connection lets understand the process of reverse connection and how it mitigates the problems faced in a direct connection.
To understand reverse connection I think it's best to take the example of a hacker trying to access his victim's computer without his knowledge. In reverse connection, instead of trying to inititate or start a connection from his computer the connection is initiated from the victims computer. So what hackers do is that they create a python file called reverse shell. In that file the IP address and the port of hacker's computer is stored.
Then they send the file to victim's via an email or via a usb and when the victim opens up this file it creates a reverse connection to the hackers computer.
Now because the victim is starting the connection the hacker doesn't have to worry about the IP address of the victim's computer. So even if the IP address is dynamic it doesn't really matter because every time the IP address changes the file installed on the victim's computer calibrates accordingly.
But there is still one more problem to solve. The hackers computer still has a dynamic IP address so the address stored in the file will be useless after sometime.
To mitigate this problems hackers create a server and they store the IP address of the server in the reverse shell file because servers have static IP addresses.
In the future videos we are going to be revisiting this concept of reverse connection a lot. So if you didn't understand any part of it, you don't have to worry because we will be going through this when we are writing the code to create a reverse connection.
In the next video we will be creating a live server on digital ocean and we will finally do something hands on. So ill see you in the next video.
Alright guys, welcome back. In this video we are going to learn how to create a cloud server on digital ocean. Digital ocean is a website where you can create servers. But before we get into the actual process of creating a server lets discuss what a server is.
A server or a cloud server is just a remote computer that never gets turned off. Because it is never turned off people over the internet can access it anytime. A server also has a static IP.
Hi guys and welcome to our capstone project! In this project we will be a building a networking tool called reverse shell. So what is reverse shell?
Reverse shell is a way to connect to anyone's personal computer anywhere in the world. I uses the concept of reverse connection which we discussed in the basics of networking section in the the video of direct and reverse connection.
Lets say you are in China and your friend is sitting in Texas and he wants some help with his computer. So you can just connect to his PC using a reverse shell and fix the problems. That's one of the use of reverse shell.
Another popular use of reverse shell though not very ethical, is for hackers who want to gain access to someones pc without his knowledge. What they do is that they spread this program around by giving free CD's or pendrives in front of Walmart or something and you pop in the pendrive thinking hey I wonder whats in this. And boom they now have access to your computer.
You will gain a practical knowledge of python networking while on this project.
Python Programming for Network Engineers
Alright Guys! Welcome back. In this section we are going be learning the concepts of python networking in a practical manner. In this video, we are going to start by creating a socket.
In this video we are going to learn how to bind the port and host together with a socket. Now you must be thinking, why do we actually need to bind the socket with port and host, isn't socket enough to connect computers? The answers is not really. I might be able to open a line of communication with socket but it needs to know the information about the computer or the device it is supposed to be communicating with.
And that is what we are going to be doing this video.
Accepting connection from a client
Sending commands to the connected client or victim computer
In this video we are going to be coding the client.py file.
Coding the client is going to much easier because, remember, the function of this client file is that once it's running on our friends computer it's going to try and connect to our server. And once it's connected it's just going to wait for our instructions, and that, it is going to get with send_commands function that we built in our server.py file.
Once it receives the instructions and it's going to run them and then it's going to take the result and send them back to the server.
Completing the python socket client
Testing the reverse shell on our local computer ( Python network programming )
Testing the reverse shell on a live server ( Digital ocean )
Alright guys, welcome back. In this section we are going to be taking our reverse shell program to the next level. For starters, Previously, we had one server and one client and we connected both of them using a connection object. But what if we wanted to connect to mulitple clients? That is, what if we wanted to control more than one computer from our single server?
Right now if you want to have muliple clients you will have to create mulitple servers.
But that is going to be costly and not every feasible. I'll take the example of hacker again. Lets say the hacker wants to affect hunderds of computers. Will he make hunderds of serevers? Obviously no.
-
Another example would be, lets say you are a system administrator and you need to have remote access to all computers in the lab or in workstation. In this case too our current reverse shell program won't work!
So In this video, We will add the functionality of handling all the clients from one single server python file and build the multiple client support system.
-
Before we get into that, let me explain it to out how it's going to work. Every time we accept a connection we get back two ouputputs. First is a connection object and second is the address list. Using the connection object we can send commands to another computer and the address list contains the information like port and IP address.
So what we are going to do is that we are going to create an empty list or you can call it an array of connection objects and address. And every time we connect to client we are going to append it or add it to that list.
Then we can loop through the list of clients connected to our server and choose the one that we want.
-
So we have write a program that two tasks at once.
1) The first task is to listen and accept connections from other clients and store them in a list
2) The second task is sending commands to an already connected client
But you must be thinking how can we do two tasks from the same program at the same time? This is achieved by a concept known as threading. You can think of threads as a multitasking support system. For example, I am talking to you right now and thinking at the same time. So one of my thread is handling my speaking abilities and the other thread is handling my thinking. In the same way the first thread is going to listen and accept connections from other clients and the second thread is going to handle connection with an already connected client and send commands
In this video we are going to learn how to handle multiple connection requests to the server from various clients ( python socket example )
Alright guys, welcome back. In the previous video we completed our first thread. The first thread is just going to sit and listen for new connections from clients. And whenever a client tries to connect, it is going to accept that connection and store the data associated with that connection, to a list.
In this video, we are going to be creating the content of our 2nd thread. The function of the 2nd thread is going to be to be listing out all the clients that are connected to our server. After seeing the list we can select and connect to a specific client. And after connecting to that specific client we can send commands to that client and connect to that computer remotely.
In this video, specifically we are going to bulding our own command promt or terminal, whatever you like to call it. So this interactive prompt that we will be building will be used to fulfill the functions of the 2nd thread. That is, listing out clients, selecting a client and sending commands.
Listing all the connections that are connected to the python socket server
Selecting a target/client from a list of clients
Sending commands from server to the connected client/victim
Alright guys! Welcome back. We have finished most of the code of the server.py file and finally we can set up our threading. Now if you remember we want to split this program into two tasks. The first thread is going to be waiting, and listening for connections from other clients and when it get a connection request, it's going to accept that connection and add it the connections list. The second thread is going to come into action when we want to send some kind of commands to a specific client.
So for people who are unfamiliar with threading in Python, I am going to give you a quick overview of what threading is. When you want to do tasks parallel or simultaneously then you have to use the concept of threads.
Imagine there is a factory in which a lot people are working. These people are called workers. Each worker is doing a specific job. But all of the workers are working simultaneously to create a product. Similarly in our program you can think of threads as workers. We have 2 workers in our program who will have to work simultaneously. The first worker is going to handle connections and the second one is going to send commands.
----------------------------------
Now let's discuss how we are going to be coding threads into our program. We will create 3 functions in our program.
The first function is actually going to create the worker threads. We will use a 'for' loop to create both the threads quickly. Inside the 'for' loop we will create the threads using the threading.thread function and store it in a variable 't'. After this we will set the daemon of the threads as equal to True. What this means is that we are telling the threads to release the memory after the program ends. If we don't set it equal to true then the threads are going to run in background even though the program has ended. After this we will simple start the thread using the start function.
---
Now The second function is going to store jobs in QUEUE. If you remember at the starting we created a variable called job number and it is storing two elements in a list. We need to copy both of these elements to the queue. We are doing this because threads look for jobs in a queue and not in lists. The list format was only there so you could understand the concept of threads better.
---
The third function called the work function will distribute work according to the job number. If the job number in queue is 1 then it's going to make the thread handle connections and if it's 2 then send commands.
So these are the 3 functions that we will be creating in our code. Now that we are going to write the code things are going to get much clearer.
Testing the final program on a live digital ocean server!
Have you ever wanted to connect two computers or devices remotely but didn't know how to? May be you even know how to code in Python but have no idea about Python networking? Or might even know the concepts of networking like IP address, Ports and sockets but don't know how to compile all of them together in Python?
With over 32 videos this online Python Networking course is designed to provide a solid foundation in Python Network Programming using Socket Programming and Communication. Network programming is one field which everybody uses but is still considered an advanced topic. Networking with Python is easy for beginners and powerful enough for advance coders.
You will also learn (BONUS)
How to create an online live server on Digital ocean and run python files on it
Multi threading and how to use it in creating a Python network
Python socket programming with python socket example and python socket server
Create a security tool called reverse shell used by hackers to remotely connect to victims computers.
Source Code - All
source code shown in this course is also available for download.
Students can create their own projects using
the downloaded Python files.
Why choose me as an instructor?
When i was a kid i saw this YouTube video on how make a folder invisible on Windows I was so fascinated with this idea. Since then my love for technology has only grown. I understand the people who are passionate about learning new things. At the end of each section we will take a quiz to check up on your skills and see if we’re ready for the next section. We will create this project together from start to finish.
So, why wait? If all this sounds great to you, Press on “Take this Course” and start learning today! 100% money-back guarantee!