Python – Language of the future (P1)

Tram Ho

Introduce

  • In recent years, with the development of machine learning, security, python has grown strongly and reached the top 2 in the list of most used programming languages ​​in 2019. (source: https: // codeburst.io/10-top-programming-languages-in-2019-for-developers-a2921798d652 )
  • Pyhon is a high-level, interpreted language, created by Guido van Rossum in 1991.
  • Python’s design philosophy emphasizes the ability to read code.
  • Its language structure and object-oriented approach aims to help programmers write clear, logical code for small-scale and large-scale projects.
  • Supported socket, thread, … are used strongly in security.
  • Can also be used to write web applications (Django, Flask, …)
  • Provides many powerful libraries that make it easy to accomplish your goals in the shortest possible time.

Syntax

  • The simplest is still Hello world, the syntax of python is very easy to remember and use just: print "Hello world"
  • Input data from the keyboard, here include input and raw_input, both functions are input but the input will automatically cast data according to the user and raw_input will default the user to enter the string: input("Nhập dữ liệu") raw_input("Nhập dữ liệu")
  • Declaring variables, this is one of the advantages of python and some high-level languages, we only need to declare the variable name and value, it will automatically cast the data type. a = 1 str = "Hello Sydney"
  • Commonly used data types: Python provides all the data types we often use such as: array, string, number (int, float, double, …), dictionary, and more. Data type similar to list (array) is tuple. string: "abc" number: 1234,567 array: [‘a’, ‘b’, ‘c’] dictionary: {‘a’: 1, ‘b’: 2, …} tuple: (‘a’, ‘ b ‘,’ c ‘) -> So, we are wondering what tuples are like list (array), and why tuple must be created. The simplest we know list is mutable and tuple is immutable. Moreover, the list when created is 1 and changes the value of the element to 1 memory cell and the tuple is the opposite.

Library:

  • Any language we choose is based on its robustness, and the python library helps it get there. Please list out some powerful libraries that python is supported.

requests

  • The first library we talk about is requests, which greatly assist in pentesting as well as crawl data, requests that support sessions and params are passed in the form of dictonary. The requests library is very easy to use (I used to write auto like tools, facebook comments and some other automation)
  • The installation syntax is very simple: python -m pip install requests

BeautifulSoup

  • If using the request, qa beautifulsoup cannot be omitted, this is a library that helps us easily parse from the response xml returned into data based on the corresponding tags (tags) and attributes.

hashlib

  • Next is the library used to encrypt and decode. The hashlib library provides us with all kinds of encryption, hashes, … like base64, md5, sha, hmac, ….

NumPy

  • The next library indispensable in computing (machine learning, cryptography) is numpy, it provides tools that help us easily perform matrix operations.

pycrypto

  • Another library that provides encryption, decryption and operations that convert from a string to a long number or vice versa is pycrypto. It is an almost indispensable library for the crypto population.

scapy

  • This is my favorite library when I recommend it to you. It is a “very powerful” library in network environments (especially LANs). It provides a tool so that we can change the fields in the package and the header of the packets to help us easily customize or take advantage of the purpose to attack a target. I am researching on this library and the first basic tool I can write is to scan the mac address of the IP addresses on the LAN.

Conclude :

Share the news now

Source : Viblo