Python for Hackers
Python is an essential programming language to learn for Penetration Testing.
In my opinion, one of the best things about Python is how straightforward it is compared to other languages. Python uses different types of data which can be defined by the coder, Strings, Numbers, Arrays (lists), Dictionaries (key:value), etc. For example, if you want to get input from the user you use `user_name = input("Enter your name here: ")`. That line of code creates the variable user_name and (when executed) will stop and ask for user input. That is a simple example of asking for a user's name, but what if you wanted to check and make sure they did not just enter some numbers instead, and if they did we should tell them that's not the type of input we want. Well, another great thing about Python is there is usually more than one way of doing something. People will start to develop their own style simply by using the syntax/logic that works for them.
When I first started coding in Python this video taught me key concepts, the basics. I highly recommend taking the time to watch it and other free resources that are on YouTube and other sites.
When it comes to coding resources there is no better place than GitHub! If you are not familiar with GitHub, it is a site that allows users to upload their code in what is called a repository or repo and is accessible to the public to download. Some repos are just snippets of code to be reused, simple calculations, but some are full working programs. If you are running Windows you will first need to install Git to be able to clone/copy repos from your command line. One repo I recommend for Python snippets is The Algorithms; from your command line type 'git clone https://github.com/TheAlgorithms/Python.git'. Another repo for Python snippets is MyPython.
With python you can create everything from a simple program that takes a usernames as input and echoes it back, to a full working TCP/IP Server! If you are new to coding I also recommend using Visual Studio Code as your 'editor'. It has a ton of features that make writing code in any language very easy. The extensions I recommend for it are the Python extension, which is actually a package that includes Jupyter Notebooks, Live Server, for coding HTML pages, to be able to see the changes you make automatically update. As you use VSCode and open/create different file formats the Extensions tab will recommend ones that will be useful for the different formats.
Here is a simple, but fun, program that takes whatever you input and prints it in reverse.
theString = str(input("Enter Anything to be print in reverse: \n"))