• Perform an Arp Poisoning Attack Using Scapy

    By George El.November 2019Reading time: 3 minutes

    In this post I will show you how to perform an arp poisoning attack on local network using a python package called scapy. Scapy is a package that allows us to craft our own packets specifying all layers from layer2 to layer7. In my local network I have two pcs, with addresses 192.

    Read More...
  • How to Talk to Mysql Databases

    By George El.August 2019Reading time: 7 minutes

    In this post I will describe how to use python to execute raw queries on mysql databases. install the database First we need to install mysql or maria-db (a fork of mysql) either in unix or windows. if you have windows 10 you can install mysql on wsl (windows subsystem for linux).

    Read More...
  • Using TextFSM to Parse Cli Output

    By George El.July 2019Reading time: 4 minutes

    Many times we connect to a router or switch usually with netmiko and we want to parse the output of a command. TextFSM is a Python module for parsing semi-structured text into python tables. It uses templates that use regular expressions in order to parse the output. The good thing is that there are already hundreds of templates for many devices and commands.

    Read More...
  • Using CiscoConfParse to Parse Cisco Configurations

    By George El.June 2019Reading time: 3 minutes

    In this post I will present a python module that makes the parsing of cisco configuration files easy. The module is called CiscoConfParse Lets start by installing it pip install ciscoconfparse I will use the following cisco file which is taken from the documentation site, but I have added a few lines in the beginning

    Read More...
  • Sort Html Links in One Line

    By George El.May 2019Reading time: 2 minutes

    Recently I had to sort a lot of html links in a program I created, so I decided to write a simple one line script to do it in python. The html links are in file called links.txt The file looks like this: <a href="file1">a</a> <a href="file2">c</a> <a href="file3">z</a> <a href="file4">b</a> <a href="file5">x</a> <a href="file6">e</a> <a href="file7">f</a> <a href="file8">g</a> <a href="file9">y</a> the code I came up with is:

    Read More...
  • Null Object Pattern

    By George El.April 2019Reading time: 2 minutes

    In this post I will explain a pattern used in OOP, called Null Object Pattern. This pattern allows us to use our code as usual even if what we get back is a null object. Lets first see an example without using the pattern. I will create a dictionary called Persons that will hold Person objects.

    Read More...
  • How to Use SQLalchemy to Talk to SQL Databases

    By George El.April 2019Reading time: 4 minutes

    In this post I will describe briefly sqlalchemy. SqlAlchemy is a package that allows the user to talk to sql databases. Except for performing raw sql queries, it provides an Object Relational Mapper, ORM. An ORM maps classes to tables in the database, and objects to table rows. So instead of running sql queries on the tables, you perform actions on the objects, and the ORM takes care of translating these actions to sql queries.

    Read More...
  • Simple Factory Pattern

    By George El.April 2019Reading time: 2 minutes

    In this post I will continue from my post Abstract Classes in Python and do some modifications in order to make my design more efficient and extensible. First of all I will create a folder named carclasses and create an __init__.py file that will contain the following: from .vwcar import VWCar from .

    Read More...
  • Abstract Classes in Python

    By George El.April 2019Reading time: 2 minutes

    In my post Classes in Python I have an example of creating a class named Car and instantiating this class. In reality you would rarely do something like this, but rather use this class as a base class in order to create subclasses. Subclasses are classes that extend the base class and inherit all functionality from it.

    Read More...
  • Decorators With Parameters

    By George El.March 2019Reading time: 2 minutes

    In this post we will continue on decorators, and I will show you how we can pass parameters to decorators. Please read the previous post Decorators in Python if you are not familiar with decorators. In the previous post we saw this example. def outerf(fn): from datetime import datetime def innerf(*args, **kwargs): print (datetime.

    Read More...