Generating e-mail addresses from names

In some scenarios, you may have a list of employees for a target company and you want to generate a list of e-mail addresses. E-mail addresses can be potentially useful. You might want to use them to perform a phishing attack, or you might want to use them to try and log on to a company's application, such as an e-mail or a corporate portal containing sensitive internal documentation.

Getting ready

Before you can use this recipe, you will want to have a list of names to work with. If you don't have a list of names, you might want to consider first performing an open source intelligence exercise on your target.

How to do it…

The following code will take a file containing a list of names and generate a list of e-mail addresses in varying formats:

import sys

if len(sys.argv) !=3:
  print "usage: %s name.txt email suffix" % (sys.argv[0])
  sys.exit(0)
for line in open(sys.argv[1]):
  name = ''.join([c for c in line if c == " " or c.isalpha()])
  tokens = name.lower().split()
  fname = tokens[0]
  lname = tokens[-1]
  print fname+lname+sys.argv[2]
  print lname+fname+sys.argv[2]
  print fname+"."+lname+sys.argv[2]
  print lname+"."+fname+sys.argv[2]
  print lname+fname[0]+sys.argv[2]
  print fname+lname+fname+sys.argv[2]
  print fname[0]+lname+sys.argv[2]
  print fname[0]+"."+lname+sys.argv[2]
  print lname[0]+"."+fname+sys.argv[2]
  print fname+sys.argv[2]
  print lname+sys.argv[2]

How it works…

The main mechanism in this recipe is the use of string concatenation. By joining up the first name or first initial with the last name in different combinations with an e-mail suffix, you have a list of potential e-mail addresses that you can then use in a later test.

There's more…

The recipe featured shows how a list of names can be used to generate a list of e-mail addresses. However, not all the e-mail addresses will be valid. You could further narrow this list by using enumeration techniques in a company's application that may reveal whether an e-mail address exists. You could also perform further open source intelligence investigations, which may allow you to determine the correct format for the target organization's e-mail addresses. If you manage to achieve this, you can then remove any unnecessary formats from the recipe to generate a more concise list of e-mail addresses that will provide greater value to you later on.

See also

Once you've got your e-mail addresses, you may want to use them as part of the Checking username validity recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.206.69