How to make a request and search for a string

Asked

Viewed 31 times

0

I wonder how I give a request and look for a string, example: *www.site.com/index.php? id=' (Error SQL) (find the error) I’m just having trouble with it since it’s almost all set, so follow the code:

import os, socket, urllib2
os.system('clear')
while True:
url = raw_input("URL: ") #site para fazer o teste
with open('word') as wordlist: #abrindo a wordlist
lista = [linha.strip() for linha in wordlist] #passando a wordlist para  lista
for list in lista:
     url2 = url.replace(" ", list) #colocando os codigos na url get
     url3 = urllib2.urlopen(url2).read()
              cf =  url3.text
     if (cf.find("Mysql")==-1):
      print "teste deu"
     else:
     print "n deu"
     break

1 answer

0

In python type objects str have search methods, follows some of them:

>>> string = 'goiaba'
>>> string.find('a') # Retorna a primeira ocorrência da string passada
3
>>> string.startswith('g') # Verifica se a string começa com a string passada
>>> string.endswith('ba') # Verifica se a string termina com a string passada

Browser other questions tagged

You are not signed in. Login or sign up in order to post.