Indonesian Back|Track Team
Share Script Filter Email : Gmail, Yahoo & Hotmail - Printable Version

+- Indonesian Back|Track Team (https://www.indonesianbacktrack.or.id/forum)
+-- Forum: General Zone (https://www.indonesianbacktrack.or.id/forum/forum-172.html)
+--- Forum: Programming (https://www.indonesianbacktrack.or.id/forum/forum-95.html)
+---- Forum: Python (https://www.indonesianbacktrack.or.id/forum/forum-111.html)
+---- Thread: Share Script Filter Email : Gmail, Yahoo & Hotmail (/thread-7099.html)



Script Filter Email : Gmail, Yahoo & Hotmail - teh manis - 03-08-2018

ane mau sharing tentang tools yang sedang ane kembangin
tools ini untuk memfilter email menurut nama domain nya gmail, yahoo & hotmail
langsung aja ke source code nya:

Code:
#!/usr/bin/env python

from optparse import OptionParser
import os.path
import re

class warna():  #definisi warna string
   cetak = '\033[0m'
   ijo ='\033[1;32m'
   putih = '\033[1;37m'
   biru = '\033[1;34m'
   kuning = '\033[1;33m'
   abang = '\033[1;31m'

def author(): #tanda %s (persen s) untuk definisikan string
   print('''%s
______  ___      ___________________________________
___   |/  /_____ ___(_)__  /___  ____/__(_)__  /_  /_____________
__  /|_/ /_  __ `/_  /__  / __  /_   __  /__  /_  __/  _ \_  ___/
_  /  / / / /_/ /_  / _  /___  __/   _  / _  / / /_ /  __/  /
/_/  /_/  \__,_/ /_/  /_____/_/      /_/  /_/  \__/ \___//_/
                                                      v.01
%s
[+] Author      : Ruitze
[+] Tool        : MailFilter v.01
[+] Description : Filter mailist Gmail, Yahoo, Hotmail
[+] Usage       : python mailFilter.py nameMailist -o %s''' % (warna.ijo,warna.putih, warna.cetak))#memanggil warna string

# variabel regex untuk mencari,membaca, mensortir data gmail yahoo hotmail
regex = re.compile(r'''(
                  ([a-zA-Z0-9._%+-]+)
                   @
                   (gmail|yahoo|hotmail)
                   (\.com)
                   )''', re.VERBOSE)

def file_to_str(filename): #membuka file mailist
   with open(filename) as f:
       return f.read().lower()

def get_emails(s): #mensortir data email pada file mailist
   return (email[0] for email in re.findall(regex, s) if not email[0].startswith('//'))

def main(): #penggunaan argument dengan optparse
   parser = OptionParser()
   parser.add_option('-o','--output',dest='output',help='output file to saveFile.txt', action='store_true')
   (options, args) = parser.parse_args()
   try:
       if args and options.output: #jika args true dan options.output true maka melanjutkan program
           for arg in args: #melooping variabel arg dalam args (argument)
               if os.path.isfile(arg): #mengecek bila arg adalah file maka lanjutkan program
                   for email in get_emails(file_to_str(arg)): #mengulang variabel email dalam mailist
                       if 'gmail' in email: #jika ada gmail dalam email maka
                           f =open('gmailFile.txt', 'a') #variabel f membuat file gmailFile.txt
                           f.write(email+'\n') #f menambahkan data email lalu membuat garis baru
                           f.close()
                       elif 'yahoo' in email: #jika ada yahoo dalam email maka
                           f = open('yahooFile.txt', 'a') #variabel f membuat file yahooFile.txt
                           f.write(email + '\n') #f menambahkan data email lalu membuat baris baru
                           f.close()
                       else: #selain gmail dan yahoo cetak hotmail
                           f = open('hotmailFile.txt', 'a')
                           f.write(email + '\n')
                           f.close()
                   author() #memanggil fungsi author
                   print(warna.cetak) #mencetak warna
                   print('%s[+] Succes filter to gmailFile.txt   [+]%s' % (warna.biru, warna.cetak)) #mencetak notif succes filter
                   print('%s[+] Succes filter to yahooFile.txt   [+]%s' % (warna.kuning, warna.cetak))
                   print('%s[+] Succes filter to hotmailFile.txt [+]%s' % (warna.abang, warna.cetak))
               else:
                   print('"{}" is not a file.').format(arg) #selain file di anggap dict

       else: #selain menjalakan python mailfilter.py maka panggil fungsi author
           author()
           print(warna.cetak)
   except Exception as e:
       print('Error Description', e) #mencetak error


if __name__=='__main__': #memanggil fungsi main()
   main()

di bawah sdikit penampakan nya :

jika menjalankan script tidak sesuai
contoh : python mailfilter.py
           

[Image: dc8qjc.jpg]

cara menggunakan nya :
$ python mailfilter.py namafile -o
contoh
$ python mailfilter.py mailist.txt -o

[Image: o6immp.png]

hasil nya bisa dilihat pada direktori /your/path/mail-filter atau langsung di ls saja

[Image: ig94ra.png]

untuk source code nya bisa di download github atau
$ git clone https://github.com/robbyparlan/mail-filter

sekian dari coder pemula ini hihi
tulis kritik & saran (jangan terlalu pedes nanti mules) Big Grin


RE: Script Filter Email : Gmail, Yahoo & Hotmail - cyberking - 03-08-2018

tools yang berguna dengan maenan yang berbau $$$
gas terus ahah


RE: Script Filter Email : Gmail, Yahoo & Hotmail - teh manis - 03-08-2018

hihi siap om gas terus sampe landing $$$