< All Intro to Python Notes

uk2newbie | Python for Security Professionals | Module 1 - Intro and Setup

By: uk2newbie | Related Course: Intro to Python | Published: February 14, 2017 | Modified: February 14, 2017
Join Cybrary

NotepadPython 101 Basics

Normal
0

false
false
false

EN-GB
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

Python   penetration testing 101 – Notes

Python was created in 1989 by Guido Van Rossum and this makes Python one of the newer languages.  Python is best described as a general purpose high level interpreter language. 

A high level language means that the code is easier to understand as it is closer to human language than machine language, and it is an interpreter language because Python uses a program called an Interpreter to execute code.  Python is an Open source language which means that is cost free and the source code is available to the public.

There are currently 2 versions of Python in circulation: Python 2 released in 2000 and Python 3 released in 2008. Python 3 is not backward compatible with Python 2. There are plenty of applications still running on Python 2 and therefore it is still worthwhile learning Python 2 syntax.

For my notes I have used Python 2

Python 101 – Basics

Strings: strings are text characters.

Integers: Whole numbers (negative or positive).

Floats: Decimal numbers.

Creating Network sockets:

In Python a network socket is a combination of IP address and numbers on our computer which represent an application.

Socket programming:

A socket program script that enables one computer to talk to another computer. It is a combination of the host IP address e.g. 192. X.X.X and Port number of connecting device\computer.

 Creating a Functions:

A block of reusable code that is used to perform a single action.

To create a function –  def  FunctionName (parameters: a,b):

e.g.

 def add(x, y):

     print ”Return x plus y”””

     print  x + y

Function Directory:

To list all the possibilities of a built-in function – use dir Command e.g dir(port) will reveal all attributes associated with the function.

 Like the dir function,  help () can be used to find all the attributes associated with the specified object.

Python Modules:

Python  allows users to import modules from different areas in order for usage. Once the code has been imported – it is then able to gain access to current user’s source code.  in one module gains access to the code in another module by importing it.

For example    for calculations –  import a calculator

>> from math import calculator

This will import a built-in Calculator module from Math.


< All Intro to Python Notes
Join Cybrary

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Cybrary On The Go

Get the Cybrary app for Android for online and offline viewing of our lessons.

Get it on Google Play
 

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel