Did I Execute Mass Mail Attack To The Gmail or not?
Tags: python, git, linux
Published: 2019-10-28 14:54:58

"**Python is just not a scripting language but it is one of dangerous tool which helps us to execute pen testing tasks.**"

# **The Beginning:**
There was a time when I didn't know about the thing **gmail** or how to create a gmail account & how to send mail using such type of mailing services,Yeh! it sound to much awkward but I am talking about a lot of year ago. There was my friend in school who told me about such type of mail services basic understanding about how to create & send mail from **gmail**,I was happy.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/8e6vh7v0fnco9ql60ow0.gif)

## **The Research:**
Then after lot of year being computer geek I tried to understand the basic concept of mail servcies that how they works on web.**So what I learned?** Gmail or any other services basically works on smtp service & the protocol used behind these mailing action is **smtp** or **Simple Mail Transfer Protocol** with port no : 25 but for gmail is usuaully works on 587 port.And A bit of research and I found out the dangerous fact of SMTP infrastructure.You have to basically setup smtp server to send mails.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5wndqtl7ruchow439ayo.png)
**note : Yeh! there is another one protocol imap but it can read the mails and does not work as same as smtp because it doesn't provide send method.**

# **Mass Mail To The Gmail Working Or Not:**
So after understanding the smtp server concept,I thought let's try to set up the smtp server in programming way.Because I was working one of my favourite scripting language **python**, So I decided to use python module **smtplib**.**SMTPLIB** provides amazing functions to connect smtp server,so firstly created a simple script just to connect & login server only for **gmail**.
```python
import smtplib
import getpass
smtpobj = smtplib.SMTP('smtp.gmail.com',587)
my_email = input("What is  your gmail?:")
my_passw = getpass.getpass("Enter the password:")
smtpobj.starttls() 
#This step enables encryption(TLS Encryption) for your connection.
smtpobj.login(my_email,my_passw)
#this will help user to logged in gmail account
```
<p><center><b>wow! the above script was working amazingly now it was very simple to connect smtp server for me and login to gmail account.Then after this one geeky thing came into my mind let's try to send multiple mail to a particular gmail address like <a href="https://medium.com/@hackersleague/what-is-mass-mailer-attack-6f205c2d9937">mass mail</a>.</b></center></p>
<h4><center>Let's begin the fun</center></h4>
So I created a fully automated script/tool to send 100 mails to the receiver or recipient.Bravo! It was working very amazing helping me to send 100 mails or mass mail other one gmail.I have also uploaded this script into my [gist](https://gist.github.com/ankitdobhal) .
{% gist https://gist.github.com/ankitdobhal/43ce31014b3c0663d76d67ead4edba2c %}

**But the problem I was having that it was working only for 100 mails & surely this is not full mass mail attack to gmail,So to get rid I decided to create this as a open source project name as [MailBomber](https://github.com/ankitdobhal/MailBomber),Now I am working with some open source contributor to get rid this problem &  trying to build one of the super amazing tool for pentester.** 
**This article is designed to express my experience about how mass mail attack can be done using python & If their is any python lover want to collaborate with me this super amazing project can contribute your codes in below given project.** 
{% github https://github.com/ankitdobhal/MailBomber %}
**Thanks for visiting my blog please keep follow me on [twitter](https://twitter.com/arjundobal96) , [github](https://github.com/ankitdobhal), [linkedin](https://www.linkedin.com/in/ankit-dobhal-aa237015b/)**