suyumen
目前主要在学习web相关

SUYUMEN

---在学了在学了qaQ---
nmap

TCP连接扫描

nmap -sT <host address>

SYN扫描

nmap -sS <host address>

绕过ping扫描

nmap -Pn <host address>


EIS-2019-EzPOP

直接给了源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
error_reporting(0);

class A {

protected $store;

protected $key;

protected $expire;

public function __construct($store, $key = 'flysystem', $expire = null) {
$this->key = $key;
$this->store = $store;
$this->expire = $expire;
}

public function cleanContents(array $contents) {
$cachedProperties = array_flip([
'path', 'dirname', 'basename', 'extension', 'filename',
'size', 'mimetype', 'visibility', 'timestamp', 'type',
]);

foreach ($contents as $path => $object) {
if (is_array($object)) {
$contents[$path] = array_intersect_key($object, $cachedProperties);
}
}

return $contents;
}

public function getForStorage() {
$cleaned = $this->cleanContents($this->cache);

return json_encode([$cleaned, $this->complete]);
}

public function save() {
$contents = $this->getForStorage();

$this->store->set($this->key, $contents, $this->expire);
}

public function __destruct() {
if (!$this->autosave) {
$this->save();
}
}
}

class B {

protected function getExpireTime($expire): int {
return (int) $expire;
}//格式化

public function getCacheKey(string $name): string {
return $this->options['prefix'] . $name;
}//拼接字符串

protected function serialize($data): string {
if (is_numeric($data)) {
return (string) $data;
}//格式化

$serialize = $this->options['serialize'];

return $serialize($data);
}

public function set($name, $value, $expire = null): bool{
$this->writeTimes++;

if (is_null($expire)) {
$expire = $this->options['expire'];
}

$expire = $this->getExpireTime($expire);
$filename = $this->getCacheKey($name);

$dir = dirname($filename);

if (!is_dir($dir)) {
try {
mkdir($dir, 0755, true);
} catch (\Exception $e) {
// 创建失败
}
}

$data = $this->serialize($value);

if ($this->options['data_compress'] && function_exists('gzcompress')) {
//数据压缩
$data = gzcompress($data, 3);
}

$data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data;
$result = file_put_contents($filename, $data);

if ($result) {
return true;
}

return false;
}

}

if (isset($_GET['src']))
{
highlight_file(__FILE__);
}

$dir = "uploads/";

if (!is_dir($dir))
{
mkdir($dir);
}
unserialize($_GET["data"]);


php序列化与反序列化

序列化

将变量或对象转换成字符串的过程。

1
$my = serialize($Site);

反序列化

1
unserialize(string $my)

如果传入的字符串不可被反序列化,则会返回FALSE,并产生一个 E_NOTICE


php的类与对象

因为碰到反序列化的题会碰到php的类相关的知识,有时候看代码不太懂,所以特意学习一下php的类与对象。军训太忙了,中午要洗衣服睡觉,晚上要搞志协的工作然后就又要睡觉了……水成两篇,下一篇记序列化相关的东西。


类定义

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
class Site {
/* 成员变量 */
var $url;
var $title;

/* 成员函数 */
function setUrl($par){
$this->url = $par;
}

function getUrl(){
echo $this->url . PHP_EOL;
}

function setTitle($par){
$this->title = $par;
}

function getTitle(){
echo $this->title . PHP_EOL;
}
}
?>

羊城杯2020Easyphp2

进入之后界面显示

404 Sorry, only people from GWHT are allowed to access this website.23333

观察到url

http://3d9dc9d7-0e2a-4cb9-93ad-3f176e320dd3.node4.buuoj.cn/?file=GWHT.php

扫了一下目录,在/robots.txt得到Disallow: /?file=check.php

考虑用php://filter协议

试一下

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


php异或计算

绕过原理

1.字符异或计算。

2.如eval()函数在执行时,如果内部有计算式,会先进行计算再执行函数。

常用场景

1.eval()命令执行;
2.正则未过滤异或计算符。


NCTF-2019-SQLi

特意找点sql注入的题来写写(万一能自己写出来了呢……)

开题是登录界面,给了源逻辑

1
sqlquery : select * from users where username='' and passwd=''

SUCTF-2019-EasySQL

POST数字后回显Array ( [0] => 1 )

字母后没有回显;

有长度限制;

过滤了OR ,& ,select * from ,flag


SUCTF-2019-CheckIn

签到题耶,我还以为我能写,,原来我还是不会写[乌乌]。

打开站点就是文件上传

试了:

1
<script language="php">eval($_GET['mycode']);</script>

回显exif_imagetype:not image!


HFCTF-2021-Final-easyflask

虽然是五一布置的作业,然而五一的时候完全不会。才对flask有一点点了解,过来写写这个试试吧,希望可以多做一些步骤。


根据页面指示,在file?file=/app/source得到源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python3.6
from flask import Flask, request, render_template, session
from base64 import b64decode
import pickle
import os

app = Flask(__name__)
app.config["SECRET_KEY"] = "*******"
User = type(
'User', (object,),
{
'uname': 'test',
'is_admin': 0,
'__repr__': lambda
o: o.uname,
}
)


@ app.route('/', methods=('GET',))
def index_handler():
if not session.get('u'):
u = pickle.dumps(User())
session['u'] = u
return "/file?file=index.js"


@ app.route('/file', methods=('GET',))
def file_handler():
path = request.args.get('file')
path = os.path.join('static', path)
if not os.path.exists(path) or os.path.isdir(path) or '.py' in path or '.sh' in path or '..' in path or "flag" in path:
return 'disallowed'

with open(path, 'r') as fp:
content = fp.read()
return content


@ app.route('/admin', methods=('GET',))
def admin_handler():
try:
u = session.get('u')
if isinstance(u, dict):
u = b64decode(u.get('b'))
u = pickle.loads(u)
except Exception:
return 'uhh?'
if u.is_admin == 1:
return 'welcome, admin'
else:
return 'who are you?'


if __name__ == '__main__':
app.run('0.0.0.0', port=80, debug=False)