Y
Y
Yoshinon Eared2017-09-01 02:05:55
Python
Yoshinon Eared, 2017-09-01 02:05:55

Why is Python behaving so strangely?

Good day!
There is the following code:

import requests

headers = {"user-agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"}

def Bot(login, password):
  account = 	{
          'login' : login,
          'password' : password
        }

  #Открываем сессию
  session = requests.Session()

  #Формируем данные
  post =  {
        'id1_hf_0': '',
        'nick': account['login'],
        'password': account['password']
      }

  #Отправляем POST- и GET- запросы
  r = session.post('http://example', params=post, verify=False, headers=headers)
  if "text" in r.text:
    print ('Пароль найден: '+account['login']+':'+account['password'])
  else:
    print ('Пароль не найден.')

password_list = []
login_list = []
with open('pass.txt') as file:
  password_list = [row.strip() for row in file]


with open('login.txt') as file:
  login_list = [row.strip() for row in file]

Execute: We get that everything is fine. We change the password to a deliberately false one - we get that everything is wrong. Good. We do like this: Everything is ok too. The correct password is on the first line in the file. But if you do it like this: ...it doesn't work. By the way, the use of numbers in the password, even when passing parameters directly to the function, does not work either. I looked at the output of r.text, a page is issued there, as if the passwords were entered incorrectly.
Bot('Login','Password')
Bot('Login',password_list[0])
Bot(login_list[0],password_list[0])
And the funny thing is that sometimes, after some looping tricks, even pre-working examples STOP WORKING AT ALL. Those. I write the code, check it several times for performance, copy it to a separate file, write further, get such jokes, play with cycles, get code that is not working at all, insert the old code from the file and for some reason it also turns out to be not workable.
I don't understand at all.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SolidMinus, 2017-09-01
@Aquinary

What will be the result of this line? And look at the wireshark dumps of requests to the site in both options, is there any difference. Most likely the login is incorrectly read from the file. Maybe the site has a trite WAF or a limit on the number of authorization attempts ... look at the response codes from the server I understand that this line: Was changed so that you would not be burned on the toaster? Burned down. Or are you seriously on the line "text" determine whether authorization passed or not? In general, the use of this code is 272 of the Criminal Code of the Russian Federation, for that matter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question